WechatQuery

This commit is contained in:
ziming 2025-06-06 09:07:27 +08:00
parent 15de8ab277
commit 3362eec301
2 changed files with 12 additions and 14 deletions

View File

@ -34,15 +34,12 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, batchNo string) error {
return fmt.Errorf("batchNo is empty") 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 num := 0
return v.OrderRepo.FinByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error { err := v.OrderRepo.FinByStockIdInBatches(ctx, batchNo, func(ctx context.Context, rows []*bo.OrderBo) error {
if len(rows) == 0 {
log.Infof("微信查询券订单状态,batchNo[%s],已处理[%d]单,无订单,结束执行", batchNo, num)
return nil
}
for _, order := range rows { for _, order := range rows {
@ -59,6 +56,14 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, batchNo string) error {
return nil 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
} }
func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error { func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error {

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/log"
"time"
"voucher/internal/pkg/rdsmq" "voucher/internal/pkg/rdsmq"
) )
@ -38,15 +37,9 @@ func (s *VoucherService) Handle(ctx context.Context, batchNo string) error {
return nil return nil
} }
start := time.Now()
fmt.Printf("微信券查询处理开始:%s,batchNo:%s", start.String(), batchNo)
if err := s.VoucherBiz.WechatQuery(ctx, batchNo); err != nil { if err := s.VoucherBiz.WechatQuery(ctx, batchNo); err != nil {
s.logHelper.Error(err) 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 return nil
} }