From f9a035ab0c26281dd5aab1140af5d185d7d6893e Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 24 六月 2026 11:22:26 +0800
Subject: [PATCH] fix:销售台账重复发货优化
---
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java | 14 ++++++++++++++
src/main/resources/mapper/sales/SalesLedgerProductMapper.xml | 2 +-
2 files changed, 15 insertions(+), 1 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 103a4f2..be34bc0 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -172,6 +172,17 @@
@Override
public boolean addReq(ShippingInfoDto req) {
+ // 鏍¢獙璇ヤ骇鍝佹槸鍚﹀凡鏈夊緟瀹℃牳/瀹℃牳涓殑鍙戣揣璁板綍锛岄槻姝㈤噸澶嶆彁浜�
+ Long salesLedgerProductId = req.getSalesLedgerProductId();
+ if (salesLedgerProductId != null) {
+ long pendingCount = this.count(new LambdaQueryWrapper<ShippingInfo>()
+ .eq(ShippingInfo::getSalesLedgerProductId, salesLedgerProductId)
+ .in(ShippingInfo::getStatus, "寰呭鏍�", "瀹℃牳涓�"));
+ if (pendingCount > 0) {
+ throw new RuntimeException("璇ヤ骇鍝佸凡鏈夊緟瀹℃牳鐨勫彂璐ц褰曪紝璇峰嬁閲嶅鎻愪氦");
+ }
+ }
+
LoginUser loginUser = SecurityUtils.getLoginUser();
String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH","shipping_no",req.getCreateTime());
// 鍏堜繚瀛樺彂璐у崟锛屽啀鍙戣捣瀹℃壒锛涙棤瀹℃牳浜鸿嚜鍔ㄩ�氳繃鏃堕渶瑕佹寜鍙戣揣缂栧彿鍥炲啓鍙戣揣鐘舵�併��
@@ -200,6 +211,9 @@
approvalInstance.setApplicantName(loginUser.getNickName());
approvalInstance.setApplyTime(LocalDateTime.now());
approvalInstanceService.add(approvalInstance);
+ // 鍒涘缓瀹℃壒瀹炰緥鍚庯紝鏇存柊鍙戣揣鐘舵�佷负"瀹℃牳涓�"锛屼娇鍓嶇姝g‘鏄剧ず瀹℃壒鐘舵��
+ req.setStatus("瀹℃牳涓�");
+ this.updateById(req);
return true;
}
}
diff --git a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
index 2ae23b1..ec5cca2 100644
--- a/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
+++ b/src/main/resources/mapper/sales/SalesLedgerProductMapper.xml
@@ -33,7 +33,7 @@
WHEN (IFNULL(t2.qualitity, 0) - IFNULL(t2.locked_quantity, 0)) >0 THEN 1
ELSE 0
END as has_sufficient_stock,
- (IFNULL(T1.quantity, 0) - IFNULL(t3.shipped_quantity, 0)) as no_quantity,
+ (IFNULL(T1.quantity, 0) - IFNULL(t3.shipped_quantity, 0) - IFNULL(t5.pending_approval_quantity, 0)) as no_quantity,
IFNULL(t5.pending_approval_quantity, 0) as pending_approval_quantity,
CASE
WHEN IFNULL(t3.shipped_quantity, 0) = 0 AND IFNULL(t5.pending_approval_quantity, 0) = 0 THEN '寰呭彂璐�'
--
Gitblit v1.9.3