install.sql 5.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. -- 系统公告表
  2. CREATE TABLE IF NOT EXISTS `cy_message_announcements` (
  3. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '公告ID',
  4. `title` varchar(255) NOT NULL COMMENT '公告标题',
  5. `content` text NOT NULL COMMENT '公告内容',
  6. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
  7. `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-普通公告,2-重要公告,3-紧急公告',
  8. `start_time` int(11) NOT NULL DEFAULT '0' COMMENT '开始时间',
  9. `end_time` int(11) NOT NULL DEFAULT '0' COMMENT '结束时间',
  10. `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  11. `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
  12. `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  13. PRIMARY KEY (`id`)
  14. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统公告表';
  15. -- 用户通知表
  16. CREATE TABLE IF NOT EXISTS `cy_message_notifications` (
  17. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '通知ID',
  18. `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID,0表示全部用户',
  19. `title` varchar(255) NOT NULL COMMENT '通知标题',
  20. `content` text NOT NULL COMMENT '通知内容',
  21. `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-系统通知,2-活动通知,3-订单通知,4-物流通知,5-其他',
  22. `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读:0-未读,1-已读',
  23. `read_time` int(11) NOT NULL DEFAULT '0' COMMENT '阅读时间',
  24. `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  25. `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
  26. `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  27. PRIMARY KEY (`id`),
  28. KEY `idx_user_id` (`user_id`)
  29. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户通知表';
  30. -- 私信表
  31. CREATE TABLE IF NOT EXISTS `cy_message_privates` (
  32. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '私信ID',
  33. `from_user_id` int(11) unsigned NOT NULL COMMENT '发送者用户ID,0表示系统',
  34. `to_user_id` int(11) unsigned NOT NULL COMMENT '接收者用户ID',
  35. `content` text NOT NULL COMMENT '私信内容',
  36. `is_read` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已读:0-未读,1-已读',
  37. `read_time` int(11) NOT NULL DEFAULT '0' COMMENT '阅读时间',
  38. `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  39. `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
  40. `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
  41. PRIMARY KEY (`id`),
  42. KEY `idx_from_user_id` (`from_user_id`),
  43. KEY `idx_to_user_id` (`to_user_id`)
  44. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='私信表';
  45. -- 消息设置表
  46. CREATE TABLE IF NOT EXISTS `cy_message_settings` (
  47. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '设置ID',
  48. `user_id` int(11) unsigned NOT NULL COMMENT '用户ID,0表示系统默认设置',
  49. `system_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '系统通知:0-关闭,1-开启',
  50. `activity_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '活动通知:0-关闭,1-开启',
  51. `order_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '订单通知:0-关闭,1-开启',
  52. `logistics_notify` tinyint(1) NOT NULL DEFAULT '1' COMMENT '物流通知:0-关闭,1-开启',
  53. `private_message` tinyint(1) NOT NULL DEFAULT '1' COMMENT '私信:0-关闭,1-开启',
  54. `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  55. `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
  56. PRIMARY KEY (`id`),
  57. UNIQUE KEY `idx_user_id` (`user_id`)
  58. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息设置表';
  59. -- 消息模板表
  60. CREATE TABLE IF NOT EXISTS `cy_message_templates` (
  61. `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '模板ID',
  62. `code` varchar(50) NOT NULL COMMENT '模板代码',
  63. `name` varchar(100) NOT NULL COMMENT '模板名称',
  64. `title` varchar(255) NOT NULL COMMENT '标题模板',
  65. `content` text NOT NULL COMMENT '内容模板',
  66. `type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '类型:1-系统通知,2-活动通知,3-订单通知,4-物流通知,5-私信,6-其他',
  67. `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态:0-禁用,1-启用',
  68. `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
  69. `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
  70. PRIMARY KEY (`id`),
  71. UNIQUE KEY `idx_code` (`code`)
  72. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息模板表';
  73. -- 插入默认消息模板数据
  74. INSERT INTO `cy_message_templates` (`code`, `name`, `title`, `content`, `type`, `status`, `create_time`, `update_time`) VALUES
  75. ('system_welcome', '欢迎注册', '欢迎加入{site_name}', '亲爱的{user_name},欢迎您加入{site_name},祝您购物愉快!', 1, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
  76. ('order_created', '订单创建', '您的订单已创建', '亲爱的{user_name},您的订单{order_no}已创建成功,请及时支付。', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
  77. ('order_paid', '订单支付', '您的订单已支付', '亲爱的{user_name},您的订单{order_no}已支付成功,我们将尽快为您发货。', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
  78. ('order_shipped', '订单发货', '您的订单已发货', '亲爱的{user_name},您的订单{order_no}已发货,物流单号:{tracking_no}。', 4, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()),
  79. ('order_completed', '订单完成', '您的订单已完成', '亲爱的{user_name},您的订单{order_no}已完成,感谢您的购买!', 3, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());
  80. -- 插入默认系统设置
  81. INSERT INTO `cy_message_settings` (`user_id`, `system_notify`, `activity_notify`, `order_notify`, `logistics_notify`, `private_message`, `create_time`, `update_time`) VALUES
  82. (0, 1, 1, 1, 1, 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());