-- ============================================
-- 更新订阅套餐价格配置
-- 用途：为 subscription_plans 表添加季付、半年付价格
-- 日期：2025-11-19
-- ============================================

-- 更新 Pro 专业版的 pricing_options
UPDATE subscription_plans
SET pricing_options = JSON_ARRAY(
    JSON_OBJECT(
        'months', 1,
        'price', 299.00,
        'label', '月付',
        'cycle_key', 'monthly',
        'discount_percent', 0
    ),
    JSON_OBJECT(
        'months', 3,
        'price', 799.00,
        'label', '季付',
        'cycle_key', 'quarterly',
        'discount_percent', 11,
        'original_price', 897.00
    ),
    JSON_OBJECT(
        'months', 6,
        'price', 1499.00,
        'label', '半年付',
        'cycle_key', 'semiannual',
        'discount_percent', 16,
        'original_price', 1794.00
    ),
    JSON_OBJECT(
        'months', 12,
        'price', 2699.00,
        'label', '年付',
        'cycle_key', 'yearly',
        'discount_percent', 25,
        'original_price', 3588.00
    )
)
WHERE name = 'pro';

-- 更新 Max 旗舰版的 pricing_options
UPDATE subscription_plans
SET pricing_options = JSON_ARRAY(
    JSON_OBJECT(
        'months', 1,
        'price', 599.00,
        'label', '月付',
        'cycle_key', 'monthly',
        'discount_percent', 0
    ),
    JSON_OBJECT(
        'months', 3,
        'price', 1599.00,
        'label', '季付',
        'cycle_key', 'quarterly',
        'discount_percent', 11,
        'original_price', 1797.00
    ),
    JSON_OBJECT(
        'months', 6,
        'price', 2999.00,
        'label', '半年付',
        'cycle_key', 'semiannual',
        'discount_percent', 17,
        'original_price', 3594.00
    ),
    JSON_OBJECT(
        'months', 12,
        'price', 5399.00,
        'label', '年付',
        'cycle_key', 'yearly',
        'discount_percent', 25,
        'original_price', 7188.00
    )
)
WHERE name = 'max';

-- 验证更新结果
SELECT
    name AS '套餐',
    display_name AS '显示名称',
    pricing_options AS '价格配置'
FROM subscription_plans
WHERE name IN ('pro', 'max');

-- 完成提示
SELECT '价格配置已更新！' AS '状态';
SELECT '新价格：' AS '';
SELECT '  Pro 月付: ¥299' AS '';
SELECT '  Pro 季付: ¥799 (省11%)' AS '';
SELECT '  Pro 半年付: ¥1499 (省16%)' AS '';
SELECT '  Pro 年付: ¥2699 (省25%)' AS '';
SELECT '' AS '';
SELECT '  Max 月付: ¥599' AS '';
SELECT '  Max 季付: ¥1599 (省11%)' AS '';
SELECT '  Max 半年付: ¥2999 (省17%)' AS '';
SELECT '  Max 年付: ¥5399 (省25%)' AS '';
