Преглед изворни кода

feat: membership_levels 添加原价列并幂等同步价格(migration 203)

Xiaogang Liao пре 1 месец
родитељ
комит
8c719d9615

+ 24 - 0
cfc-backend/src/main/java/com/etotem/cfc/config/DatabaseInitializer.java

@@ -8427,5 +8427,29 @@ private void runMigration100() {
 
 
 		// 迁移202: withdrawal_requests表添加 type 字段(提现来源)
 		// 迁移202: withdrawal_requests表添加 type 字段(提现来源)
 		ensureColumn("withdrawal_requests", "type", "VARCHAR(20) DEFAULT 'platform_points' COMMENT '提现来源: platform_points(CF值) / commission(历史佣金)'");
 		ensureColumn("withdrawal_requests", "type", "VARCHAR(20) DEFAULT 'platform_points' COMMENT '提现来源: platform_points(CF值) / commission(历史佣金)'");
+
+		// 迁移203: membership_levels 添加原价字段(LIFETIME 需求:价格来源统一迁移至表内)
+		ensureColumn("membership_levels", "original_price_monthly", "INT NULL COMMENT '原价-月费(分)'");
+		ensureColumn("membership_levels", "original_price_quarterly", "INT NULL COMMENT '原价-季费(分)'");
+		ensureColumn("membership_levels", "original_price_yearly", "INT NULL COMMENT '原价-年费(分)'");
+
+		// 迁移203.1: 幂等数据同步(sys_config 原价/现值 → membership_levels,仅当表内为 0/NULL 时)
+		try {
+			// FAMILY 原价年费(sys_config member_fee_family_original_yearly / member_fee_family_original,默认 199900)
+			jdbcTemplate.update("UPDATE membership_levels SET original_price_yearly = 199900 " +
+					"WHERE level_code = 'FAMILY' AND (original_price_yearly IS NULL OR original_price_yearly = 0)");
+			// PREMIUM 原价年费/月费(sys_config member_fee_premium_original / member_fee_premium_original_monthly)
+			jdbcTemplate.update("UPDATE membership_levels SET original_price_yearly = 1599900, original_price_monthly = 159900 " +
+					"WHERE level_code = 'PREMIUM' AND (original_price_yearly IS NULL OR original_price_yearly = 0)");
+			// FAMILY 现价补齐(现值 13140/32850/131400)
+			jdbcTemplate.update("UPDATE membership_levels SET price_monthly = 13140, price_quarterly = 32850, price_yearly = 131400 " +
+					"WHERE level_code = 'FAMILY' AND (price_yearly IS NULL OR price_yearly = 0)");
+			// PREMIUM 现价补齐(现值 131400/1316800;季费保持 NULL=不支持)
+			jdbcTemplate.update("UPDATE membership_levels SET price_monthly = 131400, price_yearly = 1316800 " +
+					"WHERE level_code = 'PREMIUM' AND (price_yearly IS NULL OR price_yearly = 0)");
+			log.info("已同步会员价格/原价至membership_levels");
+		} catch (Exception e) {
+			log.warn("同步membership_levels价格失败: {}", e.getMessage());
+		}
 	}
 	}
 }
 }

+ 3 - 0
cfc-backend/src/main/resources/schema.sql

@@ -3659,6 +3659,9 @@ CREATE TABLE IF NOT EXISTS membership_levels (
     price_monthly INT COMMENT '月费(分)',
     price_monthly INT COMMENT '月费(分)',
     price_quarterly INT COMMENT '季费(分)',
     price_quarterly INT COMMENT '季费(分)',
     price_yearly INT COMMENT '年费(分)',
     price_yearly INT COMMENT '年费(分)',
+    original_price_monthly INT COMMENT '原价-月费(分)',
+    original_price_quarterly INT COMMENT '原价-季费(分)',
+    original_price_yearly INT COMMENT '原价-年费(分)',
     features TEXT COMMENT '功能权限列表(JSON)',
     features TEXT COMMENT '功能权限列表(JSON)',
     max_children INT DEFAULT 0 COMMENT '可添加孩子数量',
     max_children INT DEFAULT 0 COMMENT '可添加孩子数量',
     max_tasks_per_day INT DEFAULT 0 COMMENT '每日任务上限',
     max_tasks_per_day INT DEFAULT 0 COMMENT '每日任务上限',