From 585fe2fb9702787c2527040984259f488dac4c29 Mon Sep 17 00:00:00 2001 From: ziming Date: Mon, 9 Jun 2025 14:36:52 +0800 Subject: [PATCH] pro order use notify --- internal/biz/wechat_notify.go | 18 ++---------------- internal/biz/wechat_query.go | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/biz/wechat_notify.go b/internal/biz/wechat_notify.go index 181f2b2..833ca14 100644 --- a/internal/biz/wechat_notify.go +++ b/internal/biz/wechat_notify.go @@ -18,7 +18,7 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req * return lock.NewMutex(v.rdb.Rdb, c.TTL).Lock(ctx, c.Key, func(ctx context.Context) error { - order, err := v.getByCouponID(ctx, req) + order, err := v.getOrder(ctx, req) if err != nil { return err } @@ -41,7 +41,7 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req * }) } -func (this *VoucherBiz) getByCouponID(ctx context.Context, req *bo.WechatVoucherNotifyBo) (*bo.OrderBo, error) { +func (this *VoucherBiz) getOrder(ctx context.Context, req *bo.WechatVoucherNotifyBo) (*bo.OrderBo, error) { order, err := this.OrderRepo.GetByVoucherNo(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID, req.PlainText.CouponID) @@ -87,20 +87,6 @@ func (v *VoucherBiz) notifyUsed(ctx context.Context, order *bo.OrderBo, req *bo. return v.notify(ctx, order) } -func (v *VoucherBiz) used(ctx context.Context, order *bo.OrderBo) error { - - if order.Status.IsUse() { - log.Warnf("券状态已是已使用,忽略不处理,orderNo:%s", order.OrderNo) - return nil - } - - if err := v.OrderRepo.Used(ctx, order.ID); err != nil { - return err - } - - return v.notify(ctx, order) -} - func (v *VoucherBiz) available(ctx context.Context, order *bo.OrderBo) error { if order.Status.IsSuccess() { diff --git a/internal/biz/wechat_query.go b/internal/biz/wechat_query.go index c3b027d..2098bc9 100644 --- a/internal/biz/wechat_query.go +++ b/internal/biz/wechat_query.go @@ -79,10 +79,24 @@ func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error { } if status.IsUse() { - return v.used(ctx, order) + return v.queryUsed(ctx, order) } else if status.IsExpired() { return v.expired(ctx, order) } return nil } + +func (v *VoucherBiz) queryUsed(ctx context.Context, order *bo.OrderBo) error { + + if order.Status.IsUse() { + log.Warnf("券状态已是已使用,忽略不处理,orderNo:%s", order.OrderNo) + return nil + } + + if err := v.OrderRepo.Used(ctx, order.ID); err != nil { + return err + } + + return v.notify(ctx, order) +}