修复(#85): 促销系统 quantity 设计修正补丁(跨任务统一修复)
- subscribe_promo 表加 quantity 字段,BIGINT NOT NULL DEFAULT 1 - EvaluatePromo 加 quantity 参数,按 subscribeID + quantity 精确匹配 - Promo 从 Subscribe 顶层移到 SubscribeDiscount - 查询加 quantity,返回 map[subscribeID][quantity] 二级映射 - recordPromoUsage 错误向上传播,不再静默吞掉 - preCreate 和 purchase 的 allowPromo 判定统一为 orderType==1 - 迁移脚本增加幂等处理(guarded DROP/ADD/MODIFY) Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -57,6 +57,12 @@ func loadSubscribePromoMap(ctx context.Context, svcCtx *svc.ServiceContext, subs
|
||||
evaluator := promoEligibilityEvaluator{ctx: ctx, db: svcCtx.DB, userInfo: userInfo}
|
||||
now := time.Now()
|
||||
for _, candidate := range candidates {
|
||||
if candidate.Quantity <= 0 {
|
||||
continue
|
||||
}
|
||||
if result[candidate.SubscribeId] == nil {
|
||||
result[candidate.SubscribeId] = make(map[int64]*types.SubscribePromo)
|
||||
}
|
||||
if _, exists := result[candidate.SubscribeId][candidate.Quantity]; exists {
|
||||
continue
|
||||
}
|
||||
@@ -70,9 +76,6 @@ func loadSubscribePromoMap(ctx context.Context, svcCtx *svc.ServiceContext, subs
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if _, exists := result[candidate.SubscribeId]; !exists {
|
||||
result[candidate.SubscribeId] = make(map[int64]*types.SubscribePromo)
|
||||
}
|
||||
result[candidate.SubscribeId][candidate.Quantity] = &types.SubscribePromo{
|
||||
RuleName: candidate.RuleName,
|
||||
RuleType: candidate.RuleType,
|
||||
|
||||
Reference in New Issue
Block a user