修复(#128): 统一促销价格资格口径
Build docker and publish / build (20.15.1) (push) Failing after 18m40s
Build docker and publish / build (20.15.1) (pull_request) Failing after 19m24s

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-29 22:42:04 -07:00
parent e5d6539d79
commit 3644e9ce3f
5 changed files with 263 additions and 235 deletions
+7 -1
View File
@@ -30,7 +30,7 @@ type promoRuleParams struct {
func EvaluatePromo(ctx context.Context, svcCtx *svc.ServiceContext, userID int64, subscribeID int64, quantity int64) (*PromoResult, error) {
result := &PromoResult{}
if svcCtx == nil || svcCtx.PromoModel == nil || svcCtx.DB == nil || userID <= 0 || subscribeID <= 0 || quantity <= 0 {
if svcCtx == nil || svcCtx.PromoModel == nil || svcCtx.DB == nil || subscribeID <= 0 || quantity <= 0 {
return result, nil
}
@@ -101,8 +101,14 @@ func evaluatePromoRule(
) (bool, time.Time, error) {
switch rule.Type {
case promo.RuleTypeNewUser:
if userID <= 0 {
return false, time.Time{}, nil
}
return evaluateNewUserPromo(ctx, db, params, userID, currentUser, now)
case promo.RuleTypeInactiveUser:
if userID <= 0 {
return false, time.Time{}, nil
}
return evaluateInactiveUserPromo(ctx, db, params, userID, promoRuleExpiresAt(rule), now)
case promo.RuleTypeCampaign:
return true, promoRuleExpiresAt(rule), nil