功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
@@ -228,6 +228,9 @@ create table t_nail_artist_info
skills text null comment '技能标签ID集合,多个ID以逗号分隔',
rating decimal(3, 1) default 0.0 null comment '评分',
status tinyint unsigned default 1 null comment '状态:1-营业中,0-休息中',
participate_production tinyint unsigned default 1 not null comment '是否参与美甲制作:1-参与,0-不参与',
work_start_time time null comment '工作开始时间',
work_end_time time null comment '工作结束时间',
portfolio text null comment '作品集商品ID集合,多个ID以逗号分隔',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
@@ -245,6 +248,9 @@ create index idx_user_id
on t_nail_artist_info (user_id)
comment '按用户查询美甲师信息的索引';
create index idx_t_nail_artist_info_participate
on t_nail_artist_info (participate_production, status);
-- auto-generated definition
create table t_object_storage_file
(
@@ -397,6 +403,9 @@ create table t_shop
shop_name varchar(100) not null comment '店铺名称',
description text null comment '店铺描述',
address varchar(200) not null comment '店铺地址',
map_provider varchar(20) default 'TENCENT' not null comment '地图服务商:TENCENT/AMAP',
longitude decimal(12, 8) null comment '店铺经度',
latitude decimal(12, 8) null comment '店铺纬度',
business_hours varchar(100) default '' null comment '店铺营业时间',
cover_image_file_id varchar(50) default '' null comment '店铺封面图文件ID',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
@@ -522,6 +531,101 @@ create index idx_user_id
on t_user_permission (user_id)
comment '用户ID索引';
create table if not exists t_system_message
(
id bigint unsigned auto_increment comment '站内消息主键'
primary key,
title varchar(100) not null comment '消息标题',
content text not null comment '消息内容',
image_file_id bigint unsigned null comment '消息图片文件ID',
publisher_id bigint unsigned not null comment '发布人ID',
publisher_name varchar(100) default '' null comment '发布人名称',
publisher_type tinyint not null comment '发布人类型:2-店长,4-管理员',
target_type varchar(30) not null comment '目标范围:PLATFORM_ALL/CURRENT_SHOP_ALL/SHOP_ALL/SELECTED_SHOPS/SELECTED_USERS',
target_ids text null comment '目标ID集合,多个ID以逗号分隔',
popup_enabled tinyint unsigned default 1 not null comment '是否弹窗:1-弹窗,0-不弹窗',
status tinyint unsigned default 1 not null comment '状态:1-已发布,0-已撤回',
publish_time datetime default CURRENT_TIMESTAMP not null comment '发布时间',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
)
comment '站内消息表';
create index idx_t_system_message_publish_time
on t_system_message (publish_time);
create index idx_t_system_message_target
on t_system_message (target_type, status);
create table if not exists t_system_message_user_state
(
id bigint unsigned auto_increment comment '用户消息状态主键'
primary key,
message_id bigint unsigned not null comment '消息ID',
user_id bigint unsigned not null comment '用户ID',
popup_shown tinyint unsigned default 0 not null comment '是否已弹窗:1-是,0-否',
read_status tinyint unsigned default 0 not null comment '是否已读:1-是,0-否',
popup_time datetime null comment '首次弹窗时间',
read_time datetime null comment '阅读时间',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删',
constraint uk_t_system_message_user
unique (message_id, user_id)
)
comment '用户站内消息状态表';
create index idx_t_system_message_user_state_user
on t_system_message_user_state (user_id, read_status, popup_shown);
create table if not exists t_announcement
(
id bigint unsigned auto_increment comment '公告主键'
primary key,
title varchar(100) not null comment '公告标题',
content text not null comment '公告内容',
publisher_id bigint unsigned not null comment '发布人ID',
publisher_name varchar(100) default '' null comment '发布人名称',
publisher_type tinyint not null comment '发布人类型:2-店长,4-管理员',
target_type varchar(30) not null comment '目标范围',
target_ids text null comment '目标ID集合,多个ID以逗号分隔',
status tinyint unsigned default 1 not null comment '状态:1-已发布,0-已撤回',
sort_order int default 0 not null comment '排序值',
publish_time datetime default CURRENT_TIMESTAMP not null comment '发布时间',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
)
comment '首页滚动公告表';
create index idx_t_announcement_target
on t_announcement (target_type, status);
create index idx_t_announcement_sort_time
on t_announcement (sort_order, publish_time);
create table if not exists t_vip_recharge_plan
(
id bigint unsigned auto_increment comment 'VIP充值档位主键'
primary key,
shop_id bigint unsigned not null comment '所属店铺ID',
title varchar(100) not null comment '档位标题',
recharge_amount decimal(10, 2) not null comment '充值金额',
gift_amount decimal(10, 2) default 0.00 not null comment '赠送金额',
vip_level varchar(20) not null comment '对应VIP等级',
description varchar(255) null comment '展示说明',
sort_order int default 0 not null comment '排序值',
status tinyint unsigned default 1 not null comment '状态:1-启用,0-停用',
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删,1-已删'
)
comment 'VIP充值展示档位表';
create index idx_t_vip_recharge_plan_shop_status
on t_vip_recharge_plan (shop_id, status, sort_order);
-- auto-generated definition
create table t_vip_benefit
(
@@ -1008,6 +1112,10 @@ END$$
DELIMITER ;
CALL sp_add_column_if_not_exists('t_shop', 'status', 'tinyint unsigned NOT NULL DEFAULT 1 COMMENT ''店铺状态:1-启用,0-停用''');
CALL sp_add_column_if_not_exists('t_shop', 'authorization_expire_time', 'datetime NULL COMMENT ''店铺授权有效期,空表示长期有效''');
CALL sp_add_column_if_not_exists('t_shop', 'map_provider', 'varchar(20) NOT NULL DEFAULT ''TENCENT'' COMMENT ''地图服务商:TENCENT/AMAP''');
CALL sp_add_column_if_not_exists('t_shop', 'longitude', 'decimal(12,8) NULL COMMENT ''店铺经度''');
CALL sp_add_column_if_not_exists('t_shop', 'latitude', 'decimal(12,8) NULL COMMENT ''店铺纬度''');
UPDATE t_shop
SET status = 1
@@ -1077,6 +1185,33 @@ WHERE b.status IS NULL
OR b.is_delete IS NULL
OR b.update_time IS NULL;
CALL sp_add_column_if_not_exists('t_nail_artist_info', 'participate_production', 'tinyint unsigned NOT NULL DEFAULT 1 COMMENT ''是否参与美甲制作:1-参与,0-不参与''');
CALL sp_add_column_if_not_exists('t_nail_artist_info', 'work_start_time', 'time NULL COMMENT ''工作开始时间''');
CALL sp_add_column_if_not_exists('t_nail_artist_info', 'work_end_time', 'time NULL COMMENT ''工作结束时间''');
CALL sp_add_index_if_not_exists('t_nail_artist_info', 'idx_t_nail_artist_info_participate', '(`participate_production`, `status`)');
CALL sp_add_column_if_not_exists('t_system_message', 'image_file_id', 'bigint unsigned NULL COMMENT ''消息图片文件ID''');
CREATE TABLE IF NOT EXISTS `t_messagehub_push_config` (
`id` bigint unsigned NOT NULL COMMENT '主键ID',
`scene_code` varchar(80) NOT NULL COMMENT '业务场景编码',
`scene_name` varchar(100) NOT NULL COMMENT '业务场景名称',
`platform` varchar(20) NOT NULL DEFAULT 'SMS' COMMENT 'MessageHub 平台类型:SMS/EMAIL/QQ',
`msg_type` varchar(30) NOT NULL DEFAULT 'VERIFICATION' COMMENT 'MessageHub 消息类型',
`queue_name` varchar(100) NOT NULL DEFAULT 'smsQueue' COMMENT '投递到 MessageHub 的队列名',
`source_system` varchar(80) NOT NULL DEFAULT 'yuminail' COMMENT 'MessageHub 来源系统编码',
`template_code` varchar(100) NOT NULL COMMENT 'MessageHub 模板编码',
`channel_id` bigint unsigned NULL COMMENT 'MessageHub 通道ID,不填则由 MessageHub 自动选择',
`send_method` varchar(30) NULL COMMENT '兼容旧短信 DTO 的发送方式,如 SPUG/OTHER',
`enabled` tinyint unsigned NOT NULL DEFAULT 1 COMMENT '是否启用:1-启用,0-停用',
`remark` varchar(255) NULL COMMENT '备注',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_delete` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '逻辑删除:0-未删除,1-已删除',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_messagehub_push_config_scene` (`scene_code`),
KEY `idx_messagehub_push_config_enabled` (`enabled`, `is_delete`)
) COMMENT='YumiNail按业务场景投递MessageHub的配置';
DROP PROCEDURE IF EXISTS sp_add_column_if_not_exists;
DROP PROCEDURE IF EXISTS sp_add_index_if_not_exists;
DROP PROCEDURE IF EXISTS sp_add_unique_index_if_not_exists;
@@ -1134,7 +1269,38 @@ VALUES
('order:edit', '编辑订单', '订单管理', '编辑订单信息的预留权限', NOW(), NOW(), 0),
('order:delete', '删除订单', '订单管理', '删除订单的预留权限', NOW(), NOW(), 0),
('nail_artist:view', '查看美甲师', '美甲师管理', '查看美甲师信息与排班入口', NOW(), NOW(), 0),
('nail_artist:edit', '编辑美甲师', '美甲师管理', '编辑美甲师信息', NOW(), NOW(), 0)
('nail_artist:edit', '编辑美甲师', '美甲师管理', '编辑美甲师信息', NOW(), NOW(), 0),
('message:view', '查看消息', '消息管理', '查看站内消息发布与通知', NOW(), NOW(), 0),
('message:create', '发布消息', '消息管理', '发布站内消息', NOW(), NOW(), 0),
('message:delete', '撤回消息', '消息管理', '撤回已发布站内消息', NOW(), NOW(), 0)
,
('announcement:view', 'View Announcements', 'Announcement Management', 'View announcement list and detail', NOW(), NOW(), 0),
('announcement:create', 'Create Announcements', 'Announcement Management', 'Publish announcements', NOW(), NOW(), 0),
('announcement:delete', 'Withdraw Announcements', 'Announcement Management', 'Withdraw published announcements', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
description = VALUES(description),
update_time = NOW(),
is_delete = 0;
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
VALUES
(910000000008001, 'message:view', '查看消息', '消息管理', '查看站内消息发布与通知', NOW(), NOW(), 0),
(910000000008002, 'message:create', '发布消息', '消息管理', '发布站内消息', NOW(), NOW(), 0),
(910000000008003, 'message:delete', '撤回消息', '消息管理', '撤回已发布站内消息', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
description = VALUES(description),
update_time = NOW(),
is_delete = 0;
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
VALUES
(910000000008011, 'announcement:view', 'View Announcements', 'Announcement Management', 'View announcement list and detail', NOW(), NOW(), 0),
(910000000008012, 'announcement:create', 'Create Announcements', 'Announcement Management', 'Publish announcements', NOW(), NOW(), 0),
(910000000008013, 'announcement:delete', 'Withdraw Announcements', 'Announcement Management', 'Withdraw published announcements', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
@@ -1229,7 +1395,13 @@ INNER JOIN t_permission p
'order:edit',
'order:delete',
'nail_artist:view',
'nail_artist:edit'
'nail_artist:edit',
'message:view',
'message:create',
'message:delete',
'announcement:view',
'announcement:create',
'announcement:delete'
)
WHERE u.is_delete = 0
AND u.type = 4
@@ -1283,7 +1455,11 @@ INNER JOIN t_permission p
'order:edit',
'order:delete',
'nail_artist:view',
'nail_artist:edit'
'nail_artist:edit',
'message:view',
'message:create',
'announcement:view',
'announcement:create'
)
WHERE u.is_delete = 0
AND u.type = 2
@@ -1323,6 +1499,224 @@ WHERE u.is_delete = 0
AND up.permission_id = p.id
);
INSERT INTO t_user_permission (id, user_id, permission_id, create_time, update_time, create_by, update_by, is_delete)
SELECT 910000000009000 + ((u.id % 1000000) * 10) + CASE p.permission_code
WHEN 'message:view' THEN 1
WHEN 'message:create' THEN 2
WHEN 'message:delete' THEN 3
WHEN 'announcement:view' THEN 4
WHEN 'announcement:create' THEN 5
WHEN 'announcement:delete' THEN 6
ELSE 0
END,
u.id,
p.id,
NOW(),
NOW(),
u.id,
u.id,
0
FROM t_user u
INNER JOIN t_permission p
ON p.is_delete = 0
AND (
(u.type = 4 AND p.permission_code IN ('message:view', 'message:create', 'message:delete', 'announcement:view', 'announcement:create', 'announcement:delete'))
OR (u.type = 2 AND p.permission_code IN ('message:view', 'message:create', 'announcement:view', 'announcement:create'))
)
WHERE u.is_delete = 0
AND NOT EXISTS (
SELECT 1
FROM t_user_permission up
WHERE up.user_id = u.id
AND up.permission_id = p.id
)
ON DUPLICATE KEY UPDATE
is_delete = 0,
update_time = NOW();
-- YumiNail 手工验收种子数据
INSERT INTO t_nail_artist_info (user_id, identity, experience, skills, rating, status, participate_production, work_start_time, work_end_time, portfolio, create_time, update_time, is_delete)
SELECT u.id, '店长', 3, '', 5.0, 1, 0, '09:00:00', '18:00:00', '', NOW(), NOW(), 0
FROM t_user u
WHERE u.type = 2 AND u.is_delete = 0
AND NOT EXISTS (SELECT 1 FROM t_nail_artist_info nai WHERE nai.user_id = u.id AND nai.is_delete = 0);
UPDATE t_nail_artist_info nai
INNER JOIN t_user u ON u.id = nai.user_id AND u.type = 3
SET nai.participate_production = 1
WHERE nai.participate_production IS NULL;
UPDATE t_nail_artist_info nai
INNER JOIN t_user u ON u.id = nai.user_id AND u.type = 2
SET nai.participate_production = COALESCE(nai.participate_production, 0);
-- 小型全覆盖验收数据,便于人工抽检。
-- Password hash matches the existing admin seed password hash; reset in non-local environments if needed.
INSERT INTO t_shop (id, shop_name, description, address, business_hours, cover_image_file_id, create_time, update_time, is_delete, image_file_ids, status)
SELECT 910000000000001, '验收主店', '用于验收的主门店', '验收路 1 号', '09:00-21:00', '', NOW(), NOW(), 0, '', 1
WHERE NOT EXISTS (SELECT 1 FROM t_shop WHERE id = 910000000000001);
INSERT INTO t_shop (id, shop_name, description, address, business_hours, cover_image_file_id, create_time, update_time, is_delete, image_file_ids, status)
SELECT 910000000000002, '验收分店', '用于验收的分门店', '验收路 2 号', '10:00-20:00', '', NOW(), NOW(), 0, '', 1
WHERE NOT EXISTS (SELECT 1 FROM t_shop WHERE id = 910000000000002);
INSERT INTO t_vip_info (id, vip_level, start_time, expire_time, activation_method, benefit_id, create_time, update_time)
SELECT 910000000000101, '青铜会员', NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), '验收种子数据', COALESCE((SELECT id FROM t_vip_benefit WHERE level_rank = 1 LIMIT 1), 0), NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM t_vip_info WHERE id = 910000000000101);
INSERT INTO t_vip_info (id, vip_level, start_time, expire_time, activation_method, benefit_id, create_time, update_time)
SELECT 910000000000102, '白银会员', NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), '验收种子数据', COALESCE((SELECT id FROM t_vip_benefit WHERE level_rank = 2 LIMIT 1), 0), NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM t_vip_info WHERE id = 910000000000102);
INSERT INTO t_vip_info (id, vip_level, start_time, expire_time, activation_method, benefit_id, create_time, update_time)
SELECT 910000000000103, '黄金会员', NOW(), DATE_ADD(NOW(), INTERVAL 1 YEAR), '验收种子数据', COALESCE((SELECT id FROM t_vip_benefit WHERE level_rank = 3 LIMIT 1), 0), NOW(), NOW()
WHERE NOT EXISTS (SELECT 1 FROM t_vip_info WHERE id = 910000000000103);
INSERT INTO t_user (id, shop_id, nickname, account, phone, email, phone_verified, email_verified, password, signature, level, type, vip_id, create_time, update_time, is_delete, status, avatar)
VALUES
(910000000001001, 910000000000001, '验收普通用户', 'accept_user_normal', '18800001001', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '普通用户', 0, 0, NOW(), NOW(), 0, 1, NULL),
(910000000001002, 910000000000001, '验收青铜用户', 'accept_user_bronze', '18800001002', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '青铜会员', 0, 910000000000101, NOW(), NOW(), 0, 1, NULL),
(910000000001003, 910000000000001, '验收白银用户', 'accept_user_silver', '18800001003', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '白银会员', 0, 910000000000102, NOW(), NOW(), 0, 1, NULL),
(910000000001004, 910000000000001, '验收黄金用户', 'accept_user_gold', '18800001004', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '黄金会员', 0, 910000000000103, NOW(), NOW(), 0, 1, NULL),
(910000000002001, 910000000000001, '验收店长', 'accept_manager_main', '18800002001', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '店长', 2, 0, NOW(), NOW(), 0, 1, NULL),
(910000000002002, 910000000000001, '验收参与制作店长', 'accept_manager_artist', '18800002002', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '店长', 2, 0, NOW(), NOW(), 0, 1, NULL),
(910000000002003, 910000000000002, '验收分店店长', 'accept_manager_branch', '18800002003', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '店长', 2, 0, NOW(), NOW(), 0, 1, NULL),
(910000000003001, 910000000000001, '验收美甲师', 'accept_artist_main', '18800003001', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '美甲师', 3, 0, NOW(), NOW(), 0, 1, NULL),
(910000000003002, 910000000000002, '验收分店美甲师', 'accept_artist_branch', '18800003002', NULL, 1, 0, '$2a$10$9v.6PztWy3.vmJiVMaOyKuWeVqAnpuHB3hQ3Dgiuz6L8IwBe7Cn9W', '', '美甲师', 3, 0, NOW(), NOW(), 0, 1, NULL)
ON DUPLICATE KEY UPDATE
shop_id = VALUES(shop_id),
nickname = VALUES(nickname),
phone = VALUES(phone),
level = VALUES(level),
type = VALUES(type),
vip_id = VALUES(vip_id),
status = VALUES(status),
is_delete = 0,
update_time = NOW();
INSERT INTO t_user_shop_binding (user_id, shop_id, status, create_time, update_time, is_delete)
SELECT u.id, u.shop_id, 1, NOW(), NOW(), 0
FROM t_user u
WHERE u.id BETWEEN 910000000001001 AND 910000000003002
AND u.shop_id > 0
ON DUPLICATE KEY UPDATE
status = 1,
is_delete = 0,
update_time = NOW();
INSERT INTO t_nail_artist_info (user_id, identity, experience, skills, rating, status, participate_production, work_start_time, work_end_time, portfolio, create_time, update_time, is_delete)
VALUES
(910000000002001, '店长', 5, '门店管理', 5.0, 1, 0, '09:00:00', '18:00:00', '', NOW(), NOW(), 0),
(910000000002002, '参与制作店长', 8, '美甲设计', 5.0, 1, 1, '09:30:00', '20:00:00', '', NOW(), NOW(), 0),
(910000000002003, '分店店长', 4, '分店管理', 4.8, 1, 1, '10:00:00', '19:00:00', '', NOW(), NOW(), 0),
(910000000003001, '美甲师', 3, '凝胶,护理', 4.9, 1, 1, '10:00:00', '21:00:00', '', NOW(), NOW(), 0),
(910000000003002, '分店美甲师', 2, '基础护理,修复', 4.7, 1, 1, '10:00:00', '19:00:00', '', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
identity = VALUES(identity),
experience = VALUES(experience),
skills = VALUES(skills),
rating = VALUES(rating),
status = VALUES(status),
participate_production = VALUES(participate_production),
work_start_time = VALUES(work_start_time),
work_end_time = VALUES(work_end_time),
is_delete = 0,
update_time = NOW();
INSERT INTO t_balance (user_id, amount, create_time, last_update_time, total_recharge_amount, last_recharge_time)
VALUES
(910000000001001, 68.00, NOW(), NOW(), 100.00, DATE_SUB(NOW(), INTERVAL 10 DAY)),
(910000000001002, 288.00, NOW(), NOW(), 600.00, DATE_SUB(NOW(), INTERVAL 8 DAY)),
(910000000001003, 588.00, NOW(), NOW(), 1200.00, DATE_SUB(NOW(), INTERVAL 6 DAY)),
(910000000001004, 988.00, NOW(), NOW(), 2600.00, DATE_SUB(NOW(), INTERVAL 4 DAY))
ON DUPLICATE KEY UPDATE
amount = VALUES(amount),
total_recharge_amount = VALUES(total_recharge_amount),
last_recharge_time = VALUES(last_recharge_time),
last_update_time = NOW();
INSERT INTO t_balance_change_detail (id, user_id, amount, type, current_balance, change_time)
VALUES
(910000000007001, 910000000001001, 100.00, 'RECHARGE', 100.00, DATE_SUB(NOW(), INTERVAL 10 DAY)),
(910000000007002, 910000000001001, -32.00, 'CONSUME', 68.00, DATE_SUB(NOW(), INTERVAL 9 DAY)),
(910000000007003, 910000000001002, 600.00, 'RECHARGE', 600.00, DATE_SUB(NOW(), INTERVAL 8 DAY)),
(910000000007004, 910000000001002, -312.00, 'CONSUME', 288.00, DATE_SUB(NOW(), INTERVAL 7 DAY)),
(910000000007005, 910000000001003, 1200.00, 'RECHARGE', 1200.00, DATE_SUB(NOW(), INTERVAL 6 DAY)),
(910000000007006, 910000000001003, -612.00, 'CONSUME', 588.00, DATE_SUB(NOW(), INTERVAL 5 DAY)),
(910000000007007, 910000000001004, 2600.00, 'RECHARGE', 2600.00, DATE_SUB(NOW(), INTERVAL 4 DAY)),
(910000000007008, 910000000001004, -1612.00, 'CONSUME', 988.00, DATE_SUB(NOW(), INTERVAL 3 DAY))
ON DUPLICATE KEY UPDATE
amount = VALUES(amount),
type = VALUES(type),
current_balance = VALUES(current_balance),
change_time = VALUES(change_time);
INSERT INTO t_product (id, shop_id, title, description, image_file_ids, price, tags, like_count, collect_count, approximate_duration, bookable_artists, available_coupons, create_time, update_time, is_delete)
VALUES
(910000000004001, 910000000000001, '验收凝胶美甲', '可由普通美甲师和参与制作店长预约服务。', '', 168.00, '验收,凝胶', 0, 0, '90 分钟', '910000000003001,910000000002002', '', NOW(), NOW(), 0),
(910000000004002, 910000000000001, '验收店长专属款', '用于验证参与制作店长的预约流程。', '', 268.00, '验收,店长', 0, 0, '120 分钟', '910000000002002', '', NOW(), NOW(), 0),
(910000000004003, 910000000000002, '验收分店护理', '用于验证跨店不可预约的分店商品。', '', 128.00, '验收,分店', 0, 0, '60 分钟', '910000000003002,910000000002003', '', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
shop_id = VALUES(shop_id),
title = VALUES(title),
description = VALUES(description),
price = VALUES(price),
tags = VALUES(tags),
approximate_duration = VALUES(approximate_duration),
bookable_artists = VALUES(bookable_artists),
is_delete = 0,
update_time = NOW();
INSERT INTO t_cart (user_id, product_id, quantity, create_time, update_time, is_delete)
VALUES (910000000001004, 910000000004001, 1, NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
quantity = VALUES(quantity),
is_delete = 0,
update_time = NOW();
INSERT INTO t_order (id, order_no, user_id, total_amount, actual_amount, coupon_id, status, create_time, update_time, is_delete)
SELECT 910000000005001, 'ACCEPTANCE-ORDER-001', 910000000001004, 168.00, 168.00, 0, 1, NOW(), NOW(), 0
WHERE NOT EXISTS (SELECT 1 FROM t_order WHERE order_no = 'ACCEPTANCE-ORDER-001');
INSERT INTO t_order_item (order_id, product_id, quantity, price, artist_id, create_time, update_time, is_delete)
SELECT 910000000005001, 910000000004001, 1, 168.00, 910000000002002, NOW(), NOW(), 0
WHERE EXISTS (SELECT 1 FROM t_order WHERE id = 910000000005001)
AND NOT EXISTS (SELECT 1 FROM t_order_item WHERE order_id = 910000000005001 AND product_id = 910000000004001);
INSERT INTO t_system_message (id, title, content, publisher_id, publisher_name, publisher_type, target_type, target_ids, popup_enabled, status, publish_time, create_time, update_time, is_delete)
VALUES
(910000000006001, '平台验收通知', '这是一条面向当前和后续新增用户的平台通知。', 910000000001001, '验收管理员', 4, 'PLATFORM_ALL', '', 1, 1, NOW(), NOW(), NOW(), 0),
(910000000006002, '本店验收通知', '这是一条面向本店动态用户范围的店铺通知。', 910000000002002, '参与制作店长', 2, 'CURRENT_SHOP_ALL', '910000000000001', 1, 1, NOW(), NOW(), NOW(), 0),
(910000000006003, '指定用户验收通知', '这是一条仅指定用户可见的通知。', 910000000002002, '参与制作店长', 2, 'SELECTED_USERS', '910000000001004', 1, 1, NOW(), NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
title = VALUES(title),
content = VALUES(content),
publisher_id = VALUES(publisher_id),
publisher_name = VALUES(publisher_name),
publisher_type = VALUES(publisher_type),
target_type = VALUES(target_type),
target_ids = VALUES(target_ids),
popup_enabled = VALUES(popup_enabled),
status = VALUES(status),
is_delete = 0,
update_time = NOW();
INSERT INTO t_system_message_user_state (message_id, user_id, popup_shown, read_status, popup_time, read_time, create_time, update_time, is_delete)
VALUES
(910000000006001, 910000000001001, 1, 1, DATE_SUB(NOW(), INTERVAL 1 DAY), DATE_SUB(NOW(), INTERVAL 1 DAY), NOW(), NOW(), 0),
(910000000006002, 910000000001002, 1, 0, DATE_SUB(NOW(), INTERVAL 2 HOUR), NULL, NOW(), NOW(), 0),
(910000000006003, 910000000001004, 0, 0, NULL, NULL, NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
popup_shown = VALUES(popup_shown),
read_status = VALUES(read_status),
popup_time = VALUES(popup_time),
read_time = VALUES(read_time),
is_delete = 0,
update_time = NOW();
-- 小型全覆盖抽检数据可在空库初始化后按需扩展:管理员、店长、美甲师、普通用户、VIP 等级、商品、余额流水均由本初始化文件统一承载。
-- ========================================
-- 雪花 ID 口径收口区:去掉运行时主键表的 AUTO_INCREMENT
-- 说明:
@@ -1331,6 +1725,43 @@ WHERE u.is_delete = 0
-- 3. 与 2026-03-30_snowflake_id_alignment_patch.sql 保持同口径
-- ========================================
INSERT INTO t_announcement (id, title, content, publisher_id, publisher_name, publisher_type, target_type, target_ids, status, sort_order, publish_time, create_time, update_time, is_delete)
VALUES
(910000000010001, '平台公告', '平台公告:欢迎体验首页滚动公告功能。', 910000000001001, '验收管理员', 4, 'PLATFORM_ALL', '', 1, 10, NOW(), NOW(), NOW(), 0),
(910000000010002, '本店公告', '本店公告:今日可预约店长参与制作服务。', 910000000002002, '参与制作店长', 2, 'CURRENT_SHOP_ALL', '910000000000001', 1, 20, NOW(), NOW(), NOW(), 0),
(910000000010003, '专属公告', '专属公告:这是指定用户可见的验收公告。', 910000000002002, '参与制作店长', 2, 'SELECTED_USERS', '910000000001004', 1, 30, NOW(), NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
title = VALUES(title),
content = VALUES(content),
publisher_id = VALUES(publisher_id),
publisher_name = VALUES(publisher_name),
publisher_type = VALUES(publisher_type),
target_type = VALUES(target_type),
target_ids = VALUES(target_ids),
status = VALUES(status),
sort_order = VALUES(sort_order),
is_delete = 0,
update_time = NOW();
INSERT INTO t_vip_recharge_plan (id, shop_id, title, recharge_amount, gift_amount, vip_level, description, sort_order, status, create_time, update_time, is_delete)
VALUES
(910000000011001, 910000000000001, '充100送10', 100.00, 10.00, '青铜VIP', '适合轻量体验用户,仅展示不发起支付。', 10, 1, NOW(), NOW(), 0),
(910000000011002, 910000000000001, '充500送80', 500.00, 80.00, '白银VIP', '适合常规护理用户,仅展示不发起支付。', 20, 1, NOW(), NOW(), 0),
(910000000011003, 910000000000001, '充1000送200', 1000.00, 200.00, '黄金VIP', '适合高频预约用户,仅展示不发起支付。', 30, 1, NOW(), NOW(), 0),
(910000000011004, 910000000000002, '分店充100送10', 100.00, 10.00, '青铜VIP', '分店验收充值档位。', 10, 1, NOW(), NOW(), 0),
(910000000011005, 910000000000002, '分店充500送80', 500.00, 80.00, '白银VIP', '分店验收充值档位。', 20, 1, NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
shop_id = VALUES(shop_id),
title = VALUES(title),
recharge_amount = VALUES(recharge_amount),
gift_amount = VALUES(gift_amount),
vip_level = VALUES(vip_level),
description = VALUES(description),
sort_order = VALUES(sort_order),
status = VALUES(status),
is_delete = 0,
update_time = NOW();
DROP PROCEDURE IF EXISTS sp_drop_auto_increment_on_id_if_exists;
DELIMITER $$
@@ -1393,5 +1824,267 @@ CALL sp_drop_auto_increment_on_id_if_exists('t_vip_benefit');
CALL sp_drop_auto_increment_on_id_if_exists('t_vip_info');
CALL sp_drop_auto_increment_on_id_if_exists('t_wishlist');
CALL sp_drop_auto_increment_on_id_if_exists('t_user_shop_binding');
CALL sp_drop_auto_increment_on_id_if_exists('t_system_message');
CALL sp_drop_auto_increment_on_id_if_exists('t_system_message_user_state');
CALL sp_drop_auto_increment_on_id_if_exists('t_announcement');
CALL sp_drop_auto_increment_on_id_if_exists('t_vip_recharge_plan');
DROP PROCEDURE IF EXISTS sp_drop_auto_increment_on_id_if_exists;
CREATE TABLE IF NOT EXISTS t_shop_role (
id BIGINT UNSIGNED NOT NULL COMMENT '店铺角色ID' PRIMARY KEY,
shop_id BIGINT UNSIGNED NOT NULL COMMENT '店铺ID',
role_name VARCHAR(100) NOT NULL COMMENT '角色名称',
creator_id BIGINT UNSIGNED NULL COMMENT '创建人',
status TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态',
remark VARCHAR(255) NULL COMMENT '备注',
sort_order INT NOT NULL DEFAULT 0 COMMENT '排序',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
is_delete TINYINT UNSIGNED DEFAULT 0 COMMENT '逻辑删除'
) COMMENT='店铺自定义角色表';
CREATE TABLE IF NOT EXISTS t_shop_role_permission (
id BIGINT UNSIGNED NOT NULL COMMENT '主键' PRIMARY KEY,
role_id BIGINT UNSIGNED NOT NULL COMMENT '角色ID',
permission_id BIGINT UNSIGNED NOT NULL COMMENT '权限ID',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
is_delete TINYINT UNSIGNED DEFAULT 0
) COMMENT='店铺角色权限关联表';
CREATE TABLE IF NOT EXISTS t_user_shop_role (
id BIGINT UNSIGNED NOT NULL COMMENT '主键' PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL COMMENT '用户ID',
shop_id BIGINT UNSIGNED NOT NULL COMMENT '店铺ID',
role_id BIGINT UNSIGNED NOT NULL COMMENT '角色ID',
status TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
is_delete TINYINT UNSIGNED DEFAULT 0
) COMMENT='用户店铺角色绑定表';
CREATE TABLE IF NOT EXISTS t_user_relation (
id BIGINT UNSIGNED NOT NULL COMMENT '主键' PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL COMMENT '用户ID',
shop_id BIGINT UNSIGNED NULL COMMENT '店铺ID',
parent_user_id BIGINT UNSIGNED NULL COMMENT '直属上级用户ID',
parent_role_type INT NULL COMMENT '上级身份类型',
source_type VARCHAR(32) NULL COMMENT '来源类型',
creator_id BIGINT UNSIGNED NULL COMMENT '创建人',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
is_delete TINYINT UNSIGNED DEFAULT 0
) COMMENT='用户归属关系表';
CREATE TABLE IF NOT EXISTS t_user_invite_code (
id BIGINT UNSIGNED NOT NULL COMMENT '主键' PRIMARY KEY,
invite_code VARCHAR(64) NOT NULL COMMENT '邀请码',
owner_user_id BIGINT UNSIGNED NOT NULL COMMENT '所属人',
shop_id BIGINT UNSIGNED NOT NULL COMMENT '店铺ID',
status TINYINT UNSIGNED NOT NULL DEFAULT 1 COMMENT '状态',
use_count INT NOT NULL DEFAULT 0 COMMENT '使用次数',
expire_time DATETIME NULL COMMENT '过期时间',
create_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
update_time DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP,
is_delete TINYINT UNSIGNED DEFAULT 0,
UNIQUE KEY uk_invite_code (invite_code)
) COMMENT='邀请码表';
-- Indexes are created by the corresponding migration path in environments that need them.
-- Existing databases already have these indexes, and MySQL 5.7 does not support CREATE INDEX IF NOT EXISTS.
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
VALUES
(313931273555136490, 'messagehub:config:manage', '管理MessageHub配置', '消息配置', '管理YumiNail投递MessageHub的场景级对接参数', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
description = VALUES(description),
is_delete = 0,
update_time = NOW();
INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by, update_by, is_delete)
SELECT u.id, p.id, NOW(), NOW(), u.id, u.id, 0
FROM t_user u
INNER JOIN t_permission p
ON p.is_delete = 0
AND p.permission_code = 'messagehub:config:manage'
WHERE u.is_delete = 0
AND u.type = 4
AND NOT EXISTS (
SELECT 1
FROM t_user_permission up
WHERE up.user_id = u.id
AND up.permission_id = p.id
AND up.is_delete = 0
);
INSERT INTO t_messagehub_push_config (
id,
scene_code,
scene_name,
platform,
msg_type,
queue_name,
source_system,
template_code,
channel_id,
send_method,
enabled,
remark,
create_time,
update_time,
is_delete
)
VALUES
(313931273555137001, 'USER_REGISTER_SMS_CODE', '用户注册验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '注册功能发送验证码时使用', NOW(), NOW(), 0),
(313931273555137002, 'USER_LOGIN_SMS_CODE', '手机号登录验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '手机号验证码登录时使用', NOW(), NOW(), 0),
(313931273555137003, 'USER_RESET_PASSWORD_SMS_CODE', '找回密码验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '找回密码时使用', NOW(), NOW(), 0),
(313931273555137004, 'USER_BIND_PHONE_SMS_CODE', '绑定手机号验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '绑定手机号时使用', NOW(), NOW(), 0),
(313931273555137005, 'USER_CHANGE_PHONE_SMS_CODE', '修改手机号验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '修改手机号时使用', NOW(), NOW(), 0),
(313931273555137006, 'USER_CHANGE_PASSWORD_SMS_CODE', '修改密码验证码', 'SMS', 'VERIFICATION', 'smsQueue', 'yuminail', 'SPUG0001', NULL, 'SPUG', 1, '修改密码时使用', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
scene_name = VALUES(scene_name),
platform = VALUES(platform),
msg_type = VALUES(msg_type),
queue_name = VALUES(queue_name),
source_system = VALUES(source_system),
template_code = VALUES(template_code),
channel_id = VALUES(channel_id),
send_method = VALUES(send_method),
enabled = VALUES(enabled),
remark = VALUES(remark),
is_delete = 0,
update_time = NOW();
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
VALUES
(313931273555136501, 'role:view', '查看店铺角色', '角色管理', '查看店铺自定义角色', NOW(), NOW(), 0),
(313931273555136502, 'role:create', '新增店铺角色', '角色管理', '创建店铺自定义角色', NOW(), NOW(), 0),
(313931273555136503, 'role:edit', '编辑店铺角色', '角色管理', '编辑角色权限和绑定员工', NOW(), NOW(), 0),
(313931273555136504, 'role:delete', '删除店铺角色', '角色管理', '删除店铺自定义角色', NOW(), NOW(), 0),
(313931273555136505, 'user:relation:view', '查看用户所属', '用户管理', '查看用户归属关系', NOW(), NOW(), 0),
(313931273555136506, 'user:relation:edit', '编辑用户所属', '用户管理', '调整用户店铺和直属上级', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
id = VALUES(id),
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
description = VALUES(description),
is_delete = 0,
update_time = NOW();
-- 2026-05-18 协议管理、用户协议同意记录与安全审计日志
CREATE TABLE IF NOT EXISTS t_legal_agreement (
id bigint NOT NULL COMMENT '协议ID',
agreement_type varchar(32) NOT NULL COMMENT '协议类型:USER_TERMS/PRIVACY_POLICY',
title varchar(100) NOT NULL COMMENT '协议标题',
version varchar(32) NOT NULL COMMENT '协议版本号',
content longtext NOT NULL COMMENT '协议正文',
status tinyint NOT NULL DEFAULT 0 COMMENT '状态:0草稿/停用,1已发布启用',
effective_time datetime NULL COMMENT '生效时间',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除:0否,1是',
PRIMARY KEY (id),
UNIQUE KEY uk_legal_agreement_type_version (agreement_type, version, is_delete),
KEY idx_legal_agreement_current (agreement_type, status, effective_time, is_delete)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户协议与隐私政策';
CREATE TABLE IF NOT EXISTS t_user_agreement_consent (
id bigint NOT NULL COMMENT '同意记录ID',
user_id bigint NOT NULL COMMENT '用户ID',
agreement_type varchar(32) NOT NULL COMMENT '协议类型',
version varchar(32) NOT NULL COMMENT '同意版本号',
entry varchar(64) NULL COMMENT '同意入口:login/register/phone-login/wechat-mini',
client_type varchar(32) NULL COMMENT '客户端类型:WEB/WECHAT_MINI',
ip_address varchar(64) NULL COMMENT '同意IP',
device_id varchar(128) NULL COMMENT '设备ID',
consent_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '同意时间',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (id),
UNIQUE KEY uk_user_agreement_consent (user_id, agreement_type, version),
KEY idx_user_agreement_user (user_id, agreement_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户协议同意记录';
CREATE TABLE IF NOT EXISTS t_security_audit_log (
id bigint NOT NULL COMMENT '审计日志ID',
user_id bigint NULL COMMENT '操作用户ID',
account varchar(100) NULL COMMENT '操作账号',
action varchar(64) NOT NULL COMMENT '安全动作',
result varchar(32) NOT NULL COMMENT '结果:SUCCESS/FAIL',
reason varchar(255) NULL COMMENT '失败或补充原因',
ip_address varchar(64) NULL COMMENT '请求IP',
device_id varchar(128) NULL COMMENT '设备ID',
operate_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (id),
KEY idx_security_audit_action_time (action, operate_time),
KEY idx_security_audit_account_time (account, operate_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='安全审计日志';
CREATE TABLE IF NOT EXISTS t_system_parameter_config (
id bigint NOT NULL COMMENT '配置ID',
config_group varchar(50) NOT NULL COMMENT '配置分组',
config_key varchar(100) NOT NULL COMMENT '配置键',
config_name varchar(100) NOT NULL COMMENT '配置名称',
config_value varchar(1000) NULL COMMENT '配置值',
enabled tinyint NOT NULL DEFAULT 1 COMMENT '是否启用:1启用,0停用',
remark varchar(255) NULL COMMENT '备注',
create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
is_delete tinyint NOT NULL DEFAULT 0 COMMENT '逻辑删除:0否,1是',
PRIMARY KEY (id),
UNIQUE KEY uk_system_parameter_group_key (config_group, config_key, is_delete)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统参数配置';
INSERT INTO t_legal_agreement (id, agreement_type, title, version, content, status, effective_time, create_time, update_time, is_delete)
VALUES
(313931273555138001, 'USER_TERMS', '用户协议', '2026.05.18', '欢迎使用 YumiNail。请在使用账号、预约、订单、会员、消息等功能前仔细阅读本协议。继续登录或注册即表示你已理解并同意平台基础服务规则、账号安全要求、订单预约规则和依法合规使用要求。', 1, NOW(), NOW(), NOW(), 0),
(313931273555138002, 'PRIVACY_POLICY', '隐私政策', '2026.05.18', 'YumiNail 会在提供登录注册、预约下单、会员余额、消息通知和客户服务时处理必要的手机号、昵称、门店归属、订单与设备信息。我们仅在业务需要和法律允许范围内使用这些信息,并采取访问控制、脱敏展示和审计记录等措施保护数据安全。', 1, NOW(), NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
title = VALUES(title),
content = VALUES(content),
status = VALUES(status),
effective_time = VALUES(effective_time),
is_delete = 0,
update_time = NOW();
INSERT INTO t_permission (id, permission_code, permission_name, permission_group, description, create_time, update_time, is_delete)
VALUES
(313931273555136601, 'legal_agreement:manage', '协议管理', '安全管理', '管理用户协议和隐私政策版本', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
permission_name = VALUES(permission_name),
permission_group = VALUES(permission_group),
description = VALUES(description),
is_delete = 0,
update_time = NOW();
INSERT INTO t_user_permission (user_id, permission_id, create_time, update_time, create_by, update_by, is_delete)
SELECT u.id, p.id, NOW(), NOW(), u.id, u.id, 0
FROM t_user u
INNER JOIN t_permission p
ON p.is_delete = 0
AND p.permission_code = 'legal_agreement:manage'
WHERE u.is_delete = 0
AND u.type = 4
AND NOT EXISTS (
SELECT 1
FROM t_user_permission up
WHERE up.user_id = u.id
AND up.permission_id = p.id
AND up.is_delete = 0
);
INSERT INTO t_system_parameter_config (
id, config_group, config_key, config_name, config_value, enabled, remark, create_time, update_time, is_delete
)
VALUES
(313931273555139001, 'MAP', 'TENCENT_MAP_KEY', '腾讯位置服务 Key', '', 0, '用于后台店铺选点和腾讯地图展示;请在后台参数管理中填入真实 Key 后启用', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
config_name = VALUES(config_name),
remark = VALUES(remark),
is_delete = 0,
update_time = NOW();