Jelajahi Sumber

补充申报方法

1 2 minggu lalu
induk
melakukan
c4de9e6bca
2 mengubah file dengan 41 tambahan dan 2 penghapusan
  1. 15 0
      common/converter.go
  2. 26 2
      common/utils.go

+ 15 - 0
common/converter.go

@@ -256,3 +256,18 @@ func GetInputValue(p *rod.Page, xPath string) string {
 	str := MustElementX(p, xPath).MustEval(`()=>{return this.value}`).Str()
 	return strings.ReplaceAll(str, ",", "")
 }
+
+func FloatToStrN(f float64, lens ...int) string {
+	if f == 0 {
+		return ""
+	}
+	lenth := 2
+	if len(lens) == 1 {
+		lenth = lens[0]
+	}
+	str := strconv.FormatFloat(f, 'f', lenth, 64)
+	if str == "-0.000" || str == "-0.00" || str == "-0.0" || str == "-0" {
+		str = ""
+	}
+	return str
+}

+ 26 - 2
common/utils.go

@@ -2,6 +2,7 @@ package common
 
 import (
 	"bytes"
+	"context"
 	"crypto/md5"
 	"encoding/hex"
 	"encoding/json"
@@ -9,6 +10,7 @@ import (
 	"git.listensoft.net/tool/jspkit/common/lxhttp"
 	"git.listensoft.net/tool/jspkit/common/models"
 	"git.listensoft.net/tool/jspkit/common/variable"
+	"git.listensoft.net/tool/jspkit/common/watermark"
 	"git.listensoft.net/tool/jspkit/logger"
 	"git.listensoft.net/tool/jspkit/taxerr"
 	"github.com/go-kratos/kratos/v2/log"
@@ -32,8 +34,8 @@ type LvName string
 const (
 	CheckSuccess  LvName = "申报成功" // 检查成功 ------ 检查完全通过
 	CheckFail     LvName = "检查失败" // 检查任务失败 ----- 网页打开失败等
-	CheckOmit     LvName = "有遗漏"   // 检查有遗漏 ----- 未申报问题
-	CheckAbnormal LvName = "有异常"   //检查有异常 ----- 税款问题
+	CheckOmit     LvName = "有遗漏"  // 检查有遗漏 ----- 未申报问题
+	CheckAbnormal LvName = "有异常"  //检查有异常 ----- 税款问题
 )
 
 func GeneratePath(suffix string) string {
@@ -433,3 +435,25 @@ func SaveCookiesNoPhone(key string) error {
 	logger.Info("SaveSessionKey:", key)
 	return nil
 }
+
+func SaveErrImgLv(lv LvName, p *rod.Page, info models.CompanyInfo, location string) string {
+	checkPath := GenerateCheckImagePath(lv, info.TaxNo, info.Period, location)
+	p.Timeout(ClickTimeOut).MustScreenshot(checkPath)
+	_ = watermark.Add(checkPath)
+	checkPath2 := PostSbjt(info.TaxNo, info.Period, checkPath)
+	_ = os.Remove(checkPath)
+	return checkPath2
+}
+
+func CheckError(ctx context.Context, task *models.TaxTask, err error) {
+	errStr := HandleError(ctx, err).Error()
+	if strings.Contains(errStr, "网页") {
+		//task.Result.Status = variable.TaxFail
+		//task.Result.ErrLog = errStr
+		task.Result.BusinessStatus = variable.TaxFail
+		task.Result.BusinessLog = errStr
+	} else {
+		task.Result.BusinessStatus = variable.TaxFail
+		task.Result.BusinessLog = errStr
+	}
+}