mall.sql 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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`) VALUES (2000, '商城', '', 1, 1, 0, '/mall', 'merchant', NULL, 0);
  61. INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES (2001, '商品管理', '', 1, 1, 2000, 'product', 'dict', NULL, 0);
  62. -- 商品分类 菜单 SQL
  63. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类管理', '', 2, 0, 2001, 'category', '', 'mall/product/category/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`) VALUES ('商品分类查询', 'product:category:query', 3, 1, @parentId, '', '', '', 0);
  68. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类创建', 'product:category:create', 3, 2, @parentId, '', '', '', 0);
  69. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类更新', 'product:category:update', 3, 3, @parentId, '', '', '', 0);
  70. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类删除', 'product:category:delete', 3, 4, @parentId, '', '', '', 0);
  71. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('商品分类导出', 'product:category:export', 3, 5, @parentId, '', '', '', 0);
  72. -- 品牌管理 菜单 SQL
  73. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌管理', '', 2, 0, 2001, 'brand', '', 'mall/product/brand/index', 0);
  74. -- 按钮父菜单ID
  75. SELECT @parentId := LAST_INSERT_ID();
  76. -- 按钮 SQL
  77. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌查询', 'product:brand:query', 3, 1, @parentId, '', '', '', 0);
  78. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌创建', 'product:brand:create', 3, 2, @parentId, '', '', '', 0);
  79. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌更新', 'product:brand:update', 3, 3, @parentId, '', '', '', 0);
  80. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌删除', 'product:brand:delete', 3, 4, @parentId, '', '', '', 0);
  81. INSERT INTO `system_menu`(`name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`) VALUES ('品牌导出', 'product:brand:export', 3, 5, @parentId, '', '', '', 0);
  82. -- ----------------------------
  83. -- Table structure for market_activity
  84. -- ----------------------------
  85. DROP TABLE IF EXISTS `market_activity`;
  86. CREATE TABLE `market_activity` (
  87. `id` bigint NOT NULL AUTO_INCREMENT COMMENT '活动编号',
  88. `title` varchar(50) NOT NULL DEFAULT '' COMMENT '活动标题',
  89. `activity_type` tinyint(4) NOT NULL COMMENT '活动类型',
  90. `status` tinyint(4) NOT NULL DEFAULT '-1' COMMENT '活动状态',
  91. `start_time` datetime NOT NULL COMMENT '开始时间',
  92. `end_time` datetime NOT NULL COMMENT '结束时间',
  93. `invalid_time` datetime DEFAULT NULL COMMENT '失效时间',
  94. `delete_time` datetime DEFAULT NULL COMMENT '删除时间',
  95. `time_limited_discount` varchar(2000) DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
  96. `full_privilege` varchar(2000) DEFAULT NULL COMMENT '限制折扣字符串,使用 JSON 序列化成字符串存储',
  97. `creator` varchar(64) DEFAULT '' COMMENT '创建者',
  98. `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  99. `updater` varchar(64) DEFAULT '' COMMENT '更新者',
  100. `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  101. `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  102. `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  103. PRIMARY KEY (`id`) USING BTREE
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='促销活动';
  105. -- 规格名称表
  106. drop table if exists product_property;
  107. create table product_property
  108. (
  109. id bigint comment '主键',
  110. name varchar(64) comment '规格名称',
  111. status tinyint comment '状态: 0 开启 ,1 禁用',
  112. create_time datetime default current_timestamp comment '创建时间',
  113. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  114. creator varchar(64) comment '创建人',
  115. updater varchar(64) comment '更新人',
  116. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  117. deleted bit(1) comment '状态',
  118. primary key (id),
  119. key idx_name (name(32)) comment '规格名称索引'
  120. ) comment '规格名称' character set utf8mb4
  121. collate utf8mb4_general_ci;
  122. -- 规格值表
  123. drop table if exists product_property_value;
  124. create table product_property_value
  125. (
  126. id int comment '主键',
  127. property_id bigint comment '规格键id',
  128. name varchar(128) comment '规格值名字',
  129. status tinyint comment '状态: 1 开启 ,2 禁用',
  130. create_time datetime default current_timestamp comment '创建时间',
  131. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  132. creator varchar(64) comment '创建人',
  133. updater varchar(64) comment '更新人',
  134. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  135. deleted bit(1) comment '状态',
  136. primary key (id)
  137. ) comment '规格值' character set utf8mb4
  138. collate utf8mb4_general_ci;
  139. -- spu
  140. drop table if exists product_spu;
  141. create table product_spu
  142. (
  143. id int comment '主键',
  144. name varchar(128) comment '商品名称',
  145. sell_point varchar(128) not null comment '卖点',
  146. description text not null comment '描述',
  147. category_id bigint not null comment '分类id',
  148. pic_urls varchar(1024) not null default '' comment '商品主图地址\n *\n * 数组,以逗号分隔\n 最多上传15张',
  149. sort int not null default 0 comment '排序字段',
  150. like_count int comment '点赞初始人数',
  151. price int comment '价格 单位使用:分',
  152. quantity int comment '库存数量',
  153. status bit(1) comment '上下架状态: 0 上架(开启) 1 下架(禁用)',
  154. create_time datetime default current_timestamp comment '创建时间',
  155. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  156. creator varchar(64) comment '创建人',
  157. updater varchar(64) comment '更新人',
  158. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  159. deleted bit(1) comment '状态',
  160. primary key (id)
  161. ) comment '商品spu' character set utf8mb4
  162. collate utf8mb4_general_ci;
  163. -- sku
  164. drop table if exists product_sku;
  165. create table product_sku
  166. (
  167. id int comment '主键',
  168. spu_id bigint not null comment 'spu编号',
  169. properties varchar(64) not null comment '规格值数组-json格式, [{propertId: , valueId: }, {propertId: , valueId: }]',
  170. price int not null DEFAULT -1 comment '销售价格,单位:分',
  171. original_price int not null DEFAULT -1 comment '原价, 单位: 分',
  172. cost_price int not null DEFAULT -1 comment '成本价,单位: 分',
  173. bar_code varchar(64) not null comment '条形码',
  174. pic_url VARCHAR(128) not null comment '图片地址',
  175. status tinyint comment '状态: 0-正常 1-禁用',
  176. create_time datetime default current_timestamp comment '创建时间',
  177. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  178. creator varchar(64) comment '创建人',
  179. updater varchar(64) comment '更新人',
  180. tenant_id bigint NOT NULL DEFAULT '0' COMMENT '租户编号',
  181. deleted bit(1) comment '状态',
  182. primary key (id)
  183. ) comment '商品sku' character set utf8mb4
  184. collate utf8mb4_general_ci;