|
|
@@ -1,5 +1,5 @@
|
|
|
-- =============================================
|
|
|
--- 订单变更记录表(记录每次下单/加餐的商品变化)
|
|
|
+-- 订单变更记录表(记录每次下单/更新订单的商品变化)
|
|
|
-- 用于展示每次操作都加了什么商品
|
|
|
-- =============================================
|
|
|
|
|
|
@@ -8,7 +8,7 @@ CREATE TABLE IF NOT EXISTS `store_order_change_log` (
|
|
|
`order_id` int(11) NOT NULL COMMENT '订单ID',
|
|
|
`order_no` varchar(64) NOT NULL COMMENT '订单号',
|
|
|
`batch_no` varchar(64) NOT NULL COMMENT '批次号(同一时间点的操作使用同一批次号,用于分组展示)',
|
|
|
- `operation_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '操作类型(1:首次下单, 2:加餐, 3:更新订单)',
|
|
|
+ `operation_type` tinyint(4) NOT NULL DEFAULT '1' COMMENT '操作类型(1:首次下单, 3:更新订单)',
|
|
|
`cuisine_id` int(11) NOT NULL COMMENT '菜品ID',
|
|
|
`cuisine_name` varchar(200) NOT NULL COMMENT '菜品名称',
|
|
|
`cuisine_type` tinyint(4) DEFAULT NULL COMMENT '菜品类型(1:单品, 2:套餐)',
|
|
|
@@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS `store_order_change_log` (
|
|
|
KEY `idx_operator_user_id` (`operator_user_id`),
|
|
|
KEY `idx_order_batch` (`order_id`, `batch_no`),
|
|
|
KEY `idx_order_time` (`order_id`, `operation_time`)
|
|
|
-) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单变更记录表(记录每次下单/加餐的商品变化)';
|
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单变更记录表(记录每次下单/更新订单的商品变化)';
|
|
|
|
|
|
-- =============================================
|
|
|
-- 表结构说明:
|
|
|
@@ -49,8 +49,7 @@ CREATE TABLE IF NOT EXISTS `store_order_change_log` (
|
|
|
--
|
|
|
-- 2. operation_type(操作类型):
|
|
|
-- - 1: 首次下单(创建订单时)
|
|
|
--- - 2: 加餐(通过加餐接口添加)
|
|
|
--- - 3: 更新订单(更新订单时重新下单)
|
|
|
+-- - 3: 更新订单(更新订单时重新下单,只记录新增或数量增加的商品)
|
|
|
--
|
|
|
-- 3. quantity_change(数量变化):
|
|
|
-- - 正数:新增的数量
|
|
|
@@ -60,7 +59,7 @@ CREATE TABLE IF NOT EXISTS `store_order_change_log` (
|
|
|
-- 4. quantity_before / quantity_after(变化前后数量):
|
|
|
-- - 用于展示变化前后对比
|
|
|
-- - 首次下单时,quantity_before = 0, quantity_after = quantity_change
|
|
|
--- - 加餐时,quantity_before = 原数量, quantity_after = 原数量 + quantity_change
|
|
|
+-- - 更新订单时,quantity_before = 原数量, quantity_after = 当前数量
|
|
|
--
|
|
|
-- 5. 使用场景:
|
|
|
-- - 查询某个订单的所有变更记录:SELECT * FROM store_order_change_log WHERE order_id = ? ORDER BY operation_time
|