Răsfoiți Sursa

fix(backend): 档位种子对齐迁移431新档位 + 清理旧档残留

迁移418 seedCfSalesTiers 每次启动按缺行才补插入旧档种子(青铜100/白银500/黄金2000/铂金5000/钻石10000),
而迁移431 已将 min 改为 10000/50000/200000/500000/1000000,导致旧档(如5000,55%)被重新插入为6-9行,
与1-5新档(新秀/小成/...至富)并存。CfReferralService 按 min DESC 匹配时,旧档抢在新档前,
如 P点=7000 命中旧铂金(5000,55%)而非新秀(10000,10%),销售奖费率超标。

- CF_DIRECT/INDIRECT_SALES_TIER_SEEDS 更新为新档(新秀10000/小成50000/中富200000/大成500000/至富1000000)
- seedCfSalesTiers 前置清理:删除 min 不在新档阈值集合内的旧档行(幂等)
Xiaogang Liao 1 săptămână în urmă
părinte
comite
9bde4e366a

+ 27 - 10
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -14284,11 +14284,11 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
      * 列序:tier_name, min_annual_ppoints, rate_percent, sort_order, remark
      */
     private static final String[][] CF_DIRECT_SALES_TIER_SEEDS = {
-            {"青铜", "100", "10", "1", "团队8层内年度P点≥100,直接销售奖10%"},
-            {"白银", "500", "25", "2", "团队8层内年度P点≥500,直接销售奖25%"},
-            {"黄金", "2000", "40", "3", "团队8层内年度P点≥2000,直接销售奖40%"},
-            {"铂金", "5000", "55", "4", "团队8层内年度P点≥5000,直接销售奖55%"},
-            {"钻石", "10000", "70", "5", "团队8层内年度P点≥10000,直接销售奖70%"}
+            {"新秀", "10000", "10", "1", "团队8层内年度P点≥10000,直接销售奖10%"},
+            {"小成", "50000", "25", "2", "团队8层内年度P点≥50000,直接销售奖25%"},
+            {"中富", "200000", "40", "3", "团队8层内年度P点≥200000,直接销售奖40%"},
+            {"大成", "500000", "55", "4", "团队8层内年度P点≥500000,直接销售奖55%"},
+            {"至富", "1000000", "70", "5", "团队8层内年度P点≥1000000,直接销售奖70%"}
     };
 
     /**
@@ -14296,16 +14296,33 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
      * 列序:tier_name, min_self_ppoints, rate_percent, sort_order, remark
      */
     private static final String[][] CF_INDIRECT_SALES_TIER_SEEDS = {
-            {"青铜", "100", "2", "1", "自身年度消费P点≥100,间接销售奖2%"},
-            {"白银", "500", "5", "2", "自身年度消费P点≥500,间接销售奖5%"},
-            {"黄金", "2000", "10", "3", "自身年度消费P点≥2000,间接销售奖10%"},
-            {"铂金", "5000", "15", "4", "自身年度消费P点≥5000,间接销售奖15%"},
-            {"钻石", "10000", "20", "5", "自身年度消费P点≥10000,间接销售奖20%"}
+            {"新秀", "10000", "2", "1", "自身年度消费P点≥10000,间接销售奖2%"},
+            {"小成", "50000", "5", "2", "自身年度消费P点≥50000,间接销售奖5%"},
+            {"中富", "200000", "10", "3", "自身年度消费P点≥200000,间接销售奖10%"},
+            {"大成", "500000", "15", "4", "自身年度消费P点≥500000,间接销售奖15%"},
+            {"至富", "1000000", "20", "5", "自身年度消费P点≥1000000,间接销售奖20%"}
     };
 
     // 迁移418: 两级销售奖档位种子(幂等:min 下限唯一键已存在则跳过,不覆盖运营改过的档位)
     // 迁移418(F-4):缺行才补的档位种子,包内可见以便单测直接调用
     void seedCfSalesTiers() {
+        // 迁移431(×100) 后清理旧档残留:旧种子青铜(100)/白银(500)/黄金(2000)/铂金(5000)/钻石(10000)
+        // 的 min 阈值与迁移431 新档位(10000/50000/...)不同,缺行才补逻辑会在每次重启重新插入旧档,
+        // 导致新旧档并存、按 min DESC 匹配时旧档(如5000,55%)抢在新秀(10000,10%)前。
+        // 此处删除不在新档阈值集合内的旧档行(幂等,不影响已改名为新秀/小成/...的 1-5 行)。
+        try {
+            int cleaned = jdbcTemplate.update(
+                    "DELETE FROM cf_direct_sales_tier "
+                            + "WHERE min_annual_ppoints NOT IN (10000, 50000, 200000, 500000, 1000000)");
+            int cleaned2 = jdbcTemplate.update(
+                    "DELETE FROM cf_indirect_sales_tier "
+                            + "WHERE min_self_ppoints NOT IN (10000, 50000, 200000, 500000, 1000000)");
+            if (cleaned > 0 || cleaned2 > 0) {
+                log.info("迁移418: 清理旧档位残留 {} 行(直接)/{} 行(间接)", cleaned, cleaned2);
+            }
+        } catch (Exception e) {
+            log.warn("迁移418: 清理旧档位残留失败(幂等容忍): {}", e.getMessage());
+        }
         int inserted = 0;
         for (String[] t : CF_DIRECT_SALES_TIER_SEEDS) {
             try {