This commit is contained in:
ziming 2025-07-01 17:53:15 +08:00
parent 2b02cf7bf6
commit 819f92484d
3 changed files with 8 additions and 5 deletions

View File

@ -30,7 +30,7 @@ const (
) )
var ( var (
WarningBudgetSendIncr CacheKey = "warning_budget_send_incr" WarningBudgetSendIncr CacheKey = "warning_budget_incr"
) )
var CacheKeyMap = map[CacheKey]time.Duration{ var CacheKeyMap = map[CacheKey]time.Duration{
@ -48,7 +48,7 @@ var CacheKeyMap = map[CacheKey]time.Duration{
ProductQueryKey: 30 * 86400 * time.Second, // 30天 ProductQueryKey: 30 * 86400 * time.Second, // 30天
ProductQueryLockKey: 30 * time.Second, ProductQueryLockKey: 30 * time.Second,
WarningBudgetSendIncr: 1 * time.Hour, WarningBudgetSendIncr: 2 * time.Hour,
} }
type Cache struct { type Cache struct {

View File

@ -30,7 +30,7 @@ func (s *VoucherBiz) WarningBudgetIncr(ctx context.Context, uid string) (int64,
} }
// 如果发送次数超过 “指定” 条,清除再来 // 如果发送次数超过 “指定” 条,清除再来
if count > 12 { if count > 24 { // 大约2小时
return 0, s.WarningBudgetIncrDel(ctx, v.Key) return 0, s.WarningBudgetIncrDel(ctx, v.Key)
} }
@ -122,7 +122,10 @@ func (v *VoucherBiz) Calculate(ctx context.Context, product *bo.ProductBo, wxRes
} }
if w.AllBudget > product.AllBudget { if w.AllBudget > product.AllBudget {
cv := vo.WarningBudgetSendIncr.BuildCache([]string{product.BatchNo})
if err := v.WarningBudgetIncrDel(ctx, cv.Key); err != nil {
return err
}
} }
} }

View File

@ -68,7 +68,7 @@ func TestWarningSend(t *testing.T) {
return return
} }
err = smsService.SendSMS(context.Background(), []string{"18666173766"}, "SMS_489705720", params) err = smsService.SendSMS(context.Background(), []string{"18666173766"}, "SMS_489660721", params)
if err != nil { if err != nil {
t.Errorf("发送短信失败: %v", err) t.Errorf("发送短信失败: %v", err)
return return