|
@@ -2983,6 +2983,12 @@ insertSysConfigSeed("gift_membership_pay_price", "198000", "送会员商品达
|
|
|
|
|
|
|
|
runSystemMigrations();
|
|
runSystemMigrations();
|
|
|
registerCollectExpectedIndicators();
|
|
registerCollectExpectedIndicators();
|
|
|
|
|
+
|
|
|
|
|
+ // 减脂专题表创建
|
|
|
|
|
+ createFatWeightRecordTable();
|
|
|
|
|
+ createFatDietRecordTable();
|
|
|
|
|
+ createFatExerciseRecordTable();
|
|
|
|
|
+ createFatGoalTable();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void migrateHealthDimensionsTable() {
|
|
private void migrateHealthDimensionsTable() {
|
|
@@ -10946,6 +10952,7 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
createTaskReminderConfigTable();
|
|
createTaskReminderConfigTable();
|
|
|
addMissingColumnsToRecommendationLog();
|
|
addMissingColumnsToRecommendationLog();
|
|
|
createDietFamilySelectedIngredientsTable();
|
|
createDietFamilySelectedIngredientsTable();
|
|
|
|
|
+ createSsoTicketTable();
|
|
|
|
|
|
|
|
// 迁移341: BASIC 体验会员 features JSON 补 referral_commission(迁移315 未包含,前端对比表已显示可参与)
|
|
// 迁移341: BASIC 体验会员 features JSON 补 referral_commission(迁移315 未包含,前端对比表已显示可参与)
|
|
|
try {
|
|
try {
|
|
@@ -11853,30 +11860,26 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 迁移354: 家庭共餐选中食材表(持久化共餐场景食材选择)
|
|
|
|
|
- private void createDietFamilySelectedIngredientsTable() {
|
|
|
|
|
|
|
+ // 迁移359: 跨小程序单点登录一次性票据表(cfc ↔ train 双向免登)
|
|
|
|
|
+ // 详见 schema.sql。此处自愈建表,避免 schema.sql 建表语句因故静默失败导致登录报错。
|
|
|
|
|
+ private void createSsoTicketTable() {
|
|
|
try {
|
|
try {
|
|
|
- jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS diet_family_selected_ingredients (" +
|
|
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS sso_ticket (" +
|
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID'," +
|
|
"id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID'," +
|
|
|
- "family_id BIGINT NOT NULL COMMENT '家庭ID'," +
|
|
|
|
|
- "food_id BIGINT NOT NULL COMMENT '食材ID'," +
|
|
|
|
|
- "food_name VARCHAR(100) COMMENT '食材名称'," +
|
|
|
|
|
- "score INT COMMENT '推荐分'," +
|
|
|
|
|
- "reason VARCHAR(255) COMMENT '推荐理由'," +
|
|
|
|
|
- "category VARCHAR(50) COMMENT '分类'," +
|
|
|
|
|
- "calories_per_100g INT COMMENT '每100克卡路里'," +
|
|
|
|
|
- "cooking_level TINYINT COMMENT '烹饪难度(1=快手,2=中等,3=耗时)'," +
|
|
|
|
|
- "nutrition_score INT COMMENT '营养密度分(0-100)'," +
|
|
|
|
|
- "balance_reason VARCHAR(255) COMMENT '均衡化推荐理由'," +
|
|
|
|
|
- "sort_order INT DEFAULT 0 COMMENT '排序'," +
|
|
|
|
|
|
|
+ "ticket VARCHAR(64) NOT NULL COMMENT '一次性票据(SecureRandom 生成)'," +
|
|
|
|
|
+ "source_system VARCHAR(16) NOT NULL COMMENT '签发方系统: cfc / train'," +
|
|
|
|
|
+ "target_system VARCHAR(16) NOT NULL COMMENT '目标系统: cfc / train'," +
|
|
|
|
|
+ "source_user_id BIGINT NOT NULL COMMENT '签发方用户ID(cfc=users.id / train=train_user.id)'," +
|
|
|
|
|
+ "cfc_user_id BIGINT NOT NULL COMMENT 'cfc 统一会员ID(users.id),跨系统换票依据'," +
|
|
|
|
|
+ "used TINYINT NOT NULL DEFAULT 0 COMMENT '是否已使用: 0=未用 1=已用'," +
|
|
|
|
|
+ "expire_at DATETIME NOT NULL COMMENT '过期时间'," +
|
|
|
"created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'," +
|
|
"created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'," +
|
|
|
- "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间'," +
|
|
|
|
|
- "UNIQUE KEY uk_family_food (family_id, food_id)," +
|
|
|
|
|
- "INDEX idx_family (family_id)" +
|
|
|
|
|
- ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='家庭共餐选中食材'");
|
|
|
|
|
- log.info("迁移354: 已创建 diet_family_selected_ingredients 表");
|
|
|
|
|
|
|
+ "UNIQUE KEY uk_ticket (ticket)," +
|
|
|
|
|
+ "INDEX idx_expire (expire_at)" +
|
|
|
|
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='跨小程序单点登录一次性票据'");
|
|
|
|
|
+ log.info("迁移359: 已创建 sso_ticket 表");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.warn("迁移354: 创建 diet_family_selected_ingredients 表失败: {}", e.getMessage());
|
|
|
|
|
|
|
+ log.warn("迁移359: 创建 sso_ticket 表失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -12049,7 +12052,7 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
return sb.append(']').toString();
|
|
return sb.append(']').toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 迁移354: 家庭共餐选中食材表(持久化共餐场景食材选择)
|
|
|
|
|
|
|
+ // 迁移359: 家庭共餐选中食材表(持久化共餐场景食材选择)
|
|
|
private void createDietFamilySelectedIngredientsTable() {
|
|
private void createDietFamilySelectedIngredientsTable() {
|
|
|
try {
|
|
try {
|
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS diet_family_selected_ingredients (" +
|
|
jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS diet_family_selected_ingredients (" +
|
|
@@ -12070,9 +12073,96 @@ log.info("迁移298: 已为无 openid 的 child 账号补齐 family_members 记
|
|
|
"UNIQUE KEY uk_family_food (family_id, food_id)," +
|
|
"UNIQUE KEY uk_family_food (family_id, food_id)," +
|
|
|
"INDEX idx_family (family_id)" +
|
|
"INDEX idx_family (family_id)" +
|
|
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='家庭共餐选中食材'");
|
|
") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='家庭共餐选中食材'");
|
|
|
- log.info("迁移354: 已创建 diet_family_selected_ingredients 表");
|
|
|
|
|
|
|
+ log.info("迁移359: 已创建 diet_family_selected_ingredients 表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("迁移359: 创建 diet_family_selected_ingredients 表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移355: 创建减脂专题体重记录表
|
|
|
|
|
+ private void createFatWeightRecordTable() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS fat_weight_record (" +
|
|
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
|
|
+ "member_id BIGINT NOT NULL, " +
|
|
|
|
|
+ "weight DECIMAL(5,2) NOT NULL, " +
|
|
|
|
|
+ "body_fat_percent DECIMAL(4,2) DEFAULT NULL, " +
|
|
|
|
|
+ "waist_circumference DECIMAL(4,2) DEFAULT NULL, " +
|
|
|
|
|
+ "measure_date DATE NOT NULL, " +
|
|
|
|
|
+ "remark VARCHAR(255) DEFAULT NULL, " +
|
|
|
|
|
+ "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "INDEX idx_fat_weight_member (member_id, measure_date)) " +
|
|
|
|
|
+ "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='减脂专题-体重体脂记录'");
|
|
|
|
|
+ log.info("迁移355: 已创建fat_weight_record表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("迁移355: 创建fat_weight_record表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移356: 创建减脂专题饮食记录表
|
|
|
|
|
+ private void createFatDietRecordTable() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS fat_diet_record (" +
|
|
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
|
|
+ "member_id BIGINT NOT NULL, " +
|
|
|
|
|
+ "meal_type VARCHAR(20) NOT NULL, " +
|
|
|
|
|
+ "food_name VARCHAR(255) NOT NULL, " +
|
|
|
|
|
+ "food_weight DECIMAL(6,2) DEFAULT NULL, " +
|
|
|
|
|
+ "calories INT DEFAULT 0, " +
|
|
|
|
|
+ "protein DECIMAL(6,2) DEFAULT 0, " +
|
|
|
|
|
+ "fat DECIMAL(6,2) DEFAULT 0, " +
|
|
|
|
|
+ "carbs DECIMAL(6,2) DEFAULT 0, " +
|
|
|
|
|
+ "eat_date DATE NOT NULL, " +
|
|
|
|
|
+ "remark VARCHAR(255) DEFAULT NULL, " +
|
|
|
|
|
+ "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "INDEX idx_fat_diet_member (member_id, eat_date)) " +
|
|
|
|
|
+ "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='减脂专题-饮食记录'");
|
|
|
|
|
+ log.info("迁移356: 已创建fat_diet_record表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("迁移356: 创建fat_diet_record表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移357: 创建减脂专题运动记录表
|
|
|
|
|
+ private void createFatExerciseRecordTable() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS fat_exercise_record (" +
|
|
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
|
|
+ "member_id BIGINT NOT NULL, " +
|
|
|
|
|
+ "exercise_type VARCHAR(50) NOT NULL, " +
|
|
|
|
|
+ "duration_min INT DEFAULT 0, " +
|
|
|
|
|
+ "distance_km DECIMAL(5,2) DEFAULT NULL, " +
|
|
|
|
|
+ "calories_burned INT DEFAULT 0, " +
|
|
|
|
|
+ "exercise_date DATE NOT NULL, " +
|
|
|
|
|
+ "remark VARCHAR(255) DEFAULT NULL, " +
|
|
|
|
|
+ "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "INDEX idx_fat_exercise_member (member_id, exercise_date)) " +
|
|
|
|
|
+ "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='减脂专题-运动记录'");
|
|
|
|
|
+ log.info("迁移357: 已创建fat_exercise_record表");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("迁移357: 创建fat_exercise_record表失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 迁移358: 创建减脂专题目标表
|
|
|
|
|
+ private void createFatGoalTable() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS fat_goal (" +
|
|
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
|
|
+ "member_id BIGINT NOT NULL, " +
|
|
|
|
|
+ "target_weight DECIMAL(5,2) NOT NULL, " +
|
|
|
|
|
+ "start_weight DECIMAL(5,2) NOT NULL, " +
|
|
|
|
|
+ "target_body_fat DECIMAL(4,2) DEFAULT NULL, " +
|
|
|
|
|
+ "target_date DATE DEFAULT NULL, " +
|
|
|
|
|
+ "status VARCHAR(20) DEFAULT 'active', " +
|
|
|
|
|
+ "start_date DATE NOT NULL, " +
|
|
|
|
|
+ "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, " +
|
|
|
|
|
+ "INDEX idx_fat_goal_member (member_id)) " +
|
|
|
|
|
+ "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='减脂专题-减脂目标'");
|
|
|
|
|
+ log.info("迁移358: 已创建fat_goal表");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- log.warn("迁移354: 创建 diet_family_selected_ingredients 表失败: {}", e.getMessage());
|
|
|
|
|
|
|
+ log.warn("迁移358: 创建fat_goal表失败: {}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|