Blame view

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