mall.sql 16 KB

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