diff --git a/internal/biz/order_notice.go b/internal/biz/cron_notice.go similarity index 89% rename from internal/biz/order_notice.go rename to internal/biz/cron_notice.go index e7b3956..d0ed4c0 100644 --- a/internal/biz/order_notice.go +++ b/internal/biz/cron_notice.go @@ -12,7 +12,7 @@ import ( "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 { return err @@ -44,12 +44,8 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error { for _, order := range rows { - if order.Type.IsCmb() { - - if err := v.cmbOrderNotice(ctx, order); err != nil { - log.Errorf("招行查询券订单状态发生错误,orderNo:%s,err:%v", order.OrderNo, err) - } - + if err := v.notice(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) @@ -139,6 +134,11 @@ func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) erro 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) if err != nil { return err diff --git a/internal/server/cron.go b/internal/server/cron.go index a7070d4..7b7ec90 100644 --- a/internal/server/cron.go +++ b/internal/server/cron.go @@ -36,7 +36,7 @@ func (cs *CronServer) Start(ctx context.Context) error { 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) return err } diff --git a/internal/service/voucher.go b/internal/service/voucher.go index d189357..3b601c2 100644 --- a/internal/service/voucher.go +++ b/internal/service/voucher.go @@ -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() - if err := s.VoucherBiz.OrderNotice(ctx); err != nil { + if err := s.VoucherBiz.Notice(ctx); err != nil { log.Error("订单定时通知,执行失败,err: %v", err) }