-- 套餐表 biz_plan(与 api/model/biz_plan.js 一致,tableName: biz_plan) -- MySQL 8+,字符集 utf8mb4 SET NAMES utf8mb4; CREATE TABLE IF NOT EXISTS `biz_plan` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `plan_code` VARCHAR(64) NOT NULL COMMENT '唯一编码', `plan_name` VARCHAR(128) NOT NULL DEFAULT '' COMMENT '展示名称', `monthly_price` DECIMAL(12, 2) NOT NULL DEFAULT 0.00 COMMENT '月价', `auth_fee` DECIMAL(12, 2) NOT NULL DEFAULT 0.00 COMMENT '授权费', `account_limit` INT NOT NULL DEFAULT 0 COMMENT '账号上限,0 表示由业务解释', `active_user_limit` INT NOT NULL DEFAULT 0 COMMENT '活跃用户数上限', `msg_quota` INT NOT NULL DEFAULT 0 COMMENT '消息额度', `mass_quota` INT NOT NULL DEFAULT 0 COMMENT '群发额度', `friend_quota` INT NOT NULL DEFAULT 0 COMMENT '加好友额度', `sns_quota` INT NOT NULL DEFAULT 0 COMMENT '朋友圈额度', `enabled_features` JSON NULL COMMENT '功能点(JSON),null 表示不限制', `allowed_apis` JSON NULL COMMENT '可访问接口路径 JSON 数组,null 表示不限制', `api_call_quota` INT NOT NULL DEFAULT 0 COMMENT '每月 API 转发总次数上限,0 表示不限制', `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active', PRIMARY KEY (`id`), UNIQUE KEY `uk_biz_plan_plan_code` (`plan_code`), KEY `idx_biz_plan_status` (`status`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- ---------- 若已有旧表缺列,可单独执行(列已存在会报错,可忽略)---------- -- ALTER TABLE `biz_plan` ADD COLUMN `enabled_features` JSON NULL COMMENT '功能点(JSON),null 表示不限制'; -- ALTER TABLE `biz_plan` ADD COLUMN `allowed_apis` JSON NULL COMMENT '可访问接口路径 JSON 数组,null 表示不限制'; -- ALTER TABLE `biz_plan` ADD COLUMN `api_call_quota` INT NOT NULL DEFAULT 0 COMMENT '每月 API 转发总次数上限,0 表示不限制'; -- ---------- 示例数据(可选;plan_code 冲突则先删或改编码)---------- INSERT INTO `biz_plan` ( `plan_code`, `plan_name`, `monthly_price`, `auth_fee`, `account_limit`, `active_user_limit`, `msg_quota`, `mass_quota`, `friend_quota`, `sns_quota`, `enabled_features`, `allowed_apis`, `api_call_quota`, `status` ) VALUES ( 'plan_junior', '初级版', 299.00, 0.00, 3, 50, 3000, 100, 200, 100, JSON_ARRAY('登录', '好友', '消息', '管理'), JSON_ARRAY('/login/GetLoginStatus', '/login/DeviceLogin', '/message/SendText', '/friend/GetContactList'), 50000, 'active' ), ( 'plan_senior', '高级版', 899.00, 0.00, 20, 500, 50000, 2000, 5000, 2000, JSON_ARRAY( '登录', '好友', '消息', '群聊', '朋友圈', '小程序', '管理', '设备', '收藏', '视频号', '标签', '支付', '企业微信', '商店', '其他', 'Ws' ), NULL, 500000, 'active' ), ( 'plan_custom', '定制版', 0.00, 0.00, 9999, 9999, 0, 0, 0, 0, NULL, NULL, 0, 'active' );