From eb10f82c4c3a400ff855f506b6adf4b60e5b73d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Mon, 17 Mar 2025 15:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=9F=A5=E8=AF=A2=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/cmb/notify.go | 4 ++-- internal/biz/order_notice.go | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/internal/biz/cmb/notify.go b/internal/biz/cmb/notify.go index 29e8f27..4bc0ebc 100644 --- a/internal/biz/cmb/notify.go +++ b/internal/biz/cmb/notify.go @@ -79,9 +79,9 @@ func (v *Cmb) bizContent(_ context.Context, order *bo.OrderBo, orderNotify *bo.O return string(bizJsonBytes), nil } -func (v *Cmb) NotifyRequest(ctx context.Context, order *bo.OrderBo, req *bo.OrderNotifyBo) (*v1.CmbRequest, error) { +func (v *Cmb) NotifyRequest(ctx context.Context, order *bo.OrderBo, orderNotify *bo.OrderNotifyBo) (*v1.CmbRequest, error) { - bizContent, err := v.bizContent(ctx, order, req) + bizContent, err := v.bizContent(ctx, order, orderNotify) if err != nil { return nil, err } diff --git a/internal/biz/order_notice.go b/internal/biz/order_notice.go index 18cd9c6..3b23f41 100644 --- a/internal/biz/order_notice.go +++ b/internal/biz/order_notice.go @@ -108,18 +108,28 @@ func (v *VoucherBiz) isCanNotice(ctx context.Context) error { func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) error { - // 批量通知不做数据存储,量可能会很大很大 + // 批量通知不做数据存储,量会很大 - if err := v.Query(ctx, order); err != nil { - return err - } - - event, err := order.Status.GetOrderNotifyEvent() + status, err := v.WechatCpnRepo.Query(ctx, order) if err != nil { return err } - req := &bo.OrderNotifyBo{ + if order.Status == status { + log.Warnf("notice 券状态未改变:%s,忽略不处理,orderNo:%s", order.Status.GetText(), order.OrderNo) + return nil + } + + if err = v.UpdateOrderStatus(ctx, order.ID, status); err != nil { + return err + } + + event, err := status.GetOrderNotifyEvent() + if err != nil { + return err + } + + orderNotify := &bo.OrderNotifyBo{ OrderNo: order.OrderNo, NotifyUrl: order.NotifyUrl, Channel: order.Channel, @@ -127,7 +137,7 @@ func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) erro Type: order.Type, } - request, err := v.Cmb.NotifyRequest(ctx, order, req) + request, err := v.Cmb.NotifyRequest(ctx, order, orderNotify) if err != nil { return err } @@ -138,7 +148,7 @@ func (v *VoucherBiz) cmbOrderNotice(ctx context.Context, order *bo.OrderBo) erro } if reply.RespCode != vo.CmbResponseStatusSuccess.GetValue() { - return fmt.Errorf(reply.RespMsg) + return errors.New(reply.RespMsg) } return nil