Преглед изворни кода

取消掉加餐接口 沿用更新订单逻辑

lutong пре 2 месеци
родитељ
комит
76888e2b6e

+ 10 - 11
alien-dining/doc/订单变更记录表使用说明.md

@@ -2,7 +2,7 @@
 
 ## 表设计目的
 
-记录每次下单/加餐时商品种类和数量的变化,用于展示每次操作都加了什么商品。
+记录每次下单/更新订单时商品种类和数量的变化,用于展示每次操作都加了什么商品。
 
 ## 核心字段说明
 
@@ -13,8 +13,7 @@
 
 ### 2. operation_type(操作类型)
 - **1:首次下单** - 创建订单时的操作
-- **2:加餐** - 通过加餐接口添加商品
-- **3:更新订单** - 更新订单时重新下单
+- **3:更新订单** - 更新订单时重新下单(只记录新增或数量增加的商品)
 
 ### 3. quantity_change(数量变化)
 - **正数**:新增的数量
@@ -75,7 +74,7 @@ WHERE batch_no = 'ORDER123_20250202143025'
 ORDER BY cuisine_id;
 ```
 
-### 场景4:查询加餐记录
+### 场景4:查询更新订单记录
 ```sql
 SELECT 
     batch_no,
@@ -85,7 +84,7 @@ SELECT
     amount_change
 FROM store_order_change_log 
 WHERE order_id = 123 
-  AND operation_type = 2  -- 加餐
+  AND operation_type = 3  -- 更新订单
   AND delete_flag = 0
 ORDER BY operation_time DESC;
 ```
@@ -100,13 +99,13 @@ ORDER BY operation_time DESC;
 | 石板肉酱豆腐 | 1 | 0 | 1 | 19.90 |
 | 经典三杯鸡 | 1 | 0 | 1 | 26.90 |
 
-### 第一次加餐(batch_no: ORDER123_20250202143000)
+### 第一次更新订单(batch_no: ORDER123_20250202143000)
 | cuisine_name | quantity_change | quantity_before | quantity_after | amount_change |
 |-------------|----------------|-----------------|----------------|---------------|
 | 经典三杯鸡 | 1 | 1 | 2 | 26.90 |
 | 宫保鸡丁 | 1 | 0 | 1 | 28.00 |
 
-### 第二次加餐(batch_no: ORDER123_20250202150000)
+### 第二次更新订单(batch_no: ORDER123_20250202150000)
 | cuisine_name | quantity_change | quantity_before | quantity_after | amount_change |
 |-------------|----------------|-----------------|----------------|---------------|
 | 石板肉酱豆腐 | 1 | 1 | 2 | 19.90 |
@@ -119,11 +118,11 @@ ORDER BY operation_time DESC;
   • 石板肉酱豆腐 x1
   • 经典三杯鸡 x1
 
-14:30 - 加餐
+14:30 - 更新订单
   • 经典三杯鸡 x1(累计:2)
   • 宫保鸡丁 x1
 
-15:00 - 加餐
+15:00 - 更新订单
   • 石板肉酱豆腐 x1(累计:2)
 ```
 
@@ -134,12 +133,12 @@ ORDER BY operation_time DESC;
   经典三杯鸡 x1    ¥26.90
   小计:¥46.80
 
-批次2:加餐(14:30)
+批次2:更新订单(14:30)
   经典三杯鸡 x1    ¥26.90
   宫保鸡丁 x1      ¥28.00
   小计:¥54.90
 
-批次3:加餐(15:00)
+批次3:更新订单(15:00)
   石板肉酱豆腐 x1  ¥19.90
   小计:¥19.90
 ```

+ 1 - 8
alien-dining/src/main/java/shop/alien/dining/service/impl/StoreOrderServiceImpl.java

@@ -1598,8 +1598,6 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
         switch (operationType) {
             case 1:
                 return "首次下单";
-            case 2:
-                return "加餐";
             case 3:
                 return "更新订单";
             default:
@@ -1613,7 +1611,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
      * @param orderId 订单ID
      * @param orderNo 订单号
      * @param items 商品列表
-     * @param operationType 操作类型(1:首次下单, 2:加餐, 3:更新订单)
+     * @param operationType 操作类型(1:首次下单, 3:更新订单)
      * @param operationTime 操作时间
      * @param userId 操作人ID
      * @param userPhone 操作人手机号
@@ -1644,11 +1642,6 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
                 quantityBefore = 0;
                 quantityAfter = currentQuantity != null ? currentQuantity : 0;
                 quantityChange = quantityAfter;
-            } else if (operationType == 2) {
-                // 加餐:记录加餐的商品
-                quantityBefore = lockedQuantity != null ? lockedQuantity : 0;
-                quantityAfter = currentQuantity != null ? currentQuantity : 0;
-                quantityChange = quantityAfter - quantityBefore;
             } else if (operationType == 3) {
                 // 更新订单:只记录新增的商品或数量增加的商品
                 if (lockedQuantity == null || lockedQuantity == 0) {

+ 2 - 2
alien-entity/src/main/java/shop/alien/entity/store/StoreOrderChangeLog.java

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
 import java.util.Date;
 
 /**
- * 订单变更记录表(记录每次下单/加餐的商品变化)
+ * 订单变更记录表(记录每次下单/更新订单的商品变化)
  *
  * @author system
  * @since 2025-02-02
@@ -38,7 +38,7 @@ public class StoreOrderChangeLog {
     @TableField("batch_no")
     private String batchNo;
 
-    @ApiModelProperty(value = "操作类型(1:首次下单, 2:加餐, 3:更新订单)")
+    @ApiModelProperty(value = "操作类型(1:首次下单, 3:更新订单)")
     @TableField("operation_type")
     private Integer operationType;
 

+ 2 - 2
alien-entity/src/main/java/shop/alien/entity/store/vo/OrderChangeLogBatchVO.java

@@ -21,7 +21,7 @@ public class OrderChangeLogBatchVO {
     @ApiModelProperty(value = "批次号")
     private String batchNo;
 
-    @ApiModelProperty(value = "操作类型(1:首次下单, 2:加餐, 3:更新订单)")
+    @ApiModelProperty(value = "操作类型(1:首次下单, 3:更新订单)")
     private Integer operationType;
 
     @ApiModelProperty(value = "操作类型文本")
@@ -36,7 +36,7 @@ public class OrderChangeLogBatchVO {
     @ApiModelProperty(value = "操作人手机号")
     private String operatorUserPhone;
 
-    @ApiModelProperty(value = "备注(该批次对应的备注,如下单/加餐时的备注)")
+    @ApiModelProperty(value = "备注(该批次对应的备注,如下单/更新订单时的备注)")
     private String remark;
 
     @ApiModelProperty(value = "该批次商品数量变化总和")

+ 5 - 6
store_order_change_log.sql

@@ -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