|
| 1 | +drop database if exists sell; |
| 2 | +create database sell; |
| 3 | +use sell; |
| 4 | + |
| 5 | +-- 类目 |
| 6 | +create table `product_category` ( |
| 7 | + `category_id` int not null auto_increment, |
| 8 | + `category_name` varchar(64) not null comment '类目名字', |
| 9 | + `category_type` int not null comment '类目编号', |
| 10 | + `create_time` timestamp not null default current_timestamp comment '创建时间', |
| 11 | + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', |
| 12 | + primary key (`category_id`) |
| 13 | +); |
| 14 | + |
| 15 | +-- 商品 |
| 16 | +create table `product_info` ( |
| 17 | + `product_id` varchar(32) not null, |
| 18 | + `product_name` varchar(64) not null comment '商品名称', |
| 19 | + `product_price` decimal(8,2) not null comment '单价', |
| 20 | + `product_stock` int not null comment '库存', |
| 21 | + `product_description` varchar(64) comment '描述', |
| 22 | + `product_icon` varchar(512) comment '小图', |
| 23 | + `product_status` tinyint(3) DEFAULT '0' COMMENT '商品状态,0正常1下架', |
| 24 | + `category_type` int not null comment '类目编号', |
| 25 | + `create_time` timestamp not null default current_timestamp comment '创建时间', |
| 26 | + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', |
| 27 | + primary key (`product_id`) |
| 28 | +); |
| 29 | + |
| 30 | +-- 订单 |
| 31 | +create table `order_master` ( |
| 32 | + `order_id` varchar(32) not null, |
| 33 | + `buyer_name` varchar(32) not null comment '买家名字', |
| 34 | + `buyer_phone` varchar(32) not null comment '买家电话', |
| 35 | + `buyer_address` varchar(128) not null comment '买家地址', |
| 36 | + `buyer_openid` varchar(64) not null comment '买家微信openid', |
| 37 | + `order_amount` decimal(8,2) not null comment '订单总金额', |
| 38 | + `order_status` tinyint(3) not null default '0' comment '订单状态, 默认为新下单', |
| 39 | + `pay_status` tinyint(3) not null default '0' comment '支付状态, 默认未支付', |
| 40 | + `create_time` timestamp not null default current_timestamp comment '创建时间', |
| 41 | + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', |
| 42 | + primary key (`order_id`), |
| 43 | + key `idx_buyer_openid` (`buyer_openid`) |
| 44 | +); |
| 45 | + |
| 46 | +-- 订单商品 |
| 47 | +create table `order_detail` ( |
| 48 | + `detail_id` varchar(32) not null, |
| 49 | + `order_id` varchar(32) not null, |
| 50 | + `product_id` varchar(32) not null, |
| 51 | + `product_name` varchar(64) not null comment '商品名称', |
| 52 | + `product_price` decimal(8,2) not null comment '当前价格,单位分', |
| 53 | + `product_quantity` int not null comment '数量', |
| 54 | + `product_icon` varchar(512) comment '小图', |
| 55 | + `create_time` timestamp not null default current_timestamp comment '创建时间', |
| 56 | + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', |
| 57 | + primary key (`detail_id`), |
| 58 | + key `idx_order_id` (`order_id`) |
| 59 | +); |
| 60 | + |
| 61 | +-- 卖家(登录后台使用, 卖家登录之后可能直接采用微信扫码登录,不使用账号密码) |
| 62 | +create table `seller_info` ( |
| 63 | + `id` varchar(32) not null, |
| 64 | + `username` varchar(32) not null, |
| 65 | + `password` varchar(32) not null, |
| 66 | + `openid` varchar(64) not null comment '微信openid', |
| 67 | + `create_time` timestamp not null default current_timestamp comment '创建时间', |
| 68 | + `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', |
| 69 | + primary key (`id`) |
| 70 | +) comment '卖家信息表'; |
| 71 | + |
| 72 | + |
0 commit comments