orderNotice定时任务
This commit is contained in:
parent
33a9f1516b
commit
3eaffae096
|
|
@ -39,17 +39,62 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
return fmt.Errorf("未知通知类型:%s", req.PlainText.Status.GetText())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("未知通知类型:%s", req.PlainText.Status.GetText())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
|
log.Warnf("券状态已是可使用,忽略不处理,orderNo:%s", order.OrderNo)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := v.OrderRepo.Available(ctx, order.ID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.notify(ctx, order)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *VoucherBiz) expired(ctx context.Context, order *bo.OrderBo) error {
|
||||||
|
|
||||||
|
if order.Status.IsExpired() {
|
||||||
|
log.Warnf("券状态已是已过期,忽略不处理,orderNo:%s", order.OrderNo)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := v.OrderRepo.Expired(ctx, order.ID); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.notify(ctx, order)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *VoucherBiz) notify(ctx context.Context, order *bo.OrderBo) error {
|
||||||
|
|
||||||
if order.Type.IsCmb() {
|
if order.Type.IsCmb() {
|
||||||
|
|
||||||
return v.cmbNotify(ctx, order.ID)
|
return v.cmbNotify(ctx, order.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return fmt.Errorf("未知渠道订单类型:%s", order.Type.GetText())
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VoucherBiz) cmbNotify(ctx context.Context, orderId uint64) error {
|
func (v *VoucherBiz) cmbNotify(ctx context.Context, orderId uint64) error {
|
||||||
|
|
@ -72,35 +117,3 @@ func (v *VoucherBiz) cmbNotify(ctx context.Context, orderId uint64) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VoucherBiz) used(ctx context.Context, order *bo.OrderBo) error {
|
|
||||||
|
|
||||||
if order.Status.IsUse() {
|
|
||||||
log.Warnf("券状态已是已使用,忽略不处理,orderNo:%s", order.OrderNo)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return v.OrderRepo.Used(ctx, order.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *VoucherBiz) available(ctx context.Context, order *bo.OrderBo) error {
|
|
||||||
|
|
||||||
if order.Status.IsSuccess() {
|
|
||||||
log.Warnf("券状态已是可使用,忽略不处理,orderNo:%s", order.OrderNo)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Warnf("券状态重置为可使用,orderNo:%s", order.OrderNo)
|
|
||||||
|
|
||||||
return v.OrderRepo.Available(ctx, order.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *VoucherBiz) expired(ctx context.Context, order *bo.OrderBo) error {
|
|
||||||
|
|
||||||
if order.Status.IsExpired() {
|
|
||||||
log.Warnf("券状态已是已过期,忽略不处理,orderNo:%s", order.OrderNo)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return j.OrderRepo.Expired(ctx, order.ID)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ func (s *VoucherService) CronNotice(ctx context.Context) error {
|
||||||
c, ok := s.bc.Cron.CommandMap["orderNotice"]
|
c, ok := s.bc.Cron.CommandMap["orderNotice"]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Warn("orderNotice定时任务未找到")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !c.IsOpen {
|
||||||
log.Warn("orderNotice定时任务未开启")
|
log.Warn("orderNotice定时任务未开启")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue