From 7bf754a7835d06f26240c4ca15bc5f83650de377 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 21 九月 2026 20:52:25 +0800
Subject: [PATCH] docs(api): 更新信托基金与代储台账及油品出库相关接口文档

---
 src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
index 00161b5..158ee93 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -25,6 +25,7 @@
 import com.ruoyi.procurementrecord.mapper.ReturnSaleProductMapper;
 import com.ruoyi.procurementrecord.pojo.ReturnManagement;
 import com.ruoyi.procurementrecord.pojo.ReturnSaleProduct;
+import com.ruoyi.sales.dto.SalesLedgerDto;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
 import com.ruoyi.sales.mapper.ShippingInfoMapper;
 import com.ruoyi.sales.pojo.SalesLedger;
@@ -58,6 +59,16 @@
     private ShippingInfoMapper shippingInfoMapper;
     private SalesLedgerMapper salesLedgerMapper;
 
+    /**
+     * 鍏ュ簱绫诲埆锛氫唬鍌ㄥ叆搴撱�傚彧鏈夎繖涓被鍒姹傜粦瀹氶攢鍞鍗�
+     */
+    private static final String INBOUND_CATEGORY_DEPOSIT = "浠e偍鍏ュ簱";
+
+    /**
+     * 閿�鍞彴璐︾殑閿�鍞被鍨嬶細浠e偍銆備唬鍌ㄥ叆搴撳彧鑳界粦杩欎釜绫诲瀷鐨勫彴璐�
+     */
+    private static final String LEDGER_TYPE_DEPOSIT = "浠e偍";
+
     @Override
     public IPage<StockInRecordDto> listPage(Page page, StockInRecordDto stockInRecordDto) {
         return stockInRecordMapper.listPage(page, stockInRecordDto);
@@ -67,6 +78,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int add(StockInRecordDto stockInRecordDto) {
+        resolveDepositSalesLedger(stockInRecordDto);
         LocalDateTime createTime = stockInRecordDto.getCreateTime();
         if (createTime == null) {
             createTime = LocalDateTime.now();
@@ -79,6 +91,38 @@
         return stockInRecordMapper.insert(stockInRecord);
     }
 
+    /**
+     * 浠e偍鍏ュ簱锛坕nboundCategory=浠e偍鍏ュ簱锛夊繀椤荤粦瀹氫竴寮犮�屼唬鍌ㄣ�嶇被鍨嬬殑閿�鍞彴璐︼紙閿�鍞鍗曪級銆�
+     * 鍙仛鏍¢獙涓庤惤搴擄紝**涓嶇敤鍙拌处瑕嗙洊**鍏ュ簱鍗曚笂鐨勫鎴�/娌瑰簱/鍌ㄧ綈 鈥斺�� 閭e嚑椤逛粛浠ョ幇鍦哄~鍐欎负鍑嗐��
+     * 闈炰唬鍌ㄥ叆搴撲笉缁戝彴璐︼紝鍗充娇鍓嶇浼犱簡涔熺疆绌猴紝閬垮厤钀戒笅鏃犳剰涔夌殑鍏宠仈銆�
+     */
+    private void resolveDepositSalesLedger(StockInRecordDto stockInRecordDto) {
+        if (!INBOUND_CATEGORY_DEPOSIT.equals(stockInRecordDto.getInboundCategory())) {
+            stockInRecordDto.setSalesLedgerId(null);
+            return;
+        }
+        Long salesLedgerId = stockInRecordDto.getSalesLedgerId();
+        if (salesLedgerId == null) {
+            throw new BaseException("浠e偍鍏ュ簱蹇呴』缁戝畾閿�鍞鍗�");
+        }
+        SalesLedger salesLedger = salesLedgerMapper.selectById(salesLedgerId);
+        if (salesLedger == null) {
+            throw new BaseException("鎵�閫夐攢鍞鍗曚笉瀛樺湪,閿�鍞鍗昳d:" + salesLedgerId);
+        }
+        if (!LEDGER_TYPE_DEPOSIT.equals(salesLedger.getLedgerType())) {
+            throw new BaseException("浠e偍鍏ュ簱鍙兘缁戝畾浠e偍绫诲瀷鐨勯攢鍞鍗�,閿�鍞悎鍚屽彿:" + salesLedger.getSalesContractNo());
+        }
+    }
+
+    @Override
+    public IPage<SalesLedger> listBindableSalesLedger(Page page, SalesLedgerDto salesLedgerDto) {
+        // 璇ユ煡璇㈢敤 /*data_scope*/ 璺宠繃鏁版嵁鏉冮檺锛岃�� MP 榛樿浼氭妸 count 璇彞浼樺寲鎴愩�孲ELECT COUNT(*) FROM sales_ledger
+        // WHERE ...銆嶏紝浼樺寲鍚庢爣璁颁涪澶憋紝count 鍙嶈�岃杩藉姞鏉冮檺鏉′欢锛宼otal 浼氭瘮瀹為檯璁板綍灏戙�傚叧鎺� count 浼樺寲鍚�
+        // count 閫�鍖栨垚銆孲ELECT COUNT(*) FROM (鍘熷彞) TOTAL銆嶏紝鏍囪鍘熸牱淇濈暀
+        page.setOptimizeCountSql(false);
+        return stockInRecordMapper.bindableSalesLedgerPage(page, salesLedgerDto);
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int update(Long id, StockInRecordDto stockInRecordDto) {

--
Gitblit v1.9.3