通知查询检索调整

This commit is contained in:
李子铭 2025-03-17 16:27:50 +08:00
parent 418ab72562
commit 572f8db83b
3 changed files with 12 additions and 12 deletions

View File

@ -12,7 +12,7 @@ import (
"voucher/internal/pkg/lock" "voucher/internal/pkg/lock"
) )
func (v *VoucherBiz) OrderNotice(ctx context.Context) error { func (v *VoucherBiz) Notice(ctx context.Context) error {
if err := v.isCanNotice(ctx); err != nil { if err := v.isCanNotice(ctx); err != nil {
return err return err
@ -44,12 +44,8 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
for _, order := range rows { for _, order := range rows {
if order.Type.IsCmb() { if err := v.notice(ctx, order); err != nil {
log.Errorf("招行查询券订单状态发生错误,orderNo:%s,err:%v", order.OrderNo, err)
if err := v.cmbOrderNotice(ctx, order); err != nil {
log.Errorf("招行查询券订单状态发生错误,orderNo:%s,err:%v", order.OrderNo, err)
}
} }
} }
@ -108,8 +104,7 @@ func (v *VoucherBiz) isCanNotice(ctx context.Context) error {
}) })
} }
func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) error { func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo) error {
// 批量通知不做数据存储,量会很大 // 批量通知不做数据存储,量会很大
status, err := v.WechatCpnRepo.Query(ctx, order) status, err := v.WechatCpnRepo.Query(ctx, order)
@ -139,6 +134,11 @@ func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) erro
Type: order.Type, Type: order.Type,
} }
return v.cmbNotice(ctx, order, orderNotify)
}
func (v *VoucherBiz) cmbNotice(ctx context.Context, order *bo.OrderBo, orderNotify *bo.OrderNotifyBo) error {
request, err := v.Cmb.NotifyRequest(ctx, order, orderNotify) request, err := v.Cmb.NotifyRequest(ctx, order, orderNotify)
if err != nil { if err != nil {
return err return err

View File

@ -36,7 +36,7 @@ func (cs *CronServer) Start(ctx context.Context) error {
return nil return nil
} }
if err := cs.VoucherService.OrderNotice(ctx); err != nil { if err := cs.VoucherService.CronNotice(ctx); err != nil {
log.Error("cron order notice Start err: %v", err) log.Error("cron order notice Start err: %v", err)
return err return err
} }

View File

@ -31,11 +31,11 @@ func NewVoucherService(
} }
} }
func (s *VoucherService) OrderNotice(ctx context.Context) error { func (s *VoucherService) CronNotice(ctx context.Context) error {
start := time.Now() start := time.Now()
if err := s.VoucherBiz.OrderNotice(ctx); err != nil { if err := s.VoucherBiz.Notice(ctx); err != nil {
log.Error("订单定时通知,执行失败,err: %v", err) log.Error("订单定时通知,执行失败,err: %v", err)
} }