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/resources/mapper/stock/StockOutRecordMapper.xml |   54 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index 784790c..dcd35e7 100644
--- a/src/main/resources/mapper/stock/StockOutRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -35,12 +35,18 @@
         pm.model,
         pm.unit,
         u.nick_name as createBy,
-        sl.sales_contract_no as salesContractNo
+        <!-- 娌瑰搧鍑哄簱鍙粦澶氫釜閿�鍞彴璐︼紙澶氬鎴凤級锛宻or.sales_ledger_id 鍙瓨棣栭」锛屾晠浠庣粦瀹氳〃姹囨�诲叏閮ㄥ悎鍚屽彿锛�
+             鏈粦瀹氱粦瀹氳〃鐨勫瓨閲忚浠嶉��鍥� sor.sales_ledger_id 鍏宠仈鐨勫崟涓悎鍚屽彿 -->
+        IFNULL(
+            (select group_concat(distinct slb.sales_contract_no separator ',')
+             from stock_out_record_sales_ledger b
+                      join sales_ledger slb on slb.id = b.sales_ledger_id
+             where b.stock_out_record_id = sor.id),
+            sl.sales_contract_no) as salesContractNo
         FROM stock_out_record as sor
         LEFT JOIN product_model as pm on sor.product_model_id = pm.id
         LEFT JOIN product as p on pm.product_id = p.id
         LEFT JOIN sys_user as u on sor.create_user = u.user_id
-        <!-- 缁戝畾浜嗛攢鍞彴璐︾殑鍑哄簱甯﹀嚭鍚堝悓鍙凤紱sales_ledger_id 鏈韩宸查殢 sor.* 杩斿洖 -->
         LEFT JOIN sales_ledger as sl on sl.id = sor.sales_ledger_id
         <where>
             <if test="params.timeStr != null and params.timeStr != ''">
@@ -140,37 +146,59 @@
         order by sor.id desc
     </select>
 
+    <!-- 璐㈠姟绠$悊 路 閿�鍞嚭搴撳彴璐︼紙鏀舵/寮�绁ㄥ�欓�夛級銆�
+         涓ょ被鏉ユ簮锛氣憼 record_type='13' 鐨勬墜宸ュ彂璐у崟鍑哄簱锛屽鎴�/鏄庣粏/鍙戣揣缂栧彿閮借蛋 shipping_info锛�
+         鈶� 娌瑰搧鍑哄簱锛坱ype 涓虹┖锛夋寜銆屽嚭搴撳崟脳瀹㈡埛銆嶆媶鍒扮粦瀹氳锛屼竴涓嚭搴撳崟缁戝嚑涓彴璐﹀氨鍑哄嚑琛岋紝
+         閲戦鍙畻璇ュ鎴峰垎鎽婄殑閭i儴鍒嗭紙b.quantity 脳 鍗曚环锛夛紝涓嶅啀鏄暣鍗曟暟閲忋��
+         鐢� LEFT JOIN 鑰屼笉鏄� UNION ALL锛欴ataScopeSqlInterceptor 鐪嬪埌 from 鍚庨潰绱ц窡 '(' 浼氭暣鏉℃斁琛岋紝
+         鎶婁袱鏉″垎鏀寘鎴愭淳鐢熻〃浼氳鍑哄簱鍗曠殑鏁版嵁鏉冮檺闈欓粯澶辨晥銆� -->
     <select id="listPageAccountSales" resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
     SELECT
         sor.id,
         sor.outbound_batches,
-        sl.customer_name,
+        IFNULL(b.customer_name, sl.customer_name) AS customerName,
         sor.create_time as shippingDate,
-        p.product_name,
-        pm.model as specification_model,
-        slp.tax_rate,
-        sor.stock_out_num * slp.tax_inclusive_unit_price as outboundAmount,
+        IFNULL(pb.product_name, p.product_name) AS productName,
+        IFNULL(pmb.model, pm.model) as specification_model,
+        IFNULL(slpb.tax_rate, slp.tax_rate) as tax_rate,
+        CASE
+            WHEN b.id IS NOT NULL THEN b.quantity * slpb.tax_inclusive_unit_price
+            ELSE sor.stock_out_num * slp.tax_inclusive_unit_price
+        END as outboundAmount,
         s.shipping_no,
-        sl.sales_contract_no
+        IFNULL(slb.sales_contract_no, sl.sales_contract_no) as sales_contract_no,
+        b.id AS bindingId,
+        IFNULL(b.customer_id, sl.customer_id) AS customer_id
         FROM stock_out_record sor
+        <!-- 鍙湁娌瑰搧鍑哄簱鎵嶅幓缁戠粦瀹氳〃锛涙墜宸ュ彂璐у崟鍑哄簱鐨� type 涔熸槸绌猴紝浣嗗畠 record_type='13' 涓旀病鏈夌粦瀹氳锛�
+             b.id 涓� NULL 鏃朵笅闈㈢粺涓�鍥炶惤鍒� shipping_info 閭d竴濂� -->
+        LEFT JOIN stock_out_record_sales_ledger b ON b.stock_out_record_id = sor.id
         left join shipping_info s on sor.record_id = s.id
         LEFT JOIN sales_ledger sl ON s.sales_ledger_id = sl.id
         LEFT JOIN sales_ledger_product slp ON s.sales_ledger_product_id = slp.id and slp.type = 1
+        LEFT JOIN sales_ledger slb ON slb.id = b.sales_ledger_id
+        LEFT JOIN sales_ledger_product slpb ON slpb.id = b.sales_ledger_product_id and slpb.type = 1
         left join product_model pm on slp.product_model_id = pm.id
         left join product p on pm.product_id = p.id
-        WHERE sor.record_type='13' and sor.approval_status=1
+        left join product_model pmb on sor.product_model_id = pmb.id
+        left join product pb on pmb.product_id = pb.id
+        WHERE sor.approval_status=1
+        AND (
+            sor.record_type='13'
+            OR (b.id IS NOT NULL AND (sor.type IS NULL OR sor.type = ''))
+        )
         <if test="req.outboundBatches != null and req.outboundBatches != ''">
             AND sor.outbound_batches LIKE CONCAT('%',#{req.outboundBatches},'%')
         </if>
         <if test="req.customerName != null and req.customerName != ''">
-            AND sl.customer_name LIKE CONCAT('%',#{req.customerName},'%')
+            AND IFNULL(b.customer_name, sl.customer_name) LIKE CONCAT('%',#{req.customerName},'%')
         </if>
         <if test="req.customerId != null ">
-            AND sl.customer_id = #{req.customerId}
+            AND IFNULL(b.customer_id, sl.customer_id) = #{req.customerId}
         </if>
         <if test="req.startDate != null and req.endDate != null">
-            AND s.shipping_date BETWEEN #{req.startDate} AND #{req.endDate}
+            AND IFNULL(s.shipping_date, sor.create_time) BETWEEN #{req.startDate} AND #{req.endDate}
         </if>
-        order by sor.id DESC
+        order by sor.id DESC, IFNULL(b.id, 0)
     </select>
 </mapper>

--
Gitblit v1.9.3