60 lines
2.9 KiB
SQL
60 lines
2.9 KiB
SQL
-- 数据库迁移:添加 pricing_options 字段,支持灵活的计费周期
|
||
-- 执行时间:2025-01-XX
|
||
-- 说明:支持用户选择"包N个月"或"包N年"的套餐
|
||
|
||
-- 1. 添加 pricing_options 字段
|
||
ALTER TABLE subscription_plans
|
||
ADD COLUMN pricing_options TEXT NULL COMMENT 'JSON格式的计费周期选项';
|
||
|
||
-- 2. 为Pro套餐配置多种计费周期(基于现有价格:198元/月,2000元/年)
|
||
UPDATE subscription_plans
|
||
SET pricing_options = '[
|
||
{"months": 1, "price": 198, "label": "月付", "cycle_key": "monthly"},
|
||
{"months": 3, "price": 534, "label": "3个月", "cycle_key": "3months", "discount_percent": 10},
|
||
{"months": 6, "price": 950, "label": "半年", "cycle_key": "6months", "discount_percent": 20},
|
||
{"months": 12, "price": 2000, "label": "1年", "cycle_key": "yearly", "discount_percent": 16},
|
||
{"months": 24, "price": 3600, "label": "2年", "cycle_key": "2years", "discount_percent": 24},
|
||
{"months": 36, "price": 5040, "label": "3年", "cycle_key": "3years", "discount_percent": 29}
|
||
]'
|
||
WHERE name = 'pro';
|
||
|
||
-- 3. 为Max套餐配置多种计费周期(基于现有价格:998元/月,10000元/年)
|
||
UPDATE subscription_plans
|
||
SET pricing_options = '[
|
||
{"months": 1, "price": 998, "label": "月付", "cycle_key": "monthly"},
|
||
{"months": 3, "price": 2695, "label": "3个月", "cycle_key": "3months", "discount_percent": 10},
|
||
{"months": 6, "price": 4790, "label": "半年", "cycle_key": "6months", "discount_percent": 20},
|
||
{"months": 12, "price": 10000, "label": "1年", "cycle_key": "yearly", "discount_percent": 17},
|
||
{"months": 24, "price": 18000, "label": "2年", "cycle_key": "2years", "discount_percent": 25},
|
||
{"months": 36, "price": 25200, "label": "3年", "cycle_key": "3years", "discount_percent": 30}
|
||
]'
|
||
WHERE name = 'max';
|
||
|
||
-- ========================================
|
||
-- 价格计算说明
|
||
-- ========================================
|
||
-- Pro版(198元/月,2000元/年):
|
||
-- - 月付:198元
|
||
-- - 3个月:198×3×0.9 = 534元(打9折,省10%)
|
||
-- - 半年:198×6×0.8 = 950元(打8折,省20%)
|
||
-- - 1年:2000元(已有年付价格,约省16%)
|
||
-- - 2年:198×24×0.76 = 3600元(省24%)
|
||
-- - 3年:198×36×0.7 = 5040元(省30%)
|
||
|
||
-- Max版(998元/月,10000元/年):
|
||
-- - 月付:998元
|
||
-- - 3个月:998×3×0.9 = 2695元(打9折,省10%)
|
||
-- - 半年:998×6×0.8 = 4790元(打8折,省20%)
|
||
-- - 1年:10000元(已有年付价格,约省17%)
|
||
-- - 2年:998×24×0.75 = 18000元(省25%)
|
||
-- - 3年:998×36×0.7 = 25200元(省30%)
|
||
|
||
-- ========================================
|
||
-- 注意事项
|
||
-- ========================================
|
||
-- 1. 上述价格仅为示例,请根据实际营销策略调整
|
||
-- 2. 折扣力度建议:时间越长,优惠越大
|
||
-- 3. 如果不想提供某个周期,直接从数组中删除即可
|
||
-- 4. 前端会自动渲染所有可用的计费周期选项
|
||
-- 5. 用户可以通过优惠码获得额外折扣
|