diff --git a/internal/biz/cmb.go b/internal/biz/cmb.go index c5c121b..33805a0 100644 --- a/internal/biz/cmb.go +++ b/internal/biz/cmb.go @@ -143,6 +143,16 @@ func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (rep reps.SaleEndTime = reps.EndTime } + if wechatResp.StartTime != nil { + s, _ := time.Parse(inputFormat, *wechatResp.StartTime) + reps.SaleStartTime = s.Format(time.DateTime) + } + + if wechatResp.StopTime != nil { + e, _ := time.Parse(inputFormat, *wechatResp.StopTime) + reps.SaleEndTime = e.Format(time.DateTime) + } + reps.Amount = fmt.Sprintf("%d", *wechatResp.StockUseRule.FixedNormalCoupon.CouponAmount) reps.MinAmount = fmt.Sprintf("%d", *wechatResp.StockUseRule.FixedNormalCoupon.TransactionMinimum) diff --git a/internal/biz/cron_notice.go b/internal/biz/cron_notice.go index d0ed4c0..9ba20ae 100644 --- a/internal/biz/cron_notice.go +++ b/internal/biz/cron_notice.go @@ -139,6 +139,11 @@ func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo) error { func (v *VoucherBiz) cmbNotice(ctx context.Context, order *bo.OrderBo, orderNotify *bo.OrderNotifyBo) error { + if !orderNotify.Event.CanNotify() { + log.Warnf("notice 券状态:%s,忽略不通知,orderNo:%s", orderNotify.Event.GetText(), order.OrderNo) + return nil + } + request, err := v.Cmb.NotifyRequest(ctx, order, orderNotify) if err != nil { return err diff --git a/internal/biz/vo/order_notify_event.go b/internal/biz/vo/order_notify_event.go index e7f6416..4d68229 100644 --- a/internal/biz/vo/order_notify_event.go +++ b/internal/biz/vo/order_notify_event.go @@ -35,6 +35,10 @@ func (s OrderNotifyEvent) IsUsed() bool { return s == OrderNotifyEventUsed } +func (s OrderNotifyEvent) CanNotify() bool { + return s.IsSendDEd() || s.IsUsed() +} + func (s OrderNotifyEvent) IsExpired() bool { return s == OrderNotifyEventExpired }