微信点餐系统
包括需求分析,项目设计,项目架构,数据库设计等等。
开发流程
项目设计
角色划分
功能模块划分
部署架构
数据库设计
角色划分
买家(手机端) 微信点餐
卖家(PC端)管理
微信点餐系统就买家和卖家
一个浏览定吃的(浏览、下单、取消、支付、查询)、一个接单做吃的(商品上下架、接单、查询、取消、类目删除)
买家(手机端)
卖家(PC端)
功能模块划分 - 功能分析
商品的、订单的、类目的。。。
商品
订单
类目
微信点餐系统的关系图
买家
查询 商品
创建/查询 订单
消息
卖家
查询/接单 订单
管理商品
消息
消息互相联系哦
部署架构
分布式部署
Tomcat 多台服务器 多个应用
多端 手机微信端 Web端
Nginx
Tomcat
Redist、MySQL
微服务 -》Spring Cloud -》Spring Boot
微服务
单一 垂直 分布式 流动式
架构的演进
微服务 实现
两大“门派”
阿里系
SpringCloud栈
Spring社区
阿里系
Dubbo
Zookeeper
Spring MVC or SpringBoot
…
Apache Dubbo 服务化治理?
Apache Dubbo™ 是一款高性能Java RPC框架。
Zookeeper https://zookeeper.apache.org/ 注册中心?
Spring Cloud 栈
https://spring.io/projects/spring-cloud-netflix
微服务 面对 服务化的
演进过程
本身 不受技术框架的束缚 微服务
数据库设计
表和表之间的关系
建表SQL
注意事项
数据库 设计 五张
商品表 商品的属性
类目表
订单详情表
卖家信息表
订单主表
设计我们的数据库
设计数据库
自增有上限,设置下字符类型 。
微信点餐的数据库设计 表设计
商品表
名称 product_name 商品名称
单价 product_price 商品单价
库存 库存 product_stock
描述 product_description 商品的描述
图片 product_icon 商品小图
类目编号 category_type
商品状态,0正常1下架 product_status
创建时间 create_time
修改时间 update_time
-- 商品
create table `product_info` (
`product_id` varchar(32) not null,
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '单价',
`product_stock` int not null comment '库存',
`product_description` varchar(64) comment '描述',
`product_icon` varchar(512) comment '小图',
`product_status` tinyint(3) DEFAULT '0' COMMENT '商品状态,0正常1下架',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`product_id`)
);
简单说明
主键product_id商品的id , primary key (product_id
)
create_time
timestamp not null default current_timestamp comment ‘创建时间’,
update_time
timestamp not null default current_timestamp on update current_timestamp comment ‘修改时间’,
timestamp时间戳
decimal 8 2
这是上线的项目,自增上线是不行的,自增不够用商品id有上限。
更新的时候自动写进去
mysql5.7 可以这么设置
价格8位 加二个小数点
类目表
名称 category_name
编号 category
-- 类目
create table `product_category` (
`category_id` int not null auto_increment,
`category_name` varchar(64) not null comment '类目名字',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`category_id`),
UNIQUE KEY `uqe_category_type` (`category_type`)
);
类目没那多么多 int 类目名称 类目编号少的
类目编号 自定义的
查询性能的优化 约束索引 unique key `` 与商品也有关
订单表
买家名字 buyer_name
买家电话 buyer_phone
买家地址 buyer_address
买家微信id buyer_openid
总金额 order_amount
订单状态 order_status
支付状态 pay_status
常见时间
修改时间
-- 订单
create table `order_master` (
`order_id` varchar(32) not null,
`buyer_name` varchar(32) not null comment '买家名字',
`buyer_phone` varchar(32) not null comment '买家电话',
`buyer_address` varchar(128) not null comment '买家地址',
`buyer_openid` varchar(64) not null comment '买家微信openid',
`order_amount` decimal(8,2) not null comment '订单总金额',
`order_status` tinyint(3) not null default '0' comment '订单状态, 默认为新下单',
`pay_status` tinyint(3) not null default '0' comment '支付状态, 默认未支付',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`order_id`),
key `idx_buyer_openid` (`buyer_openid`)
);
加一个索引
key
idx_buyer_openid(
buyer_openid)
订单详情表
订单id order_id
商品id product_id
商品名字 product_name
商品价格 product_price
商品数量 product_quantity
商品图片 product_icon
-- 订单商品
create table `order_detail` (
`detail_id` varchar(32) not null,
`order_id` varchar(32) not null,
`product_id` varchar(32) not null,
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '当前价格,单位分',
`product_quantity` int not null comment '数量',
`product_icon` varchar(512) comment '小图',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`detail_id`),
key `idx_order_id` (`order_id`)
);
查询的时候用到订单id 来查
order_id
varchar(32) not null,
加个索引
key idx_order_id
(order_id
)
总的 创建个sell数据库再执行sell.sql吧
sell.sql
-- 类目
create table `product_category` (
`category_id` int not null auto_increment,
`category_name` varchar(64) not null comment '类目名字',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`category_id`),
UNIQUE KEY `uqe_category_type` (`category_type`)
);
-- 商品
create table `product_info` (
`product_id` varchar(32) not null,
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '单价',
`product_stock` int not null comment '库存',
`product_description` varchar(64) comment '描述',
`product_icon` varchar(512) comment '小图',
`product_status` tinyint(3) DEFAULT '0' COMMENT '商品状态,0正常1下架',
`category_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`product_id`)
);
-- 订单
create table `order_master` (
`order_id` varchar(32) not null,
`buyer_name` varchar(32) not null comment '买家名字',
`buyer_phone` varchar(32) not null comment '买家电话',
`buyer_address` varchar(128) not null comment '买家地址',
`buyer_openid` varchar(64) not null comment '买家微信openid',
`order_amount` decimal(8,2) not null comment '订单总金额',
`order_status` tinyint(3) not null default '0' comment '订单状态, 默认为新下单',
`pay_status` tinyint(3) not null default '0' comment '支付状态, 默认未支付',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`order_id`),
key `idx_buyer_openid` (`buyer_openid`)
);
-- 订单商品
create table `order_detail` (
`detail_id` varchar(32) not null,
`order_id` varchar(32) not null,
`product_id` varchar(32) not null,
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '当前价格,单位分',
`product_quantity` int not null comment '数量',
`product_icon` varchar(512) comment '小图',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`detail_id`),
key `idx_order_id` (`order_id`)
);
-- 卖家(登录后台使用, 卖家登录之后可能直接采用微信扫码登录,不使用账号密码)
create table `seller_info` (
`seller_id` varchar(32) not null,
`username` varchar(32) not null,
`password` varchar(32) not null,
`openid` varchar(64) not null comment '微信openid',
`create_time` timestamp not null default current_timestamp comment '创建时间',
`update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间',
primary key (`seller_id`)
) comment '卖家信息表';
执行成功 数据库搞定
阿里云OSS 存储图片
烤肉
https://sell-liuawen.oss-cn-beijing.aliyuncs.com/kaorou.jpg
皮蛋粥
https://sell-liuawen.oss-cn-beijing.aliyuncs.com/pidanzhou.jpg
白米饭
https://sell-liuawen.oss-cn-beijing.aliyuncs.com/baimifan.jpg
1、Spring Boot 打造企业级微信点餐系统