pro order use notify
This commit is contained in:
parent
16fe9ff561
commit
585fe2fb97
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue