@@ -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
|
||||
|
||||
Reference in New Issue
Block a user