From 994e47b4d0577fb6a9ecbaca970cc2e5abb92f5f Mon Sep 17 00:00:00 2001 From: ziming Date: Fri, 6 Jun 2025 09:13:42 +0800 Subject: [PATCH] WechatQuery --- internal/biz/wechat_query.go | 10 +--------- internal/biz/wechat_retry.go | 14 ++++++++------ internal/service/wechat_query.go | 2 +- internal/service/wechat_retry.go | 7 ------- 4 files changed, 10 insertions(+), 23 deletions(-) diff --git a/internal/biz/wechat_query.go b/internal/biz/wechat_query.go index ebef404..4ab32b2 100644 --- a/internal/biz/wechat_query.go +++ b/internal/biz/wechat_query.go @@ -30,10 +30,6 @@ func (v *VoucherBiz) PushWechatQuery(ctx context.Context, productNo string) erro func (v *VoucherBiz) WechatQuery(ctx context.Context, batchNo string) error { - if batchNo == "" { - return fmt.Errorf("batchNo is empty") - } - start := time.Now() log.Warnf("微信券查询处理开始:%s,batchNo:%s", start.String(), batchNo) fmt.Printf("微信券查询处理开始:%s,batchNo:%s", start.String(), batchNo) @@ -56,14 +52,10 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, batchNo string) error { return nil }) - if err != nil { - return err - } - log.Warnf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num) fmt.Printf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num) - return nil + return err } func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error { diff --git a/internal/biz/wechat_retry.go b/internal/biz/wechat_retry.go index 321205f..c5fe0c0 100644 --- a/internal/biz/wechat_retry.go +++ b/internal/biz/wechat_retry.go @@ -30,14 +30,12 @@ func (v *VoucherBiz) PushWechatRetry(ctx context.Context, productNo string) erro func (v *VoucherBiz) WechatRetry(ctx context.Context, batchNo string) error { - if batchNo == "" { - return fmt.Errorf("batchNo is empty") - } - - log.Infof("失败订单重试开始,batchNo:%s", batchNo) + start := time.Now() + log.Warnf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo) + fmt.Printf("失败订单重试开始:%s,batchNo:%s", start.String(), batchNo) num := 0 - return v.OrderRepo.FinFailByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error { + err := v.OrderRepo.FinFailByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error { if len(rows) == 0 { log.Infof("微信查询券订单状态,batchNo[%s],已处理[%d]单,无订单,结束执行", batchNo, num) @@ -59,4 +57,8 @@ func (v *VoucherBiz) WechatRetry(ctx context.Context, batchNo string) error { return nil }) + log.Warnf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num) + fmt.Printf("微信券查询处理耗时:%s,batchNo:%s,处理%d单", time.Now().Sub(start).String(), batchNo, num) + + return err } diff --git a/internal/service/wechat_query.go b/internal/service/wechat_query.go index 98d7813..35a2a9f 100644 --- a/internal/service/wechat_query.go +++ b/internal/service/wechat_query.go @@ -33,7 +33,7 @@ func (s *VoucherService) GetConfig() *rdsmq.ConsumeConfig { func (s *VoucherService) Handle(ctx context.Context, batchNo string) error { if batchNo == "" { - s.logHelper.Errorf("RdsMQ keySend error: batchNo is empty") + s.logHelper.Errorf("wechat query error: batchNo is empty") return nil } diff --git a/internal/service/wechat_retry.go b/internal/service/wechat_retry.go index 04a8bfd..34cc754 100644 --- a/internal/service/wechat_retry.go +++ b/internal/service/wechat_retry.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "github.com/go-kratos/kratos/v2/log" - "time" "voucher/internal/pkg/rdsmq" ) @@ -38,15 +37,9 @@ func (s *VoucherService) HandleWechat(ctx context.Context, batchNo string) error return nil } - start := time.Now() - fmt.Printf("失败订单重试处理开始:%s,batchNo:%s", start.String(), batchNo) - if err := s.VoucherBiz.WechatRetry(ctx, batchNo); err != nil { s.logHelper.Error(err) } - log.Warnf("失败订单重试处理耗时:%s,batchNo:%s", time.Now().Sub(start).String(), batchNo) - fmt.Printf("失败订单重试处理耗时:%s,batchNo:%s", time.Now().Sub(start).String(), batchNo) - return nil }