188 lines
12 KiB
SQL
188 lines
12 KiB
SQL
create database jqjy;
|
||
|
||
use jqjy;
|
||
|
||
create table user
|
||
(
|
||
username varchar(256) null comment '用户昵称',
|
||
id bigint auto_increment comment 'id'
|
||
primary key,
|
||
unionId varchar(256) null comment '支付宝开放平台id',
|
||
openId varchar(256) null comment 'openId',
|
||
userAccount varchar(256) null comment '账号',
|
||
avatarUrl varchar(256) null comment '用户头像',
|
||
gender tinyint null comment '性别',
|
||
userPassword varchar(512) not null comment '密码',
|
||
phone varchar(128) null comment '电话',
|
||
email varchar(512) null comment '邮箱',
|
||
userStatus int default 0 not null comment '状态 0 -正常',
|
||
createTime datetime default CURRENT_TIMESTAMP null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP null on update CURRENT_TIMESTAMP,
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
userRole int default 0 not null comment '用户角色 0 - 普通用户 1 - 管理员 2 - 商家 3 - 美甲师',
|
||
index idx_openId (openId)
|
||
) comment '用户' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 商品表
|
||
create table if not exists commodities
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
businessId bigint not null comment '商家id',
|
||
commoditiesGroupId bigint not null comment '商品分组id',
|
||
commoditiesName varchar(128) not null comment '商品名称',
|
||
commoditiesImage varchar(1024) null comment '商品图片',
|
||
commoditiesPrice double not null comment '商品价格',
|
||
inventoryStatus int not null comment '库存数量',
|
||
status varchar(20) default '上架' not null comment '商品状态:上架,下架',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_businessId (businessId)
|
||
) comment '商品表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 商品分组表
|
||
create table if not exists commodities_group
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
businessId bigint not null comment '商家id',
|
||
groupName varchar(128) not null comment '商品分组名称',
|
||
isTopping tinyint default 0 not null comment '是否置顶:0不置顶,1置顶',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_businessId (businessId)
|
||
) comment '商品分组表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 商家表
|
||
create table if not exists business
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
userId bigint not null comment '用户id',
|
||
businessName varchar(512) not null comment '门店名称',
|
||
businessAvatar varchar(1024) not null comment '门店头像',
|
||
businessPhone varchar(64) not null comment '门店手机号',
|
||
address varchar(512) not null comment '店铺详细地址',
|
||
businessProfile varchar(512) null comment '门店简介',
|
||
businessImages varchar(1024) null comment '商家相册',
|
||
categoryId bigint null comment '分类id',
|
||
startBusiness varchar(64) not null comment '开始营业时间',
|
||
endBusiness varchar(64) not null comment '结束营业时间',
|
||
state tinyint default 0 not null comment '状态:0审核中,1启用,2禁用',
|
||
storeStatus tinyint default 0 not null comment '店铺状态:0休业,1营业',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_businessId (id),
|
||
index idx_userId (userId)
|
||
) comment '商家' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 商家认证表
|
||
create table if not exists business_auth
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
businessId bigint not null comment '店铺id',
|
||
shopkeeper varchar(64) not null comment '店主名',
|
||
license varchar(1024) not null comment '营业执照',
|
||
frontIdCard varchar(1024) not null comment '身份证正面',
|
||
backIdCard varchar(1024) not null comment '身份证反面',
|
||
bankCard varchar(64) not null comment '银行卡号',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_businessId (businessId)
|
||
) comment '商家认证' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 商品和规格的中间表
|
||
create table if not exists specifications_commodities
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
commoditiesId bigint not null comment '商品id',
|
||
specificationsId bigint not null comment '规格id',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_dishesId (commoditiesId),
|
||
index idx_specificationsId (specificationsId)
|
||
) comment '商品和规格的中间表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 规格表
|
||
create table if not exists specifications
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
businessId bigint not null comment '商家id',
|
||
specificationsName varchar(128) not null comment '规格名称',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_businessId (businessId)
|
||
) comment '规格表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 属性表
|
||
create table if not exists attribute
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
businessId bigint not null comment '商家id',
|
||
specificationsId bigint not null comment '规格id',
|
||
attributeName varchar(128) not null comment '属性名称',
|
||
attributeStatus tinyint default 0 not null comment '属性状态:0在售,1停售',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
index idx_businessId (businessId)
|
||
) comment '属性表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 购物车表
|
||
create table if not exists cart
|
||
(
|
||
id bigint auto_increment comment 'id' primary key,
|
||
userId bigint not null comment '用户id',
|
||
businessId bigint not null comment '商家id',
|
||
createTime datetime default CURRENT_TIMESTAMP not null comment '加入购物车时间',
|
||
updateTime datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
||
commoditiesId bigint null comment '商品id',
|
||
quantity int default 1 not null comment '商品数量',
|
||
price decimal(10, 2) not null comment '当前选择规格的价格',
|
||
subtotal decimal(10, 2) as ((`price` * `quantity`)) stored comment '小计(单价 * 数量)',
|
||
selectedOptions varchar(512) default '' not null comment '已选规格属性列表',
|
||
isDelete tinyint default 0 not null comment '是否删除',
|
||
index idx_userId (userId),
|
||
index idx_businessId (businessId)
|
||
) comment '购物车表' collate = utf8mb4_unicode_ci;
|
||
|
||
-- 美甲师表
|
||
create table if not exists manicurist
|
||
(
|
||
id BIGINT AUTO_INCREMENT COMMENT '美甲师唯一标识(主键,自增)' PRIMARY KEY,
|
||
userId BIGINT not null comment '用户ID(关联用户表)',
|
||
businessId bigint not null comment '商家id',
|
||
name VARCHAR(100) not null comment '美甲师姓名',
|
||
gender tinyint null comment '性别',
|
||
manicuristAvatar VARCHAR(255) COMMENT '美甲师头像文件的存储路径或链接',
|
||
phone VARCHAR(20) COMMENT '美甲师联系电话',
|
||
email VARCHAR(100) COMMENT '美甲师电子邮件',
|
||
employment_date DATE COMMENT '美甲师入职日期',
|
||
specialties VARCHAR(255) comment '美甲师的专长(如法式美甲、彩绘等)',
|
||
rating DECIMAL(3, 2) comment '美甲师的服务评分',
|
||
salary DECIMAL(10, 2) comment '美甲师的基本薪资',
|
||
manStatus int DEFAULT 0 comment'美甲师状态 0 表示正常 1 表示禁用',
|
||
isDeleted TINYINT DEFAULT 0 comment '逻辑删除标志,0 表示未删除,1 表示已删除',
|
||
createTime DATETIME DEFAULT CURRENT_TIMESTAMP not null comment '记录创建时间',
|
||
updateTime DATETIME DEFAULT CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '记录更新时间',
|
||
INDEX idx_userId (userId)
|
||
) comment ='美甲师表' COLLATE = utf8mb4_unicode_ci;
|
||
|
||
create table if not exists manicurist_auth
|
||
(
|
||
id BIGINT AUTO_INCREMENT COMMENT '认证唯一标识(主键,自增)' PRIMARY KEY,
|
||
artistId BIGINT not null comment '美甲师ID(关联美甲师表)',
|
||
certification_number VARCHAR(100) COMMENT '认证编号',
|
||
issuing_authority VARCHAR(100) COMMENT '发证机构',
|
||
certificate_path VARCHAR(255) COMMENT '证书文件的存储路径或链接',
|
||
createTime DATETIME default CURRENT_TIMESTAMP not null comment '记录创建时间',
|
||
updateTime DATETIME default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '记录更新时间',
|
||
isDeleted TINYINT default 0 comment '逻辑删除标志,0 表示未删除,1 表示已删除',
|
||
INDEX idx_artistId (artistId)
|
||
) comment ='美甲师认证表' COLLATE = utf8mb4_unicode_ci;
|
||
|
||
ALTER TABLE manicurist ADD COLUMN manStatus INT DEFAULT 0;
|
||
|