Przeglądaj źródła

fix: 修复 createMultiItem 中 minQuantity 产品级校验注入位置错误

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
iwt 1 miesiąc temu
rodzic
commit
c25e67802f

+ 6 - 6
cfc-backend/src/main/java/com/etotem/cfc/service/ProductOrderService.java

@@ -194,6 +194,10 @@ public class ProductOrderService {
                     }
                 }
             }
+            // 产品级最小购买数量检查(当没有SKU或SKU不限制时)
+            if (item.getSkuId() == null && product.getMinQuantity() != null && item.getQuantity() < product.getMinQuantity()) {
+                return Result.error(product.getName() + " 最低需购买" + product.getMinQuantity() + "件");
+            }
             totalAmount += unitPrice * item.getQuantity();
             totalQuantity += item.getQuantity();
             if (firstProduct == null) {
@@ -522,12 +526,8 @@ public class ProductOrderService {
             }
         } catch (Exception e) {
             log.error("同步AfterSalesRequest状态失败: orderNo={}, status={}", orderNo, status, e);
-                }
-                // 产品级最小购买数量检查
-                if (item.getSkuId() == null && product.getMinQuantity() != null && item.getQuantity() < product.getMinQuantity()) {
-                    return Result.error(product.getName() + " 最低需购买" + product.getMinQuantity() + "件");
-                }
-            }
+        }
+    }
 
     public Result<List<ProductOrderDTO>> myOrders(Long buyerId, String status) {
         return myOrders(buyerId, status, null);