hyapp-server/server/admin/migrations/115_fami_agency_host_income_share.sql

49 lines
2.1 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
SET @now_ms = CAST(UNIX_TIMESTAMP(UTC_TIMESTAMP(3)) * 1000 AS UNSIGNED);
-- 088 已执行的环境不会重放历史迁移;只覆盖 Fami v1 的四个确定业务字段,保留运营后续补充的提现、任务等规则。
UPDATE admin_policy_templates
SET rule_json = JSON_SET(
JSON_SET(
rule_json,
'$.host', COALESCE(JSON_EXTRACT(rule_json, '$.host'), JSON_OBJECT()),
'$.agency', COALESCE(JSON_EXTRACT(rule_json, '$.agency'), JSON_OBJECT())
),
'$.host.point_ratio_percent', 100,
'$.host.use_gift_type_ratio', JSON_EXTRACT('true', '$'),
'$.agency.point_ratio_percent', 20,
'$.agency.share_base', 'host_income'
),
description = 'Fami 主播 POINT 收益政策Agency 按主播实际 POINT 收益由平台额外发放 20%,以发布后的运行快照为准。',
updated_at_ms = @now_ms
WHERE template_code = 'fami_guild_revenue_policy'
AND template_version = 'v1';
-- 版本表是发布读取源,必须与模板当前版本同时升级,避免列表展示和实际发布使用不同规则。
UPDATE admin_policy_template_versions
SET rule_json = JSON_SET(
JSON_SET(
rule_json,
'$.host', COALESCE(JSON_EXTRACT(rule_json, '$.host'), JSON_OBJECT()),
'$.agency', COALESCE(JSON_EXTRACT(rule_json, '$.agency'), JSON_OBJECT())
),
'$.host.point_ratio_percent', 100,
'$.host.use_gift_type_ratio', JSON_EXTRACT('true', '$'),
'$.agency.point_ratio_percent', 20,
'$.agency.share_base', 'host_income'
),
updated_at_ms = @now_ms
WHERE template_code = 'fami_guild_revenue_policy'
AND template_version = 'v1';
-- 模板版本被原地修正后,所有引用它的 Fami 实例都必须退回待发布状态;不能只处理默认 instance_code
-- 否则区域/备用实例会显示 published却继续运行旧快照。wallet 运行侧仍只由显式发布流程写入。
UPDATE admin_policy_instances
SET publish_status = 'draft',
publish_error = '',
updated_at_ms = @now_ms
WHERE app_code = 'fami'
AND template_code = 'fami_guild_revenue_policy'
AND template_version = 'v1';