mall.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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_attr_key;
  107. create table product_attr_key
  108. (
  109. id int comment '主键',
  110. create_time datetime default current_timestamp comment '创建时间',
  111. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  112. creator varchar(64) comment '创建人',
  113. updater varchar(64) comment '更新人',
  114. deleted bit(1) comment '状态',
  115. attr_name varchar(64) comment '规格名称',
  116. status tinyint comment '状态: 1 开启 ,2 禁用',
  117. primary key (id),
  118. key idx_name (attr_name(32)) comment '规格名称索引'
  119. ) comment '规格名称' character set utf8mb4
  120. collate utf8mb4_general_ci;
  121. -- 规格值表
  122. drop table if exists product_attr_value;
  123. create table product_attr_value
  124. (
  125. id int comment '主键',
  126. create_time datetime default current_timestamp comment '创建时间',
  127. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  128. creator varchar(64) comment '创建人',
  129. updater varchar(64) comment '更新人',
  130. deleted bit(1) comment '状态',
  131. attr_key_id varchar(64) comment '规格键id',
  132. attr_value_name varchar(128) comment '规格值名字',
  133. status tinyint comment '状态: 1 开启 ,2 禁用',
  134. primary key (id)
  135. ) comment '规格值' character set utf8mb4
  136. collate utf8mb4_general_ci;
  137. -- spu
  138. drop table if exists product_spu;
  139. create table product_spu
  140. (
  141. id int comment '主键',
  142. create_time datetime default current_timestamp comment '创建时间',
  143. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  144. creator varchar(64) comment '创建人',
  145. updater varchar(64) comment '更新人',
  146. deleted bit(1) comment '状态',
  147. name varchar(128) comment '商品名称',
  148. visible bit(1) comment '上下架状态: true 上架,false 下架',
  149. sell_point varchar(128) not null comment '卖点',
  150. description text not null comment '描述',
  151. cid int not null comment '分类id',
  152. list_pic_url varchar(128) comment '列表图',
  153. pic_urls varchar(1024) not null default '' comment '商品主图地址, 数组,以逗号分隔, 最多上传15张',
  154. sort int not null default 0 comment '排序字段',
  155. like_count int comment '点赞初始人数',
  156. price int comment '价格',
  157. quantity int comment '库存数量',
  158. primary key (id)
  159. ) comment '商品spu' character set utf8mb4
  160. collate utf8mb4_general_ci;
  161. -- sku
  162. drop table if exists product_sku;
  163. create table product_sku
  164. (
  165. id int comment '主键',
  166. create_time datetime default current_timestamp comment '创建时间',
  167. update_time datetime default current_timestamp on update current_timestamp comment '更新时间',
  168. creator varchar(64) comment '创建人',
  169. updater varchar(64) comment '更新人',
  170. deleted bit(1) comment '状态',
  171. spu_id int not null comment 'spu编号',
  172. sku_status tinyint comment '状态: 1-正常 2-禁用',
  173. attrs varchar(64) not null comment '规格值数组, 以逗号隔开',
  174. price int not null DEFAULT -1 comment '销售价格,单位:分',
  175. original_price int not null DEFAULT -1 comment '原价, 单位: 分',
  176. cost_price int not null DEFAULT -1 comment '成本价,单位: 分',
  177. bar_code varchar(64) not null comment '条形码',
  178. pic_url VARCHAR(128) not null comment '图片地址',
  179. primary key (id)
  180. ) comment '商品sku' character set utf8mb4
  181. collate utf8mb4_general_ci;