pro order use notify

This commit is contained in:
ziming 2025-06-09 14:36:52 +08:00
parent 16fe9ff561
commit 585fe2fb97
2 changed files with 17 additions and 17 deletions

View File

@ -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 { 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 { if err != nil {
return err 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) 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) 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 { func (v *VoucherBiz) available(ctx context.Context, order *bo.OrderBo) error {
if order.Status.IsSuccess() { if order.Status.IsSuccess() {

View File

@ -79,10 +79,24 @@ func (v *VoucherBiz) wechatQuery(ctx context.Context, order *bo.OrderBo) error {
} }
if status.IsUse() { if status.IsUse() {
return v.used(ctx, order) return v.queryUsed(ctx, order)
} else if status.IsExpired() { } else if status.IsExpired() {
return v.expired(ctx, order) return v.expired(ctx, order)
} }
return nil 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)
}