Files
MES/yawei-mes/.sql/2026-03-12_v2.0.008_周启威_到期续费功能.sql
2026-04-02 10:39:03 +08:00

68 lines
3.8 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.

-- =============================================
-- MES系统授权续费功能数据库脚本
-- 版本: v2.0.008
-- 作者: 周启威
-- 日期: 2026-03-12
-- 说明: 系统到期提醒和续费管理功能
-- =============================================
-- =============================================
-- 1. 系统授权配置表
-- =============================================
CREATE TABLE `sys_license_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`expire_date` datetime NOT NULL COMMENT '系统到期时间',
`contact_email` varchar(100) DEFAULT NULL COMMENT '联系邮箱',
`contact_phone` varchar(50) DEFAULT NULL COMMENT '联系电话',
`create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统授权配置表';
-- 初始化数据默认到期时间为1年后
INSERT INTO `sys_license_config` (`expire_date`, `contact_email`, `contact_phone`)
VALUES (DATE_ADD(NOW(), INTERVAL 1 YEAR), 'yavyjs@yav123.cn', '15727007467');
-- =============================================
-- 2. 续费记录表
-- =============================================
CREATE TABLE `sys_license_renewal` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`company_name` varchar(200) NOT NULL COMMENT '企业名称',
`previous_expire_date` datetime DEFAULT NULL COMMENT '续费前到期时间',
`expire_date` datetime NOT NULL COMMENT '续费后到期时间',
`operator` varchar(100) NOT NULL COMMENT '操作人',
`operate_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`id`),
KEY `idx_operate_time` (`operate_time`) COMMENT '操作时间索引'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='续费记录表';
-- =============================================
-- 3. 菜单权限配置
-- =============================================
-- 插入续费管理菜单父菜单为系统管理parent_id=1
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
VALUES ('续费管理', 1, 20, 'license', 'system/license/renewal', NULL, 1, 0, 'C', '0', '0', 'system:license:list', 'time-range', 'admin', NOW(), '', NULL, '续费管理菜单');
-- 获取最新插入的菜单ID
SET @menu_id = LAST_INSERT_ID();
-- 续费管理查询权限
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
VALUES ('续费查询', @menu_id, 1, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:license:query', '#', 'admin', NOW(), '', NULL, '');
-- 续费操作权限
INSERT INTO `sys_menu` (`menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`)
VALUES ('续费操作', @menu_id, 2, '#', '', NULL, 1, 0, 'F', '0', '0', 'system:license:add', '#', 'admin', NOW(), '', NULL, '');
-- =============================================
-- 说明
-- =============================================
-- 1. sys_license_config 表仅存储一条记录,用于全局配置
-- 2. sys_license_renewal 表记录每次续费操作的历史
-- 3. 续费操作会同时更新 sys_license_config 的 expire_date
-- 4. 索引优化operate_time 用于历史记录查询排序
-- 5. 菜单配置:续费管理菜单添加到系统管理模块下,仅管理员可访问