From 55d694aaae4e421b5e55cd941500e08f85cb5d4d Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 27 八月 2026 18:21:33 +0800
Subject: [PATCH] feat(sales): 添加框架合同订单功能并优化销售台账管理
---
src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 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 103a4f2..82049ab 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ShippingInfoServiceImpl.java
@@ -23,9 +23,12 @@
import com.ruoyi.sales.dto.ShippingApproveDto;
import com.ruoyi.sales.dto.ShippingInfoDto;
import com.ruoyi.sales.dto.ShippingProductDetailDto;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
import com.ruoyi.sales.mapper.ShippingProductDetailMapper;
+import com.ruoyi.sales.pojo.SalesLedger;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.pojo.ShippingProductDetail;
import com.ruoyi.sales.service.ShippingInfoService;
@@ -52,6 +55,8 @@
private final SalesLedgerProductMapper salesLedgerProductMapper;
+
+ private final SalesLedgerMapper salesLedgerMapper;
private final StockUtils stockUtils;
@@ -172,6 +177,33 @@
@Override
public boolean addReq(ShippingInfoDto req) {
+ // 妗嗘灦鍚堝悓鍙敤浜庣櫥璁颁骇鍝佽寖鍥达紝瀹為檯鍙戣揣蹇呴』鍏宠仈妗嗘灦璁㈠崟浜у搧銆�
+ Long salesLedgerProductId = req.getSalesLedgerProductId();
+ if (salesLedgerProductId != null) {
+ SalesLedgerProduct product = salesLedgerProductMapper.selectById(salesLedgerProductId);
+ if (product == null) {
+ throw new RuntimeException("閿�鍞骇鍝佷笉瀛樺湪");
+ }
+ if (req.getSalesLedgerId() != null
+ && !java.util.Objects.equals(req.getSalesLedgerId(), product.getSalesLedgerId())) {
+ throw new RuntimeException("鍙戣揣鍙拌处涓庨攢鍞骇鍝佷笉鍖归厤");
+ }
+ SalesLedger ledger = salesLedgerMapper.selectById(product.getSalesLedgerId());
+ if (ledger == null || (!java.util.Objects.equals(ledger.getContractType(), 1)
+ && !java.util.Objects.equals(ledger.getContractType(), 3))) {
+ throw new RuntimeException("璇ラ攢鍞骇鍝佷笉鍏佽鍙戣揣");
+ }
+ }
+ // 鏍¢獙璇ヤ骇鍝佹槸鍚﹀凡鏈夊緟瀹℃牳/瀹℃牳涓殑鍙戣揣璁板綍锛岄槻姝㈤噸澶嶆彁浜�
+ 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 +232,9 @@
approvalInstance.setApplicantName(loginUser.getNickName());
approvalInstance.setApplyTime(LocalDateTime.now());
approvalInstanceService.add(approvalInstance);
+ // 鍒涘缓瀹℃壒瀹炰緥鍚庯紝鏇存柊鍙戣揣鐘舵�佷负"瀹℃牳涓�"锛屼娇鍓嶇姝g‘鏄剧ず瀹℃壒鐘舵��
+ req.setStatus("瀹℃牳涓�");
+ this.updateById(req);
return true;
}
}
--
Gitblit v1.9.3