From 69e0f44e279f7763fa9c9a4d105f154db39ee1d8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期六, 23 五月 2026 11:38:02 +0800
Subject: [PATCH] feat(sales): 添加每件数量字段支持及多业务流程优化

---
 src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
index 8d16029..69a0820 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -19,6 +19,7 @@
 import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
 import com.ruoyi.sales.mapper.ShippingInfoMapper;
 import com.ruoyi.sales.mapper.ShippingProductDetailMapper;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
 import com.ruoyi.sales.pojo.ShippingInfo;
 import com.ruoyi.sales.pojo.ShippingProductDetail;
 import com.ruoyi.sales.service.ShippingInfoService;
@@ -27,6 +28,7 @@
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -127,6 +129,10 @@
 
     @Override
     public boolean add(ShippingInfoDto req) {
+        if (CollectionUtils.isEmpty(req.getBatchNoDetailList())) {
+            throw new RuntimeException("鍙戣揣鏄庣粏涓嶈兘涓虹┖");
+        }
+//        normalizeShippingQuantity(req.getBatchNoDetailList(), req.getSalesLedgerProductId());
         this.save(req);
         req.getBatchNoDetailList().forEach(item -> item.setShippingInfoId(req.getId()));
         shippingProductDetailMapper.insert(req.getBatchNoDetailList());
@@ -153,4 +159,31 @@
         shippingApproveDto.setShippingProductDetailDtoList(dateilByShippingNo);
         return shippingApproveDto;
     }
+
+    /**
+     * 姝e父鍖栧彂璐ф暟閲�
+     * @param shippingProductDetails
+     * @param salesLedgerProductId
+     */
+    private void normalizeShippingQuantity(List<ShippingProductDetail> shippingProductDetails, Long salesLedgerProductId) {
+        if (CollectionUtils.isEmpty(shippingProductDetails)) {
+            return;
+        }
+        BigDecimal singleQuantity = BigDecimal.ONE;
+        if (salesLedgerProductId != null) {
+            SalesLedgerProduct salesLedgerProduct = salesLedgerProductMapper.selectById(salesLedgerProductId);
+            if (salesLedgerProduct != null && salesLedgerProduct.getSingleQuantity() != null
+                    && salesLedgerProduct.getSingleQuantity().compareTo(BigDecimal.ZERO) > 0) {
+                singleQuantity = salesLedgerProduct.getSingleQuantity();
+            }
+        }
+        if (singleQuantity.compareTo(BigDecimal.ONE) == 0) {
+            return;
+        }
+        for (ShippingProductDetail shippingProductDetail : shippingProductDetails) {
+            if (shippingProductDetail.getQuantity() != null) {
+                shippingProductDetail.setQuantity(shippingProductDetail.getQuantity().multiply(singleQuantity));
+            }
+        }
+    }
 }

--
Gitblit v1.9.3