diff --git a/internal/biz/warning_budget.go b/internal/biz/warning_budget.go index f76ce44..efb8283 100644 --- a/internal/biz/warning_budget.go +++ b/internal/biz/warning_budget.go @@ -115,14 +115,24 @@ func (this *VoucherBiz) WarningBudget(ctx context.Context, product *bo.ProductBo return fmt.Errorf("no warning budget") } + if product.WarningBudget == 0 { + return fmt.Errorf("no warning budget") + } + + now := time.Now() + if now.Before(*product.StartTime) { + return fmt.Errorf("not start") + } + if now.After(*product.EndTime) { + return fmt.Errorf("expired") + } + wxResp, err := this.WechatCpnRepo.QueryProduct(ctx, product.MchId, product.BatchNo) if err != nil { return err } - if err = this.Calculate(ctx, product, wxResp); err != nil { - return err - } - return nil + + return this.Calculate(ctx, product, wxResp) } func (this *VoucherBiz) Calculate(ctx context.Context, product *bo.ProductBo, wxResp *cashcoupons.Stock) error {