This commit is contained in:
ziming 2025-07-02 09:46:00 +08:00
parent 9cab8c7aa4
commit 4107f7f1ba
1 changed files with 14 additions and 4 deletions

View File

@ -115,14 +115,24 @@ func (this *VoucherBiz) WarningBudget(ctx context.Context, product *bo.ProductBo
return fmt.Errorf("no warning budget") 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) wxResp, err := this.WechatCpnRepo.QueryProduct(ctx, product.MchId, product.BatchNo)
if err != nil { if err != nil {
return err return err
} }
if err = this.Calculate(ctx, product, wxResp); err != nil {
return err return this.Calculate(ctx, product, wxResp)
}
return nil
} }
func (this *VoucherBiz) Calculate(ctx context.Context, product *bo.ProductBo, wxResp *cashcoupons.Stock) error { func (this *VoucherBiz) Calculate(ctx context.Context, product *bo.ProductBo, wxResp *cashcoupons.Stock) error {