| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- -- 系统公告表
- CREATE TABLE IF NOT EXISTS `cy_message_announcements` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '公告ID',
- `title` varchar(255) NOT NULL COMMENT '公告标题',
- `content` text NOT NULL COMMENT '公告内容',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-普通公告,2-重要公告,3-紧急公告',
- `start_time` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
- `end_time` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
- `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
- `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统公告表';
- -- 用户通知表
- CREATE TABLE IF NOT EXISTS `cy_message_notifications` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '通知ID',
- `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID,0表示全部用户',
- `title` varchar(255) NOT NULL COMMENT '通知标题',
- `content` text NOT NULL COMMENT '通知内容',
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-系统通知,2-活动通知,3-订单通知,4-物流通知,5-其他',
- `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读:0-未读,1-已读',
- `read_time` int(11) NOT NULL DEFAULT '0' COMMENT '阅读时间',
- `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
- `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
- PRIMARY KEY (`id`),
- KEY `idx_user_id` (`user_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户通知表';
- -- 私信表
- CREATE TABLE IF NOT EXISTS `cy_message_privates` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '私信ID',
- `from_user_id` int(11) unsigned NOT NULL COMMENT '发送者用户ID,0表示系统',
- `to_user_id` int(11) unsigned NOT NULL COMMENT '接收者用户ID',
- `content` text NOT NULL COMMENT '私信内容',
- `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读:0-未读,1-已读',
- `read_time` int(11) NOT NULL DEFAULT '0' COMMENT '阅读时间',
- `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
- `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
- PRIMARY KEY (`id`),
- KEY `idx_from_user_id` (`from_user_id`),
- KEY `idx_to_user_id` (`to_user_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='私信表';
- -- 消息设置表
- CREATE TABLE IF NOT EXISTS `cy_message_settings` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '设置ID',
- `user_id` int(11) unsigned NOT NULL COMMENT '用户ID,0表示系统默认设置',
- `system_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '系统通知:0-关闭,1-开启',
- `activity_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '活动通知:0-关闭,1-开启',
- `order_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '订单通知:0-关闭,1-开启',
- `logistics_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '物流通知:0-关闭,1-开启',
- `private_message` tinyint(1) NOT NULL DEFAULT '1' COMMENT '私信:0-关闭,1-开启',
- `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
- PRIMARY KEY (`id`),
- UNIQUE KEY `idx_user_id` (`user_id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息设置表';
- -- 消息模板表
- CREATE TABLE IF NOT EXISTS `cy_message_templates` (
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '模板ID',
- `code` varchar(50) NOT NULL COMMENT '模板代码',
- `name` varchar(100) NOT NULL COMMENT '模板名称',
- `title` varchar(255) NOT NULL COMMENT '标题模板',
- `content` text NOT NULL COMMENT '内容模板',
- `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-系统通知,2-活动通知,3-订单通知,4-物流通知,5-私信,6-其他',
- `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
- `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
- PRIMARY KEY (`id`),
- UNIQUE KEY `idx_code` (`code`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息模板表';
- -- 插入默认消息模板数据
- INSERT INTO `cy_message_templates` (`code`, `name`, `title`, `content`, `type`, `status`, `create_time`, `update_time`) VALUES
- ('system_welcome', '欢迎注册', '欢迎加入{site_name}', '亲爱的{user_name},欢迎您加入{site_name},祝您购物愉快!', 1, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
- ('order_created', '订单创建', '您的订单已创建', '亲爱的{user_name},您的订单{order_no}已创建成功,请及时支付。', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
- ('order_paid', '订单支付', '您的订单已支付', '亲爱的{user_name},您的订单{order_no}已支付成功,我们将尽快为您发货。', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
- ('order_shipped', '订单发货', '您的订单已发货', '亲爱的{user_name},您的订单{order_no}已发货,物流单号:{tracking_no}。', 4, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
- ('order_completed', '订单完成', '您的订单已完成', '亲爱的{user_name},您的订单{order_no}已完成,感谢您的购买!', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
- -- 插入默认系统设置
- INSERT INTO `cy_message_settings` (`user_id`, `system_notify`, `activity_notify`, `order_notify`, `logistics_notify`, `private_message`, `create_time`, `update_time`) VALUES
- (0, 1, 1, 1, 1, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
|