feat: MBTI头像与用户规则链路升级,三端页面与接口同步
Made-with: Cursor
This commit is contained in:
38
soul-api/scripts/add-persons-pin-and-source.sql
Normal file
38
soul-api/scripts/add-persons-pin-and-source.sql
Normal file
@@ -0,0 +1,38 @@
|
||||
-- persons 表:补齐首页置顶与来源字段(兼容低版本 MySQL 的幂等写法)
|
||||
SET @db = DATABASE();
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'persons' AND COLUMN_NAME = 'is_pinned'
|
||||
),
|
||||
'SELECT 1',
|
||||
"ALTER TABLE persons ADD COLUMN is_pinned TINYINT(1) NOT NULL DEFAULT 0 COMMENT '置顶到小程序首页'"
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'persons' AND COLUMN_NAME = 'person_source'
|
||||
),
|
||||
'SELECT 1',
|
||||
"ALTER TABLE persons ADD COLUMN person_source VARCHAR(32) NOT NULL DEFAULT '' COMMENT '来源:空=后台手工;vip_sync=超级个体同步'"
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @sql = (
|
||||
SELECT IF(
|
||||
EXISTS(
|
||||
SELECT 1 FROM information_schema.STATISTICS
|
||||
WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'persons' AND INDEX_NAME = 'idx_persons_is_pinned'
|
||||
),
|
||||
'SELECT 1',
|
||||
'CREATE INDEX idx_persons_is_pinned ON persons(is_pinned)'
|
||||
)
|
||||
);
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
42
soul-api/scripts/migrate-user-rules-v2.sql
Normal file
42
soul-api/scripts/migrate-user-rules-v2.sql
Normal file
@@ -0,0 +1,42 @@
|
||||
-- 用户规则表 v2:新增结构化触发条件和推送动作列(GORM AutoMigrate 会自动加列,此脚本用于填充现有规则的结构化数据)
|
||||
|
||||
ALTER TABLE user_rules ADD COLUMN IF NOT EXISTS trigger_conditions JSON DEFAULT NULL;
|
||||
ALTER TABLE user_rules ADD COLUMN IF NOT EXISTS action_type VARCHAR(50) DEFAULT 'popup';
|
||||
ALTER TABLE user_rules ADD COLUMN IF NOT EXISTS action_config JSON DEFAULT NULL;
|
||||
|
||||
-- 根据现有 trigger 字段回填结构化条件(最佳实践预设)
|
||||
-- #10: 注册完成 → 填写头像
|
||||
UPDATE user_rules SET trigger_conditions = '["after_login","fill_profile"]', action_type = 'popup'
|
||||
WHERE sort = 10 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #20: 完成匹配 → 补充个人资料
|
||||
UPDATE user_rules SET trigger_conditions = '["after_match","fill_profile"]', action_type = 'popup'
|
||||
WHERE sort = 20 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #30: 首次浏览章节 → 绑定手机号
|
||||
UPDATE user_rules SET trigger_conditions = '["view_chapter","bind_phone"]', action_type = 'popup'
|
||||
WHERE sort = 30 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #40: 付款 ¥1980 → 填写完整信息
|
||||
UPDATE user_rules SET trigger_conditions = '["purchase_fullbook","fill_profile","add_wechat"]', action_type = 'popup'
|
||||
WHERE sort = 40 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #50: 加入派对房 → 填写项目介绍
|
||||
UPDATE user_rules SET trigger_conditions = '["after_match"]', action_type = 'navigate'
|
||||
WHERE sort = 50 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #60: 浏览 5 个章节 → 分享推广
|
||||
UPDATE user_rules SET trigger_conditions = '["browse_5_chapters","share_action"]', action_type = 'popup'
|
||||
WHERE sort = 60 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #70: 绑定微信 → 开启分销
|
||||
UPDATE user_rules SET trigger_conditions = '["add_wechat","referral_bind"]', action_type = 'navigate'
|
||||
WHERE sort = 70 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #80: 收益达到
|
||||
UPDATE user_rules SET trigger_conditions = '["withdraw_request"]', action_type = 'popup'
|
||||
WHERE sort = 80 AND trigger_conditions IS NULL;
|
||||
|
||||
-- #90: 完善信息 → 进入流量池
|
||||
UPDATE user_rules SET trigger_conditions = '["fill_profile","add_wechat","bind_phone"]', action_type = 'popup'
|
||||
WHERE sort = 90 AND trigger_conditions IS NULL;
|
||||
Reference in New Issue
Block a user