Kaynağa Gözat

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

wangkaiyue 1 yıl önce
ebeveyn
işleme
59077e822b

+ 4 - 1
internal/service/invoiceDemo.go

@@ -79,7 +79,10 @@ start:
 	}
 	err := im.Auth.MakeSingleInvoice(c)
 	if err != nil {
-		<-im.RunPool
+		select {
+		case <-im.RunPool:
+		case <-time.After(time.Second * 5):
+		}
 	}
 	if gerror.Is(err, consts.LoginOutErr) {
 		g.Log().Infof(ctx, "RunJob-身份过期,需要重新登录")

+ 16 - 4
internal/service/invoiceMake.go

@@ -80,7 +80,10 @@ func (im *InvoiceManager) simpleMakeInvoice(ctx context.Context) (total, okNum i
 
 		err = im.Auth.MakeSingleInvoice(c)
 		if err != nil {
-			<-im.RunPool
+			select {
+			case <-im.RunPool:
+			case <-time.After(time.Second * 5):
+			}
 			if gerror.Is(err, consts.LoginOutErr) {
 				end = true
 				g.Log().Infof(ctx, "simpleMakeInvoice-身份过期,需要重新登录")
@@ -162,7 +165,10 @@ func (im *InvoiceManager) multipleOrdersMakeInvoice(ctx context.Context) (total,
 
 		err = im.Auth.MakeSingleInvoice(c)
 		if err != nil {
-			<-im.RunPool
+			select {
+			case <-im.RunPool:
+			case <-time.After(time.Second * 5):
+			}
 			if gerror.Is(err, consts.LoginOutErr) {
 				g.Log().Infof(ctx, "multipleOrdersMakeInvoice-身份过期,需要重新登录")
 				end = true
@@ -208,7 +214,10 @@ func (im *InvoiceManager) makeRedInvoice(ctx context.Context) (total, okNum int,
 			Date: invoiceDate.Format(consts.DateFormat_Short),
 		})
 		if err != nil {
-			<-im.RunPool
+			select {
+			case <-im.RunPool:
+			case <-time.After(time.Second * 5):
+			}
 			if gerror.Is(err, consts.LoginOutErr) {
 				g.Log().Infof(ctx, "makeRedInvoice-身份过期,需要重新登录")
 				end = true
@@ -249,7 +258,10 @@ func (im *InvoiceManager) multipleOrdersMakeRedInvoice(ctx context.Context) (tot
 			Date: invoiceDate.Format(consts.DateFormat_Short),
 		})
 		if err != nil {
-			<-im.RunPool
+			select {
+			case <-im.RunPool:
+			case <-time.After(time.Second * 5):
+			}
 			if gerror.Is(err, consts.LoginOutErr) {
 				g.Log().Infof(ctx, "multipleOrdersMakeRedInvoice-身份过期,需要重新登录")
 				end = true

+ 4 - 1
internal/service/invoiceManager.go

@@ -161,7 +161,10 @@ func (im *InvoiceManager) RunJob(ctx context.Context) {
 	//保证所有回调已执行完成
 	select {
 	case im.RunPool <- true:
-		<-im.RunPool
+		select {
+		case <-im.RunPool:
+		case <-time.After(time.Second * 5):
+		}
 	case <-time.After(time.Minute * 5):
 		g.Log().Infof(ctx, "RunJob-等待回调完成超时")
 	}

+ 4 - 1
internal/service/runOnce.go

@@ -34,7 +34,10 @@ func (im *InvoiceManager) RunRedBatchOnce(ctx context.Context) {
 			Date: data.Date,
 		})
 		if err != nil {
-			<-im.RunPool
+			select {
+			case <-im.RunPool:
+			case <-time.After(time.Second * 5):
+			}
 			if gerror.Is(err, consts.LoginOutErr) {
 				g.Log().Errorf(ctx, "RunJob-RunRedBatchOnce-身份过期,需要重新登录")
 				return