|
|
@@ -5215,6 +5215,70 @@ try {
|
|
|
}
|
|
|
|
|
|
runMigration80();
|
|
|
+ runMigration81();
|
|
|
+ }
|
|
|
|
|
|
+ private void runMigration81() {
|
|
|
+ // 迁移 81: 创建 product_dimension_mapping 表(商品维度关联)
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS product_dimension_mapping (" +
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
+ "product_id BIGINT NOT NULL COMMENT '商品 ID', " +
|
|
|
+ "dimension_code VARCHAR(32) NOT NULL COMMENT '维度:body/wisdom/mind/action/wealth', " +
|
|
|
+ "match_score INT DEFAULT 100 COMMENT '匹配度 0-100', " +
|
|
|
+ "match_reason VARCHAR(200) COMMENT '匹配原因', " +
|
|
|
+ "tags VARCHAR(500) COMMENT '推荐标签 JSON', " +
|
|
|
+ "enabled TINYINT DEFAULT 1, " +
|
|
|
+ "created_at DATETIME, " +
|
|
|
+ "updated_at DATETIME, " +
|
|
|
+ "INDEX idx_product (product_id), " +
|
|
|
+ "INDEX idx_dimension (dimension_code) " +
|
|
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品维度关联表'");
|
|
|
+ log.info("已创建 product_dimension_mapping 表");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("创建 product_dimension_mapping 表失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 迁移 81: products 表添加 recommendation_tags 字段
|
|
|
+ ensureColumn("products", "recommendation_tags", "VARCHAR(500) COMMENT '推荐标签 JSON' AFTER domain");
|
|
|
+ // 迁移 81: products 表添加 purchase_count_threshold 字段
|
|
|
+ ensureColumn("products", "purchase_count_threshold", "INT DEFAULT 0");
|
|
|
+ // 迁移 81: products 表添加 repurchase_interval_days 字段
|
|
|
+ ensureColumn("products", "repurchase_interval_days", "INT DEFAULT 30");
|
|
|
+
|
|
|
+ // 迁移 82: 创建 repurchase_reminder_record 表(复购提醒记录)
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS repurchase_reminder_record (" +
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
+ "user_id BIGINT NOT NULL, " +
|
|
|
+ "product_id BIGINT NOT NULL, " +
|
|
|
+ "order_id BIGINT COMMENT '关联订单 ID', " +
|
|
|
+ "reminder_days INT DEFAULT 30, " +
|
|
|
+ "sent_at DATETIME, " +
|
|
|
+ "clicked TINYINT DEFAULT 0, " +
|
|
|
+ "purchased TINYINT DEFAULT 0, " +
|
|
|
+ "INDEX idx_user_pending (user_id, purchased) " +
|
|
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='复购提醒发送记录'");
|
|
|
+ log.info("已创建 repurchase_reminder_record 表");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("创建 repurchase_reminder_record 表失败:{}", e.getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ // 迁移 83: 创建 repurchase_reminder_config 表(复购提醒配置)
|
|
|
+ try {
|
|
|
+ jdbcTemplate.execute("CREATE TABLE IF NOT EXISTS repurchase_reminder_config (" +
|
|
|
+ "id BIGINT AUTO_INCREMENT PRIMARY KEY, " +
|
|
|
+ "product_category VARCHAR(100), " +
|
|
|
+ "product_id BIGINT COMMENT '特定商品 ID(优先于 category)', " +
|
|
|
+ "reminder_days INT DEFAULT 30, " +
|
|
|
+ "reminder_template VARCHAR(500) COMMENT '提醒话术模板', " +
|
|
|
+ "max_reminders INT DEFAULT 3, " +
|
|
|
+ "enabled TINYINT DEFAULT 1, " +
|
|
|
+ "created_at DATETIME " +
|
|
|
+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='复购提醒配置表'");
|
|
|
+ log.info("已创建 repurchase_reminder_config 表");
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("创建 repurchase_reminder_config 表失败:{}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|