mall.sql 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. Navicat Premium Data Transfer
  3. Source Server : 127.0.0.1
  4. Source Server Type : MySQL
  5. Source Server Version : 80026
  6. Source Host : localhost:3306
  7. Source Schema : ruoyi-vue-pro
  8. Target Server Type : MySQL
  9. Target Server Version : 80026
  10. File Encoding : 65001
  11. Date: 05/02/2022 00:50:30
  12. */
  13. SET
  14. FOREIGN_KEY_CHECKS = 0;
  15. SET NAMES utf8mb4;
  16. -- ----------------------------
  17. -- Table structure for product_category
  18. -- ----------------------------
  19. -- ----------------------------
  20. -- Table structure for product_brand
  21. -- ----------------------------
  22. DROP TABLE IF EXISTS `product_brand`;
  23. CREATE TABLE `product_brand`
  24. (
  25. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '品牌编号',
  26. `category_id` bigint NOT NULL COMMENT '分类编号',
  27. `name` varchar(255) NOT NULL COMMENT '品牌名称',
  28. `banner_url` varchar(255) NOT NULL COMMENT '品牌图片',
  29. `sort` int DEFAULT '0' COMMENT '品牌排序',
  30. `description` varchar(1024) DEFAULT NULL COMMENT '品牌描述',
  31. `status` tinyint NOT NULL COMMENT '状态',
  32. `creator` varchar(64) DEFAULT '' COMMENT '创建者',
  33. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  34. `updater` varchar(64) DEFAULT '' COMMENT '更新者',
  35. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  36. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  37. `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  38. PRIMARY KEY (`id`) USING BTREE
  39. ) ENGINE=InnoDB COMMENT='品牌';
  40. -- TODO 父级菜单的 id 处理: 2000 、 2001
  41. INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  42. VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0);
  43. INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  44. VALUES (2001, '商品', '', 1, 1, 2000, 'product', 'dict', NULL, 0);
  45. -- 商品分类 菜单 SQL
  46. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  47. VALUES ('分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/index', 0);
  48. -- 按钮父菜单ID
  49. SELECT @parentId := LAST_INSERT_ID();
  50. -- 按钮 SQL
  51. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  52. VALUES ('分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0);
  53. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  54. VALUES ('分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0);
  55. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  56. VALUES ('分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0);
  57. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  58. VALUES ('分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0);
  59. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  60. VALUES ('分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0);
  61. -- 品牌管理 菜单 SQL
  62. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  63. VALUES ('品牌管理', '', 2, 1, 2001, 'brand', '', 'mall/product/brand/index', 0);
  64. -- 按钮父菜单ID
  65. SELECT @parentId := LAST_INSERT_ID();
  66. -- 按钮 SQL
  67. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  68. VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0);
  69. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  70. VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0);
  71. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  72. VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0);
  73. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  74. VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0);
  75. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  76. VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0);
  77. -- ----------------------------
  78. -- Table structure for market_activity
  79. -- ----------------------------
  80. DROP TABLE IF EXISTS `market_activity`;
  81. CREATE TABLE `market_activity`
  82. (
  83. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '活动编号',
  84. `title` varchar(50) NOT NULL DEFAULT '' COMMENT '活动标题',
  85. `activity_type` tinyint(4) NOT NULL COMMENT '活动类型',
  86. `status` tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态',
  87. `start_time` datetime NOT NULL COMMENT '开始时间',
  88. `end_time` datetime NOT NULL COMMENT '结束时间',
  89. `invalid_time` datetime DEFAULT NULL COMMENT '失效时间',
  90. `delete_time` datetime DEFAULT NULL COMMENT '删除时间',
  91. `time_limited_discount` varchar(2000) DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
  92. `full_privilege` varchar(2000) DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
  93. `creator` varchar(64) DEFAULT '' COMMENT '创建者',
  94. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  95. `updater` varchar(64) DEFAULT '' COMMENT '更新者',
  96. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  97. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  98. `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  99. PRIMARY KEY (`id`) USING BTREE
  100. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='促销活动';
  101. -- 规格菜单 SQL
  102. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  103. VALUES ('规格管理', '', 2, 3, 2001, 'property', '', 'mall/product/property/index', 0);
  104. -- 按钮父菜单ID
  105. SELECT @parentId := LAST_INSERT_ID();
  106. -- 按钮 SQL
  107. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  108. VALUES ('规格查询', 'product:property:query', 3, 1, @parentId, '', '', '', 0);
  109. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  110. VALUES ('规格创建', 'product:property:create', 3, 2, @parentId, '', '', '', 0);
  111. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  112. VALUES ('规格更新', 'product:property:update', 3, 3, @parentId, '', '', '', 0);
  113. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  114. VALUES ('规格删除', 'product:property:delete', 3, 4, @parentId, '', '', '', 0);
  115. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  116. VALUES ('规格导出', 'product:property:export', 3, 5, @parentId, '', '', '', 0);
  117. -- 商品菜单 SQL
  118. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  119. VALUES ('商品管理', '', 2, 2, 2001, 'spu', '', 'mall/product/spu/index', 0);
  120. -- 按钮父菜单ID
  121. SELECT @parentId := LAST_INSERT_ID();
  122. -- 按钮 SQL
  123. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  124. VALUES ('商品查询', 'product:spu:query', 3, 1, @parentId, '', '', '', 0);
  125. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  126. VALUES ('商品创建', 'product:spu:create', 3, 2, @parentId, '', '', '', 0);
  127. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  128. VALUES ('商品更新', 'product:spu:update', 3, 3, @parentId, '', '', '', 0);
  129. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  130. VALUES ('商品删除', 'product:spu:delete', 3, 4, @parentId, '', '', '', 0);
  131. INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status)
  132. VALUES ('商品导出', 'product:spu:export', 3, 5, @parentId, '', '', '', 0);
  133. -- 规格名称表
  134. drop table if exists product_property;
  135. create table product_property
  136. (
  137. id bigint NOT NULL AUTO_INCREMENT comment '主键',
  138. name varchar(64) comment '规格名称',
  139. status tinyint comment '状态: 0 开启 ,1 禁用',
  140. create_time datetime default current_timestamp comment '创建时间',
  141. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  142. creator varchar(64) comment '创建人',
  143. updater varchar(64) comment '更新人',
  144. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  145. deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  146. primary key (id),
  147. key idx_name ( name (32)) comment '规格名称索引'
  148. ) comment '规格名称' character set utf8mb4
  149. collate utf8mb4_general_ci;
  150. -- 规格值表
  151. drop table if exists product_property_value;
  152. create table product_property_value
  153. (
  154. id bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  155. property_id bigint comment '规格键id',
  156. name varchar(128) comment '规格值名字',
  157. status tinyint comment '状态: 1 开启 ,2 禁用',
  158. create_time datetime default current_timestamp comment '创建时间',
  159. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  160. creator varchar(64) comment '创建人',
  161. updater varchar(64) comment '更新人',
  162. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  163. deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  164. primary key (id)
  165. ) comment '规格值' character set utf8mb4
  166. collate utf8mb4_general_ci;
  167. -- spu
  168. drop table if exists product_spu;
  169. create table product_spu
  170. (
  171. id bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  172. name varchar(128) comment '商品名称',
  173. sell_point varchar(128) not null comment '卖点',
  174. description text not null comment '描述',
  175. category_id bigint not null comment '分类id',
  176. pic_urls varchar(1024) not null default '' comment '商品主图地址\n *\n * 数组,以逗号分隔\n 最多上传15张',
  177. sort int not null default 0 comment '排序字段',
  178. like_count int comment '点赞初始人数',
  179. price int comment '价格 单位使用:分',
  180. quantity int comment '库存数量',
  181. status bit(1) comment '上下架状态: 0 上架(开启) 1 下架(禁用)',
  182. create_time datetime default current_timestamp comment '创建时间',
  183. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  184. creator varchar(64) comment '创建人',
  185. updater varchar(64) comment '更新人',
  186. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  187. deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  188. primary key (id)
  189. ) comment '商品spu' character set utf8mb4
  190. collate utf8mb4_general_ci;
  191. -- sku
  192. drop table if exists product_sku;
  193. create table product_sku
  194. (
  195. id bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  196. spu_id bigint not null comment 'spu编号',
  197. properties varchar(64) not null comment '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]',
  198. price int not null DEFAULT -1 comment '销售价格,单位:分',
  199. original_price int not null DEFAULT -1 comment '原价, 单位: 分',
  200. cost_price int not null DEFAULT -1 comment '成本价,单位: 分',
  201. bar_code varchar(64) not null comment '条形码',
  202. pic_url VARCHAR(128) not null comment '图片地址',
  203. status tinyint comment '状态: 0-正常 1-禁用',
  204. create_time datetime default current_timestamp comment '创建时间',
  205. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  206. creator varchar(64) comment '创建人',
  207. updater varchar(64) comment '更新人',
  208. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  209. deleted bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  210. primary key (id)
  211. ) comment '商品sku' character set utf8mb4
  212. collate utf8mb4_general_ci;
  213. ---Market-Banner管理SQL
  214. drop table if exists market_banner;
  215. CREATE TABLE `market_banner` (
  216. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'Banner编号',
  217. `title` varchar(64) NOT NULL DEFAULT '' COMMENT 'Banner标题',
  218. `pic_url` varchar(255) NOT NULL COMMENT '图片URL',
  219. `status` tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态',
  220. `url` varchar(255) NOT NULL COMMENT '跳转地址',
  221. `creator` varchar(64) DEFAULT '' COMMENT '创建者',
  222. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  223. `updater` varchar(64) DEFAULT '' COMMENT '更新者',
  224. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  225. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  226. `tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
  227. `sort` tinyint(4) DEFAULT NULL COMMENT '排序',
  228. `memo` varchar(255) DEFAULT NULL COMMENT '描述',
  229. PRIMARY KEY (`id`) USING BTREE
  230. ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COMMENT='Banner管理';
  231. -- 菜单 SQL
  232. INSERT INTO `system_menu`(`id`,`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  233. VALUES (2002, 'Banner管理', '', 2, 1, 2000, 'brand', '', 'mall/market/banner/index', 0);
  234. -- 按钮父菜单ID
  235. SELECT @parentId := LAST_INSERT_ID();
  236. -- 按钮 SQL
  237. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  238. VALUES ('Banner查询', 'market:banner:query', 3, 1, @parentId, '', '', '', 0);
  239. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  240. VALUES ('Banner创建', 'market:banner:create', 3, 2, @parentId, '', '', '', 0);
  241. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  242. VALUES ('Banner更新', 'market:banner:update', 3, 3, @parentId, '', '', '', 0);
  243. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`)
  244. VALUES ('Banner删除', 'market:banner:delete', 3, 4, @parentId, '', '', '', 0);