From 4107f7f1ba1d9cb4e4493b81054859ef63e00a69 Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 2 Jul 2025 09:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A617?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/warning_budget.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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 {