领取成功查询核销状态,过期不做通知

This commit is contained in:
ziming 2025-06-05 14:48:23 +08:00
parent d11ff47f0c
commit 70c2f65dbf
3 changed files with 14 additions and 10 deletions

View File

@ -34,10 +34,19 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, batchNo string) error {
return fmt.Errorf("batchNo is empty")
}
log.Infof("微信查询券订单状态,batchNo:%s", batchNo)
num := 0
return 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 {
num += 1
if err := v.wechatQuery(ctx, order); err != nil {
log.Errorf("微信查询券订单状态发生错误,batchNo:%s,orderNo:%s,couponId:%s,appId:%s,openId:%s,err:%v",
batchNo, order.OrderNo, order.VoucherNo, order.AppID, order.Account, err)

View File

@ -37,7 +37,7 @@ func (p *OrderRepoImpl) FinByStockIdInBatches(ctx context.Context, batchNo strin
result := p.DB(ctx).
Where("batch_no = ?", batchNo).
Where("status = ?", vo.OrderStatusSuccess.GetValue()).
FindInBatches(&results, 10, func(tx *gorm.DB, batch int) error {
FindInBatches(&results, 20, func(tx *gorm.DB, batch int) error {
return fun(ctx, p.ToBos(results))
})

View File

@ -4,8 +4,6 @@ import (
"context"
"fmt"
"github.com/go-kratos/kratos/v2/log"
"time"
"voucher/internal/pkg/lock"
"voucher/internal/pkg/rdsmq"
)
@ -39,12 +37,9 @@ func (s *VoucherService) Handle(ctx context.Context, msg string) error {
return nil
}
return lock.NewMutex(s.rdb.Rdb, time.Hour*10).Lock(ctx, fmt.Sprintf("cmb_wechant_query_%s", msg), func(ctx context.Context) error {
if err := s.VoucherBiz.WechatQuery(ctx, msg); err != nil {
s.logHelper.Error(err)
}
return nil
})
}