Files
yunzerwebsiteallinone/go/docs/sql/insert_platform_dict_data.sql
T
2026-09-28 23:16:26 +08:00

306 lines
26 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.
-- =============================================================
-- 平台端数据字典 —— 初始数据
--
-- 表:yz_platform_dict / yz_platform_dict_item(建表见 create_dict.sql)
-- 内容来源:platform 前端散落的硬编码映射(值→文案 / 标签色),
-- 以及各平台端接口返回的状态字段取值。
--
-- 幂等:
-- - 字典按 dict_code 判重,已存在则跳过;
-- - 字典项按 (dict_id, item_value) 判重,已存在则跳过。
-- 因此可重复执行,不会产生重复数据。
--
-- 说明:
-- - tag_type 对应前端 el-tag 的 type,留空表示不渲染彩色标签;
-- - sort 按 10 递增,便于后续插入新字典项;
-- - 执行完这份数据后,前端改为调用 /platform/dict/options/:code 读取。
-- =============================================================
SET NAMES utf8mb4;
-- =============================================================
-- 1. 字典列表
-- =============================================================
INSERT INTO `yz_platform_dict` (`dict_name`, `dict_code`, `remark`, `sort`, `status`, `create_user_id`, `create_time`)
SELECT t.dict_name, t.dict_code, t.remark, t.sort, 1, 'sql', NOW()
FROM (
-- 通用
SELECT '通用启用状态' AS dict_name, 'common_enable_status' AS dict_code, '1 启用 / 0 停用,部分页面把 0 显示为「禁用」' AS remark, 10 AS sort
UNION ALL SELECT '是否' , 'common_yes_no' , '1 是 / 0 否' , 20
-- 支付
UNION ALL SELECT '支付渠道' , 'payment_channel' , 'yz_platform_payment_channel.channel' , 100
UNION ALL SELECT '支付单状态' , 'payment_order_status' , 'yz_platform_payment_order.status' , 110
UNION ALL SELECT '支付订单类型' , 'payment_order_type' , 'yz_platform_payment_order.order_type' , 120
UNION ALL SELECT '支付渠道状态' , 'payment_channel_state' , '渠道配置页展示状态:启用/停用/未配置' , 130
UNION ALL SELECT '对账处理状态' , 'payment_reconcile_status' , 'yz_platform_payment_reconcile_diff.handle_status' , 140
UNION ALL SELECT '对账差异类型' , 'payment_reconcile_diff_type', 'yz_platform_payment_reconcile_diff.diff_type' , 150
UNION ALL SELECT '佣金状态' , 'payment_commission_status', 'yz_platform_commission_order.status' , 160
UNION ALL SELECT '佣金发放方式' , 'payment_commission_pay_method', 'yz_platform_commission_order.pay_method' , 170
UNION ALL SELECT '佣金计算方式' , 'payment_calc_type' , 'yz_platform_commission_rule.calc_type' , 180
-- 通知 / 短信
UNION ALL SELECT '通知渠道' , 'notification_channel' , '站内提醒的推送渠道' , 200
UNION ALL SELECT '短信任务状态' , 'sms_task_status' , 'yz_system_sms_task.status' , 210
-- 系统
UNION ALL SELECT '请求方法' , 'http_method' , '操作日志的 HTTP 方法' , 220
UNION ALL SELECT '登录方式' , 'login_type' , '登录日志的登录方式' , 230
UNION ALL SELECT '菜单类型' , 'menu_type' , 'yz_system_menu.type' , 240
-- 官网内容
UNION ALL SELECT '导航类型' , 'website_nav_type' , 'yz_platform_website_nav.type' , 250
UNION ALL SELECT '评论状态' , 'comment_status' , 'yz_platform_website_comment.status' , 260
UNION ALL SELECT '文章状态' , 'article_status' , 'yz_platform_website_article.status' , 270
UNION ALL SELECT '公告类型' , 'notice_type' , 'yz_platform_website_notice.type' , 280
UNION ALL SELECT '公告状态' , 'notice_status' , 'yz_platform_website_notice.status' , 290
-- 账号池 / Cursor
UNION ALL SELECT '账号池平台' , 'account_pool_platform' , '账号来源平台(本地/闲鱼/淘宝…)' , 300
UNION ALL SELECT '账号池数据类型' , 'account_pool_data_type' , '账号密码 / 账号密码+Token / Token' , 310
UNION ALL SELECT '账号池提取状态' , 'account_pool_extract_status', '账号池记录的提取状态' , 320
UNION ALL SELECT 'Cursor 设备状态' , 'cursor_equipment_status' , 'yz_platform_cursor_equipment.status' , 330
UNION ALL SELECT 'Cursor 激活码状态' , 'cursor_activation_status' , 'yz_platform_cursor_activation_code.status' , 340
UNION ALL SELECT '提取记录状态' , 'cursor_extract_record_status', 'Cursor 设备提取记录的状态' , 350
UNION ALL SELECT '激活记录状态' , 'cursor_activation_record_status', 'Cursor 设备激活记录的状态' , 360
-- 模块商店
UNION ALL SELECT '模块发布状态' , 'moduleshop_publish_status' , '模块商店上下架状态' , 370
UNION ALL SELECT '模块分类状态' , 'moduleshop_category_status' , '模块商店分类启用状态' , 380
-- 投诉工单
UNION ALL SELECT '投诉工单状态' , 'complain_status' , 'yz_platform_complaint.status' , 390
-- 统一认证
UNION ALL SELECT '接入应用类型' , 'auth_app_type' , 'yz_auth_client.app_type' , 400
UNION ALL SELECT '认证域' , 'auth_realm' , '租户域 / 平台域' , 410
UNION ALL SELECT '登录验证方式' , 'auth_verify_type' , '图形验证码 / 短信 / 邮箱 / 极验 / 不开启' , 420
-- 域名
UNION ALL SELECT '域名类型' , 'domain_type' , 'yz_system_tenant_domain.domain_type' , 430
UNION ALL SELECT '域名状态' , 'domain_status' , 'yz_system_tenant_domain.status' , 440
-- 租户 / 组织
UNION ALL SELECT '员工状态' , 'employee_status' , 'yz_backend_employee.account_status' , 450
UNION ALL SELECT '性别' , 'gender' , '用户/员工性别' , 460
UNION ALL SELECT '角色分类' , 'role_category' , 'yz_system_admin_role.cid:1 平台角色 / 2 租户角色' , 470
UNION ALL SELECT '角色来源' , 'role_source' , 'yz_system_admin_role.is_custom' , 480
UNION ALL SELECT '站内信接收对象' , 'sitereminder_target_type' , 'yz_system_reminder_list.target_type' , 490
) AS t
WHERE NOT EXISTS (
SELECT 1 FROM `yz_platform_dict` AS d
WHERE d.dict_code = t.dict_code AND d.delete_time IS NULL
);
-- =============================================================
-- 2. 字典项
-- =============================================================
INSERT INTO `yz_platform_dict_item` (`dict_id`, `item_label`, `item_value`, `tag_type`, `sort`, `status`, `is_default`, `create_time`)
SELECT d.id, t.item_label, t.item_value, t.tag_type, t.sort, 1, 0, NOW()
FROM (
-- 通用启用状态
SELECT 'common_enable_status' AS dict_code, '启用' AS item_label, '1' AS item_value, 'success' AS tag_type, 10 AS sort
UNION ALL SELECT 'common_enable_status' , '停用' , '0' , 'info' , 20
-- 是否
UNION ALL SELECT 'common_yes_no' , '是' , '1' , 'success' , 10
UNION ALL SELECT 'common_yes_no' , '否' , '0' , 'info' , 20
-- 支付渠道
UNION ALL SELECT 'payment_channel' , '微信支付' , 'wechat' , '' , 10
UNION ALL SELECT 'payment_channel' , '支付宝' , 'alipay' , '' , 20
UNION ALL SELECT 'payment_channel' , '银联' , 'unionpay' , '' , 30
UNION ALL SELECT 'payment_channel' , '云闪付' , 'cloudpay' , '' , 40
UNION ALL SELECT 'payment_channel' , 'PayPal' , 'paypal' , '' , 50
-- 支付单状态
UNION ALL SELECT 'payment_order_status' , '已创建' , 'created' , 'info' , 10
UNION ALL SELECT 'payment_order_status' , '待支付' , 'pending' , 'warning' , 20
UNION ALL SELECT 'payment_order_status' , '支付中' , 'paying' , 'warning' , 30
UNION ALL SELECT 'payment_order_status' , '支付成功' , 'paid' , 'success' , 40
UNION ALL SELECT 'payment_order_status' , '支付成功' , 'success' , 'success' , 50
UNION ALL SELECT 'payment_order_status' , '支付失败' , 'failed' , 'danger' , 60
UNION ALL SELECT 'payment_order_status' , '已关闭' , 'closed' , 'info' , 70
UNION ALL SELECT 'payment_order_status' , '已超时' , 'timeout' , 'info' , 80
UNION ALL SELECT 'payment_order_status' , '退款中' , 'refunding' , 'warning' , 90
UNION ALL SELECT 'payment_order_status' , '已退款' , 'refunded' , 'info' , 100
UNION ALL SELECT 'payment_order_status' , '部分退款' , 'partial_refunded' , 'warning' , 110
-- 支付订单类型
UNION ALL SELECT 'payment_order_type' , '平台使用费' , 'platform_usage' , '' , 10
UNION ALL SELECT 'payment_order_type' , '模块购买' , 'module_shop' , '' , 20
UNION ALL SELECT 'payment_order_type' , '服务费' , 'service_fee' , '' , 30
-- 支付渠道状态
UNION ALL SELECT 'payment_channel_state' , '已启用' , 'enabled' , 'success' , 10
UNION ALL SELECT 'payment_channel_state' , '已停用' , 'disabled' , 'info' , 20
UNION ALL SELECT 'payment_channel_state' , '未配置' , 'unconfigured' , 'warning' , 30
-- 对账处理状态
UNION ALL SELECT 'payment_reconcile_status' , '待处理' , 'unhandled' , 'warning' , 10
UNION ALL SELECT 'payment_reconcile_status' , '处理中' , 'handling' , 'primary' , 20
UNION ALL SELECT 'payment_reconcile_status' , '已处理' , 'handled' , 'success' , 30
UNION ALL SELECT 'payment_reconcile_status' , '已忽略' , 'ignored' , 'info' , 40
-- 对账差异类型
UNION ALL SELECT 'payment_reconcile_diff_type' , '长款' , 'long' , 'warning' , 10
UNION ALL SELECT 'payment_reconcile_diff_type' , '短款' , 'short' , 'danger' , 20
UNION ALL SELECT 'payment_reconcile_diff_type' , '状态不一致' , 'status_mismatch' , 'warning' , 30
-- 佣金状态
UNION ALL SELECT 'payment_commission_status' , '应付' , 'payable' , 'warning' , 10
UNION ALL SELECT 'payment_commission_status' , '已付' , 'settled' , 'success' , 20
UNION ALL SELECT 'payment_commission_status' , '税务处理中' , 'tax_processing' , 'primary' , 30
UNION ALL SELECT 'payment_commission_status' , '已作废' , 'canceled' , 'info' , 40
-- 佣金发放方式
UNION ALL SELECT 'payment_commission_pay_method', '余额抵扣' , 'balance' , '' , 10
UNION ALL SELECT 'payment_commission_pay_method', '银行转账' , 'bank' , '' , 20
UNION ALL SELECT 'payment_commission_pay_method', '人工发放' , 'manual' , '' , 30
UNION ALL SELECT 'payment_commission_pay_method', '下期抵扣' , 'offset' , '' , 40
-- 佣金计算方式
UNION ALL SELECT 'payment_calc_type' , '按比例' , 'percent' , 'primary' , 10
UNION ALL SELECT 'payment_calc_type' , '固定金额' , 'fixed' , 'success' , 20
UNION ALL SELECT 'payment_calc_type' , '阶梯' , 'tiered' , 'warning' , 30
-- 通知渠道
UNION ALL SELECT 'notification_channel' , '短信' , 'SMS' , 'success' , 10
UNION ALL SELECT 'notification_channel' , '邮件' , 'EMAIL' , 'warning' , 20
UNION ALL SELECT 'notification_channel' , 'Bark推送' , 'BARK' , 'danger' , 30
UNION ALL SELECT 'notification_channel' , '站内信' , 'SITE_MSG' , 'primary' , 40
-- 短信任务状态
UNION ALL SELECT 'sms_task_status' , '待发送' , '0' , 'info' , 10
UNION ALL SELECT 'sms_task_status' , '发送中' , '1' , 'warning' , 20
UNION ALL SELECT 'sms_task_status' , '发送失败' , '2' , 'danger' , 30
UNION ALL SELECT 'sms_task_status' , '发送成功' , '3' , 'success' , 40
-- 请求方法
UNION ALL SELECT 'http_method' , 'GET' , 'GET' , 'info' , 10
UNION ALL SELECT 'http_method' , 'POST' , 'POST' , 'success' , 20
UNION ALL SELECT 'http_method' , 'PUT' , 'PUT' , 'warning' , 30
UNION ALL SELECT 'http_method' , 'DELETE' , 'DELETE' , 'danger' , 40
UNION ALL SELECT 'http_method' , 'PATCH' , 'PATCH' , 'primary' , 50
-- 登录方式
UNION ALL SELECT 'login_type' , '密码登录' , 'password' , '' , 10
UNION ALL SELECT 'login_type' , '短信验证码' , 'sms' , '' , 20
UNION ALL SELECT 'login_type' , '邮箱验证码' , 'email' , '' , 30
-- 菜单类型
UNION ALL SELECT 'menu_type' , '目录' , '1' , 'primary' , 10
UNION ALL SELECT 'menu_type' , '页面' , '2' , 'success' , 20
UNION ALL SELECT 'menu_type' , '接口' , '3' , 'info' , 30
-- 导航类型
UNION ALL SELECT 'website_nav_type' , '目录' , '1' , 'primary' , 10
UNION ALL SELECT 'website_nav_type' , '页面' , '2' , 'success' , 20
UNION ALL SELECT 'website_nav_type' , '外链' , '3' , 'info' , 30
UNION ALL SELECT 'website_nav_type' , '单页' , '4' , 'warning' , 40
-- 评论状态
UNION ALL SELECT 'comment_status' , '待审核' , '0' , 'warning' , 10
UNION ALL SELECT 'comment_status' , '已通过' , '1' , 'success' , 20
UNION ALL SELECT 'comment_status' , '已拒绝' , '2' , 'danger' , 30
-- 文章状态
UNION ALL SELECT 'article_status' , '草稿' , '0' , 'info' , 10
UNION ALL SELECT 'article_status' , '待审核' , '1' , 'warning' , 20
UNION ALL SELECT 'article_status' , '已发布' , '2' , 'success' , 30
UNION ALL SELECT 'article_status' , '已隐藏' , '3' , 'danger' , 40
-- 公告类型
UNION ALL SELECT 'notice_type' , '通知公告' , '1' , '' , 10
UNION ALL SELECT 'notice_type' , '活动公告' , '2' , '' , 20
UNION ALL SELECT 'notice_type' , '系统维护' , '3' , '' , 30
-- 公告状态
UNION ALL SELECT 'notice_status' , '草稿' , '0' , 'info' , 10
UNION ALL SELECT 'notice_status' , '已发布' , '1' , 'success' , 20
UNION ALL SELECT 'notice_status' , '已下线' , '2' , 'warning' , 30
-- 账号池平台
UNION ALL SELECT 'account_pool_platform' , '本地' , 'local' , 'info' , 10
UNION ALL SELECT 'account_pool_platform' , '闲鱼' , 'xianyu' , 'warning' , 20
UNION ALL SELECT 'account_pool_platform' , '拼多多' , 'pinduoduo' , 'danger' , 30
UNION ALL SELECT 'account_pool_platform' , '京东' , 'jingdong' , 'primary' , 40
UNION ALL SELECT 'account_pool_platform' , '抖音' , 'douyin' , 'success' , 50
UNION ALL SELECT 'account_pool_platform' , '淘宝' , 'taobao' , 'info' , 60
UNION ALL SELECT 'account_pool_platform' , '自有商城' , 'ziyoushangcheng' , 'warning' , 70
UNION ALL SELECT 'account_pool_platform' , '续杯' , 'xubei' , 'primary' , 80
-- 账号池数据类型
UNION ALL SELECT 'account_pool_data_type' , '账号密码' , 'account' , 'success' , 10
UNION ALL SELECT 'account_pool_data_type' , '账号密码+Token' , 'account_tk' , 'primary' , 20
UNION ALL SELECT 'account_pool_data_type' , 'Token' , 'tk' , 'warning' , 30
-- 账号池提取状态
UNION ALL SELECT 'account_pool_extract_status' , '未提取' , '0' , 'info' , 10
UNION ALL SELECT 'account_pool_extract_status' , '补号' , '2' , 'warning' , 20
UNION ALL SELECT 'account_pool_extract_status' , '续杯' , '3' , 'primary' , 30
UNION ALL SELECT 'account_pool_extract_status' , '已提取' , 'extracted' , 'success' , 40
-- Cursor 设备状态
UNION ALL SELECT 'cursor_equipment_status' , '已激活' , 'active' , 'success' , 10
UNION ALL SELECT 'cursor_equipment_status' , '未激活' , 'inactive' , 'info' , 20
UNION ALL SELECT 'cursor_equipment_status' , '禁用' , 'disabled' , 'danger' , 30
UNION ALL SELECT 'cursor_equipment_status' , '已过期' , 'expired' , 'warning' , 40
-- Cursor 激活码状态
UNION ALL SELECT 'cursor_activation_status' , '未使用' , '0' , 'info' , 10
UNION ALL SELECT 'cursor_activation_status' , '已使用' , '1' , 'success' , 20
UNION ALL SELECT 'cursor_activation_status' , '已过期' , '2' , 'warning' , 30
UNION ALL SELECT 'cursor_activation_status' , '已禁用' , '3' , 'danger' , 40
-- 提取记录状态
UNION ALL SELECT 'cursor_extract_record_status', '未提取' , '0' , 'info' , 10
UNION ALL SELECT 'cursor_extract_record_status', '已提取' , '1' , 'success' , 20
UNION ALL SELECT 'cursor_extract_record_status', '补号' , '2' , 'warning' , 30
UNION ALL SELECT 'cursor_extract_record_status', '异常' , '3' , 'danger' , 40
-- 激活记录状态
UNION ALL SELECT 'cursor_activation_record_status', '失败' , '0' , 'danger' , 10
UNION ALL SELECT 'cursor_activation_record_status', '成功' , '1' , 'success' , 20
-- 模块发布状态
UNION ALL SELECT 'moduleshop_publish_status' , '草稿' , '0' , 'info' , 10
UNION ALL SELECT 'moduleshop_publish_status' , '已发布' , '1' , 'success' , 20
UNION ALL SELECT 'moduleshop_publish_status' , '已撤回' , '2' , 'warning' , 30
-- 模块分类状态
UNION ALL SELECT 'moduleshop_category_status' , '禁用' , '0' , 'info' , 10
UNION ALL SELECT 'moduleshop_category_status' , '启用' , '1' , 'success' , 20
-- 投诉工单状态
UNION ALL SELECT 'complain_status' , '待处理' , '0' , 'warning' , 10
UNION ALL SELECT 'complain_status' , '处理中' , '1' , 'warning' , 20
UNION ALL SELECT 'complain_status' , '已回复' , '2' , 'success' , 30
UNION ALL SELECT 'complain_status' , '已关闭' , '3' , 'info' , 40
-- 接入应用类型
UNION ALL SELECT 'auth_app_type' , 'Web 后端' , '1' , '' , 10
UNION ALL SELECT 'auth_app_type' , 'SPA' , '2' , '' , 20
UNION ALL SELECT 'auth_app_type' , '原生 APP' , '3' , '' , 30
UNION ALL SELECT 'auth_app_type' , '小程序' , '4' , '' , 40
-- 认证域
UNION ALL SELECT 'auth_realm' , '租户域' , 'tenant' , '' , 10
UNION ALL SELECT 'auth_realm' , '平台域' , 'platform' , '' , 20
-- 登录验证方式
UNION ALL SELECT 'auth_verify_type' , '图形验证码' , 'captcha' , '' , 10
UNION ALL SELECT 'auth_verify_type' , '短信验证码' , 'sms' , '' , 20
UNION ALL SELECT 'auth_verify_type' , '邮箱验证码' , 'email' , '' , 30
UNION ALL SELECT 'auth_verify_type' , '极验人机验证' , 'geetest' , '' , 40
UNION ALL SELECT 'auth_verify_type' , '不开启' , 'none' , '' , 50
-- 域名类型
UNION ALL SELECT 'domain_type' , '平台二级域名' , '1' , '' , 10
UNION ALL SELECT 'domain_type' , '自有域名' , '2' , '' , 20
-- 域名状态
UNION ALL SELECT 'domain_status' , '审核中' , '0' , 'warning' , 10
UNION ALL SELECT 'domain_status' , '已生效' , '1' , 'success' , 20
UNION ALL SELECT 'domain_status' , '已禁用' , '2' , 'info' , 30
-- 员工状态
UNION ALL SELECT 'employee_status' , '启用' , '1' , 'success' , 10
UNION ALL SELECT 'employee_status' , '禁用' , '0' , 'info' , 20
UNION ALL SELECT 'employee_status' , '离职' , '2' , 'danger' , 30
-- 性别
UNION ALL SELECT 'gender' , '保密' , '0' , 'info' , 10
UNION ALL SELECT 'gender' , '男' , '1' , 'primary' , 20
UNION ALL SELECT 'gender' , '女' , '2' , 'danger' , 30
-- 角色分类
UNION ALL SELECT 'role_category' , '平台角色' , '1' , 'primary' , 10
UNION ALL SELECT 'role_category' , '租户角色' , '2' , 'warning' , 20
-- 角色来源
UNION ALL SELECT 'role_source' , '预置' , '0' , 'info' , 10
UNION ALL SELECT 'role_source' , '自建' , '1' , 'warning' , 20
-- 站内信接收对象
UNION ALL SELECT 'sitereminder_target_type' , '全平台(所有人)' , 'all' , 'danger' , 10
UNION ALL SELECT 'sitereminder_target_type' , '平台端(所有人)' , 'platform' , 'primary' , 20
UNION ALL SELECT 'sitereminder_target_type' , '租户端(所有租户)' , 'tenant_all' , 'success' , 30
UNION ALL SELECT 'sitereminder_target_type' , '租户角色' , 'tenant_role' , 'warning' , 40
UNION ALL SELECT 'sitereminder_target_type' , '租户' , 'tenant' , 'warning' , 50
UNION ALL SELECT 'sitereminder_target_type' , '租户用户' , 'tenant_user' , 'info' , 60
UNION ALL SELECT 'sitereminder_target_type' , '平台角色' , 'role' , 'warning' , 70
) AS t
JOIN `yz_platform_dict` AS d
ON d.dict_code = t.dict_code AND d.delete_time IS NULL
WHERE NOT EXISTS (
SELECT 1 FROM `yz_platform_dict_item` AS i
WHERE i.dict_id = d.id AND i.item_value = t.item_value AND i.delete_time IS NULL
);
-- =============================================================
-- 3. 校验
-- =============================================================
SELECT d.dict_name, d.dict_code, COUNT(i.id) AS item_count
FROM `yz_platform_dict` d
LEFT JOIN `yz_platform_dict_item` i ON i.dict_id = d.id AND i.delete_time IS NULL
WHERE d.delete_time IS NULL
GROUP BY d.id, d.dict_name, d.dict_code
ORDER BY d.sort, d.id;