烘焙预约小程序 - 数据库ER图

三大模块(用户点单、外卖配送、预约)完整表结构及 bake_ 表关系

完整系统ER图(三大模块数据关系)

关系符号:||--o{ 一对多(1:N),}o--o{ 多对多(N:N),||--|| 一对一(1:1)。

erDiagram %% 模块A:用户点单 goods_type ||--o{ goods_type : "自关联parentId" goods_type ||--o{ goods_info : "1:N typeId" goods_info ||--o{ goods_spec : "1:N goodsId" goods_info ||--o{ goods_comment : "1:N goodsId" goods_info ||--o{ order_goods : "1:N goodsId" user_info ||--o{ goods_comment : "1:N userId" %% 模块B:外卖配送 user_info ||--o{ order_info : "1:N userId" shop_info ||--o{ order_info : "1:N shopId" order_info ||--o{ order_goods : "1:N orderId" order_info ||--o| market_coupon_user : "1:1 orderId" %% 模块C:预约 user_info ||--o{ bake_reservation : "1:N userId" shop_info ||--o{ bake_reservation : "1:N shopId" shop_info ||--o{ bake_shop_delivery_tip : "1:N shopId" %% 公共模块 user_info ||--o{ user_address : "1:N userId" user_info ||--o{ user_wx : "1:N userId" user_info ||--o{ user_vip : "1:1 userId" user_info ||--o{ market_coupon_user : "1:N userId" market_coupon_info ||--o{ market_coupon_user : "1:N couponId" user_info ||--o{ cs_session : "1:N userId" cs_session ||--o{ cs_msg : "1:N sessionId" user_info ||--o{ app_feedback : "1:N userId" user_info ||--o{ app_complain : "1:N userId" %% 用户相关表 user_info { bigint id PK string unionId UK string nickName string phone string avatarUrl int vipLevel int points } user_address { bigint id PK bigint userId FK string name string phone string province string city string area string address string detail tinyint isDefault } user_wx { bigint id PK bigint userId FK string openId UK string sessionKey } user_vip { bigint id PK bigint userId FK int level datetime expireTime } %% 门店相关表 shop_info { bigint id PK string name string contactName string phone string address float latitude float longitude tinyint status bigint adminUserId FK string deliveryTip } info_banner { bigint id PK string title string picUrl string linkUrl tinyint type int sort tinyint status } %% 商品相关表 goods_type { bigint id PK bigint shopId FK bigint parentId FK string name string pic int sort } goods_info { bigint id PK bigint shopId FK bigint typeId FK string name string description decimal price int stock int sales string pic text pics } goods_spec { bigint id PK bigint goodsId FK string name tinyint type json values } goods_comment { bigint id PK bigint userId FK bigint goodsId FK bigint orderId FK string content text pics tinyint star } %% 订单相关表 order_info { bigint id PK string orderNo UK bigint userId FK bigint shopId FK tinyint type "0自取1外卖2堂食" string takeNo "取餐号AWD前缀" string seatNo "座位号堂食可选" tinyint status decimal totalPrice decimal payPrice decimal deliveryFee json address string remark bigint couponUserId FK datetime payTime datetime finishTime } order_goods { bigint id PK bigint orderId FK bigint goodsId FK string goodsName decimal price int num string specIds string specNames string pic } %% 预约相关表(新增) bake_reservation { bigint id PK bigint userId FK bigint shopId FK tinyint type string contactName string phone date reserveDate string reserveTime json address string voucherPic string remark tinyint status } bake_shop_delivery_tip { bigint id PK bigint shopId FK string tip int minPrice int maxDistance } %% 营销相关表 market_coupon_info { bigint id PK string name tinyint type decimal value decimal minAmount int validDays int total int received int limitPerUser tinyint status } market_coupon_user { bigint id PK bigint userId FK bigint couponId FK bigint orderId FK tinyint status datetime useTime datetime expireTime } %% 客服相关表 cs_session { bigint id PK bigint userId FK string lastMsg int unreadCount datetime lastTime } cs_msg { bigint id PK bigint sessionId FK tinyint type string content tinyint isRead tinyint fromAdmin } %% 应用相关表 app_feedback { bigint id PK bigint userId FK string content text pics tinyint status string reply } app_complain { bigint id PK bigint userId FK bigint orderId FK string content text pics tinyint status string reply } app_version { bigint id PK string version string platform string content tinyint forceUpdate } app_goods { bigint id PK string name decimal price text goodsIds string pic }

bake_ 新建业务表使用 bake_ 前缀,其他表按模块标准命名

模块 A:用户点单(商品相关)
goods_info(商品信息)
id, shopId, typeIdPK, FK
name, price, stock, sales
关系:N:1 → goods_type;1:N → order_goods, goods_spec, goods_comment
goods_type(商品分类)
id, shopId, parentIdPK, FK 自关联
name, pic, sort
关系:自关联 parentId;1:N → goods_info
goods_spec(商品规格)
goodsId, name, typeFK, 1单选 2多选
valuesJSON [{id,name,price}]
关系:N:1 → goods_info
goods_comment(商品评论)
userId, goodsId, orderIdFK
content, pics, star
关系:N:1 → goods_info, user_info, order_info
goods_search_keyword(搜索关键词)
keyword, count
关系:独立表
模块 B:外卖配送(订单相关)
order_info(订单主表)
id, orderNo, userId, shopIdPK, UK, FK
type0自取 1外卖 2堂食
takeNo取餐号(A/W/D前缀)
seatNo座位号(堂食可选)
status, totalPrice, payPrice
address, remark, couponUserId
关系:N:1 → user_info, shop_info;1:N → order_goods
order_goods(订单商品)
orderId, goodsIdFK
goodsName, price, num, specIds快照
关系:N:1 → order_info, goods_info
模块 C:预约(新增 bake_ 表)
bake_reservation(预约单)
id, userId, shopIdPK, FK
type, status0自提 1配送 / 0已预约 1已完成 2已取消
reserveDate, reserveTime预约时间
voucherPic核销券码图
关系:N:1 → user_info, shop_info
bake_shop_delivery_tip(门店配送提示)
shopId, tipFK
minPrice, maxDistance配送规则
关系:N:1 → shop_info
公共模块:用户与门店
user_info(用户信息)
id, unionIdPK, UK
nickName, phone, avatarUrl
vipLevel, points
关系:1:N → user_address, user_wx, order_info, bake_reservation, market_coupon_user
user_address(用户地址)
userIdFK → user_info
name, phone, province/city/area
address, detail, isDefault
关系:N:1 → user_info
user_wx(微信登录)
userId, openIdFK, UK
sessionKey
关系:N:1 → user_info
shop_info(店铺信息)
id, name, addressPK
latitude, longitude定位
+ adminUserId, deliveryTip门店管理员/配送提示(扩展)
关系:1:N → order_info, bake_reservation, bake_shop_delivery_tip
info_banner(轮播图)
title, picUrl, linkUrl
type, sort, status
关系:独立表,无外键
公共模块:营销
market_coupon_info(优惠券)
name, type, value, minAmount
total, received, limitPerUser
关系:1:N → market_coupon_user
market_coupon_user(用户优惠券)
userId, couponId, orderIdFK
status, useTime, expireTime
关系:N:1 → user_info, market_coupon_info, order_info
user_vip(会员等级)
userId, level, expireTimeFK
关系:1:1 → user_info
公共模块:客服与应用
cs_session(客服会话)
userId, lastMsg, unreadCountFK
关系:N:1 → user_info;1:N → cs_msg
cs_msg(客服消息)
sessionId, type, contentFK
isRead, fromAdmin
关系:N:1 → cs_session
app_feedback(意见反馈)
userId, content, picsFK
status, reply
关系:N:1 → user_info
app_complain(投诉)
userId, orderId, contentFK
status, reply
关系:N:1 → user_info, order_info
app_version(版本管理)
version, platform, content
forceUpdate
关系:独立表
app_goods(套餐管理)
name, price, goodsIds
关系:逻辑关联 → goods_info
模块 C 预约专用 ER 图(bake_ 新增表关系)
erDiagram %% 预约模块核心关系 user_info ||--o{ bake_reservation : "1:N userId" shop_info ||--o{ bake_reservation : "1:N shopId" shop_info ||--o{ bake_shop_delivery_tip : "1:N shopId" user_info { bigint id PK string unionId UK string nickName string phone string avatarUrl } shop_info { bigint id PK string name string address float latitude float longitude bigint adminUserId FK string deliveryTip } bake_reservation { bigint id PK bigint userId FK bigint shopId FK tinyint type string contactName string phone date reserveDate string reserveTime json address string voucherPic string remark tinyint status } bake_shop_delivery_tip { bigint id PK bigint shopId FK string tip int minPrice int maxDistance }

预约模块 bake_reservationbake_shop_delivery_tip 为烘焙项目新增表,通过 userId 和 shopId 与沿用的 user_info 和 shop_info 表建立关联。

文档版本:v2.1 · 2026-02-25(新增堂食类型和座位号)

← 返回文档总览