Prechádzať zdrojové kódy

Merge branch 'feature/v2.0.2' of qmx/ElectronicInvoice into main

wangkaiyue 1 rok pred
rodič
commit
4fe87b6ff6

+ 12 - 3
internal/controller/callback.go

@@ -7,6 +7,7 @@ import (
 	"github.com/gogf/gf/v2/util/gconv"
 	"net/url"
 	"strings"
+	"time"
 )
 
 // CallBack 回调
@@ -41,12 +42,20 @@ func CallBack(r *ghttp.Request) {
 			qData := gconv.Map(r.Get("data"))
 			switch qData["taskType"] {
 			case "2": //电子发票开具
-				<-service.JyInvoiceManager.RunPool //可进行下次开票请求
+				select {
+				case <-service.JyInvoiceManager.RunPool: //可进行下次开票请求
+				case <-time.After(time.Second * 5):
+					g.Log().Infof(ctx, "开具发票结束 蓝票 RunPool 放回超时")
+				}
 				g.Log().Infof(ctx, "开具发票结束")
 			case "4": //活体认证
 			case "5": //验证电子税局登录授权
 			case "9": //红冲
-				<-service.JyInvoiceManager.RunPool //可进行下次开票请求
+				select {
+				case <-service.JyInvoiceManager.RunPool: //可进行下次开票请求
+				case <-time.After(time.Second * 5):
+					g.Log().Infof(ctx, "开具发票结束 红冲 RunPool 放回超时")
+				}
 				g.Log().Infof(ctx, "发票冲红结束")
 			default:
 				g.Log().Infof(ctx, "未知回调任务退出 %+v", qData)
@@ -65,7 +74,7 @@ func CallBack(r *ghttp.Request) {
 
 // printFilter 打印参数调试
 func printFilter(value url.Values) map[string][]string {
-	var filter = []string{"pdf"} //过滤部分字段
+	var filter = []string{"pdf", "xml"} //过滤部分字段
 	res := map[string][]string{}
 	for key, val := range value {
 		add := true

+ 3 - 2
internal/service/invoiceManager.go

@@ -157,14 +157,15 @@ func (im *InvoiceManager) RunJob(ctx context.Context) {
 			return
 		}
 	}
+	g.Log().Infof(ctx, "RunJob-multipleOrdersMakeRedInvoice任务完成 共%d个 完成%d个", total, okNum)
 	//保证所有回调已执行完成
 	select {
 	case im.RunPool <- true:
+		<-im.RunPool
 	case <-time.After(time.Minute * 5):
 		g.Log().Infof(ctx, "RunJob-等待回调完成超时")
 	}
-	<-im.RunPool
-	g.Log().Infof(ctx, "RunJob-multipleOrdersMakeRedInvoice任务完成 共%d个 完成%d个", total, okNum)
+	g.Log().Infof(ctx, "开票任务结束")
 }
 
 // NoticeJob 为开票成功提示