|
|
@@ -3631,6 +3631,11 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
|
|
|
|
|
|
// 迁移484: users / product_orders / package_orders 加 appid 列 + users 唯一索引(OID 防串号)
|
|
|
migrateMultiAppDataDimensions();
|
|
|
+
|
|
|
+ // 迁移488: CF 分润模型 v2(T01,cf.rewardv2.migrateConfig)——
|
|
|
+ // 新建 4 表(cf_team_share_config/cf_team_pool_order/cf_team_pool_share/cf_platform_revenue_log)
|
|
|
+ // + ensureServiceConfig 播种 6 键 + F03c 种子(seedCfEarnRules / seedCfServiceConfig 内已含)
|
|
|
+ migrateCfRewardV2TeamPool();
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -4014,6 +4019,105 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 迁移488: CF 分润模型 v2 团队池配置与迁移(T01,能力键 cf.rewardv2.migrateConfig)。
|
|
|
+ *
|
|
|
+ * <p>设计契约:docs/superpowers/plans/2026-11-14-cf-reward-model-v2-design.md
|
|
|
+ * §2.1-2.4(新 4 表) / §2.5(迁移方式) / §3.3(F03c 种子) / §4(6 配置键)。</p>
|
|
|
+ *
|
|
|
+ * <ul>
|
|
|
+ * <li>{@code cf_team_share_config}:T% 配置,作用域 GLOBAL/SYSTEM/MINIAPP,唯一键 {@code uk_scope};</li>
|
|
|
+ * <li>{@code cf_team_pool_order}:团队池整单,唯一键 {@code uk_order(order_type, order_id)} 幂等;</li>
|
|
|
+ * <li>{@code cf_team_pool_share}:成员瓜分明细,唯一键 {@code uk_pool_member(pool_id, member_id)} 幂等;</li>
|
|
|
+ * <li>{@code cf_platform_revenue_log}:平台抽成 R0 流水,唯一键 {@code uk_order} 幂等。</li>
|
|
|
+ * </ul>
|
|
|
+ *
|
|
|
+ * <p>幂等:{@code CREATE TABLE IF NOT EXISTS}(迁移铁律,可重复执行)。
|
|
|
+ * 6 个配置键已由 {@link #seedCfServiceConfig()} 播种(幂等 ensureServiceConfig);
|
|
|
+ * F03c 团队分润池规则种子已由 {@link #seedCfEarnRules()} 播入(CF_EARN_RULE_SEEDS)。</p>
|
|
|
+ */
|
|
|
+ private void migrateCfRewardV2TeamPool() {
|
|
|
+ // cf_team_share_config:T% 配置,作用域 GLOBAL/SYSTEM/MINIAPP,uk_scope 幂等
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS cf_team_share_config ("
|
|
|
+ + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
|
|
|
+ + "owner_type VARCHAR(16) NOT NULL COMMENT '作用域: GLOBAL/SYSTEM/MINIAPP', "
|
|
|
+ + "owner_id VARCHAR(64) COMMENT 'SYSTEM=distribution_systems.id / MINIAPP=miniapp_config.mp_code / GLOBAL=NULL', "
|
|
|
+ + "t_bps INT NOT NULL COMMENT '团队池比例(bps, 如3000=30%)', "
|
|
|
+ + "enabled TINYINT NOT NULL DEFAULT 1, "
|
|
|
+ + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, "
|
|
|
+ + "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "
|
|
|
+ + "UNIQUE KEY uk_scope (owner_type, owner_id), "
|
|
|
+ + "KEY idx_enabled (enabled)"
|
|
|
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队分润池比例配置(作用域GLOBAL/SYSTEM/MINIAPP)'");
|
|
|
+ log.info("迁移488: cf_team_share_config 表已就绪");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移488: cf_team_share_config 创建失败(可能已存在): {}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // cf_team_pool_order:团队池整单,uk_order(order_type, order_id) 幂等
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS cf_team_pool_order ("
|
|
|
+ + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
|
|
|
+ + "order_id BIGINT NOT NULL COMMENT '来源订单ID', "
|
|
|
+ + "order_type VARCHAR(32) NOT NULL, "
|
|
|
+ + "product_id BIGINT NULL, "
|
|
|
+ + "buyer_user_id BIGINT NOT NULL, "
|
|
|
+ + "pool_cent INT NOT NULL DEFAULT 0 COMMENT '团队池金额(分)', "
|
|
|
+ + "t_bps INT NOT NULL COMMENT '实际采用T(bps)', "
|
|
|
+ + "config_scope VARCHAR(16) COMMENT '命中作用域 GLOBAL/SYSTEM/MINIAPP', "
|
|
|
+ + "status VARCHAR(16) NOT NULL DEFAULT 'pooled' COMMENT 'pooled=已建池/share_issued=已瓜分/unclaimed=无成员可瓜分', "
|
|
|
+ + "remark VARCHAR(255), "
|
|
|
+ + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, "
|
|
|
+ + "settled_at DATETIME NULL, "
|
|
|
+ + "UNIQUE KEY uk_order (order_type, order_id), "
|
|
|
+ + "KEY idx_status (status)"
|
|
|
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队分润池整单(成本×T%)'");
|
|
|
+ log.info("迁移488: cf_team_pool_order 表已就绪");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移488: cf_team_pool_order 创建失败(可能已存在): {}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // cf_team_pool_share:团队池成员瓜分明细,uk_pool_member(pool_id, member_id) 幂等
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS cf_team_pool_share ("
|
|
|
+ + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
|
|
|
+ + "pool_id BIGINT NOT NULL COMMENT 'cf_team_pool_order.id', "
|
|
|
+ + "member_id BIGINT NOT NULL COMMENT 'family_members.id', "
|
|
|
+ + "user_id BIGINT NOT NULL COMMENT 'users.id(推荐链成员)', "
|
|
|
+ + "layer INT NOT NULL COMMENT '推荐层级1..8(买家上溯)', "
|
|
|
+ + "rate_percent INT NOT NULL COMMENT '该成员直推档位率(%)', "
|
|
|
+ + "weight INT NOT NULL DEFAULT 0 COMMENT '档位权重(=rate_percent, 0=无档位跳过)', "
|
|
|
+ + "share_cent INT NOT NULL COMMENT '分得金额(分)', "
|
|
|
+ + "status VARCHAR(16) NOT NULL DEFAULT 'issued', "
|
|
|
+ + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, "
|
|
|
+ + "UNIQUE KEY uk_pool_member (pool_id, member_id), "
|
|
|
+ + "KEY idx_user (user_id)"
|
|
|
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团队池成员瓜分明细'");
|
|
|
+ log.info("迁移488: cf_team_pool_share 表已就绪");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移488: cf_team_pool_share 创建失败(可能已存在): {}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // cf_platform_revenue_log:平台抽成 R0 流水,uk_order(order_type, order_id) 幂等
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS cf_platform_revenue_log ("
|
|
|
+ + "id BIGINT AUTO_INCREMENT PRIMARY KEY, "
|
|
|
+ + "order_id BIGINT NOT NULL, "
|
|
|
+ + "order_type VARCHAR(32) NOT NULL, "
|
|
|
+ + "amount_cent INT NOT NULL COMMENT '平台抽成(分)=实付×10%', "
|
|
|
+ + "take_bps INT NOT NULL DEFAULT 1000, "
|
|
|
+ + "remark VARCHAR(255), "
|
|
|
+ + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, "
|
|
|
+ + "UNIQUE KEY uk_order (order_type, order_id), "
|
|
|
+ + "KEY idx_created (created_at)"
|
|
|
+ + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='平台抽成R0流水(独立入平台账)'");
|
|
|
+ log.info("迁移488: cf_platform_revenue_log 表已就绪");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("迁移488: cf_platform_revenue_log 创建失败(可能已存在): {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 迁移464: 创建 P3 跨案例聚合承载表(T15 跨案例聚合,S-cfc-119 guhe.p3.lowSideAggregate)。
|
|
|
*
|
|
|
@@ -14686,6 +14790,11 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
"{\"base\":\"self_annual_ppoints\",\"tier_table\":\"cf_indirect_sales_tier\",\"window\":\"1y_rolling\",\"max_rate_percent\":20,\"downgrade\":true}",
|
|
|
"", "", "", "F03b", "30",
|
|
|
"基数=间接推荐人消费P点;档位按自身年度累计消费P点(cf_indirect_sales_tier);幂等ref_type与规则编码一致(F-4)"},
|
|
|
+ {"F03c", "团队分润池(成本×T%池内瓜分)", "consume", "per_item", "",
|
|
|
+ "",
|
|
|
+ "{\"source\":\"cf_team_pool_share.share_cent\",\"note\":\"amount=每人分得CF,按池金额1分=1CF\"}",
|
|
|
+ "", "", "", "F03c", "25",
|
|
|
+ "团队池=成本×T%,按referral_tree层级树+直推档位权重瓜分;幂等ref_type=F03c,ref_id=pool_id"},
|
|
|
{"F04", "商品赠品CF", "consume", "per_item", "",
|
|
|
"",
|
|
|
"{\"source\":\"product_order_gift.cf_value\"}",
|
|
|
@@ -14986,6 +15095,21 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
"产品平台积分分成比例(bps);原散落 sys_config.product_platform_points_share", 1);
|
|
|
ensureServiceConfig("cf.version", "1", "int",
|
|
|
"CF 配置版本号(单调递增,前端据此局部刷新提示)", 0);
|
|
|
+
|
|
|
+ // 迁移488: CF 分润模型 v2(T01,cf.rewardv2.migrateConfig)——
|
|
|
+ // §4 六个配置键进 seedCfServiceConfig(幂等;与 CfConfigKeys.FALLBACKS 同口径)
|
|
|
+ ensureServiceConfig("cf.platform.take_rate_bps", "1000", "int",
|
|
|
+ "R0 平台抽成(成交价 10%,基数=实付;bps)", 1);
|
|
|
+ ensureServiceConfig("cf.team_pool.enabled", "true", "bool",
|
|
|
+ "团队池总开关", 1);
|
|
|
+ ensureServiceConfig("cf.team_pool.default_t_bps", "3000", "int",
|
|
|
+ "GLOBAL 兜底 T(30%,bps)", 1);
|
|
|
+ ensureServiceConfig("cf.team_pool.on_loss", "payout", "string",
|
|
|
+ "亏损仓照常发(2026-11-14 裁决;可选 zero)", 1);
|
|
|
+ ensureServiceConfig("cf.team_pool.max_depth", "8", "int",
|
|
|
+ "池瓜分最大层级(默认 8)", 1);
|
|
|
+ ensureServiceConfig("cf.team_pool.non_goods_cost_rate", "5000", "int",
|
|
|
+ "非商品成本率(bps,默认50%),用于非商品订单进池(2026-11-14 裁决)", 1);
|
|
|
}
|
|
|
|
|
|
/**
|