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/account/sales/AccountInvoiceApplicationMapper.xml | 73 ++++++++++++++++++++++++++----------
1 files changed, 53 insertions(+), 20 deletions(-)
diff --git a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
index 4121614..952f27c 100644
--- a/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountInvoiceApplicationMapper.xml
@@ -9,7 +9,11 @@
GROUP_CONCAT(sour.outbound_batches SEPARATOR ',') AS outboundBatches
from account_invoice_application aia
left join customer c on aia.customer_id = c.id
+ <!-- 鎵嬪伐鍙戣揣鍗曞嚭搴撴寜 stock_out_record_ids 鎵撅紝娌瑰搧鍑哄簱鎸夌粦瀹氳 stock_out_binding_ids 鍙嶆煡鎵�鍦ㄧ殑鍑哄簱鍗� -->
left join stock_out_record sour on FIND_IN_SET(sour.id, aia.stock_out_record_ids) > 0
+ OR EXISTS (select 1 from stock_out_record_sales_ledger b
+ where b.stock_out_record_id = sour.id
+ and FIND_IN_SET(b.id, aia.stock_out_binding_ids) > 0)
GROUP BY aia.id)A
<where>
<if test="req.customerId != null">
@@ -27,40 +31,55 @@
</where>
order by A.id desc
</select>
+ <!-- 鍙紑绁ㄧ殑閿�鍞嚭搴撳�欓�夈��
+ 鈶� record_type='13' 鐨勬墜宸ュ彂璐у崟鍑哄簱 鈫� b.id 涓� NULL锛岀敤 stock_out_record_ids 鍒ら噸锛�
+ 鈶� 娌瑰搧鍑哄簱锛坱ype 涓虹┖锛夋寜銆屽嚭搴撳崟脳瀹㈡埛銆嶆媶鍒扮粦瀹氳 鈫� 鐢� stock_out_binding_ids 鍒ら噸銆�
+ 涓や釜 id 绌洪棿閮芥槸灏忔暣鏁帮紝娣峰湪涓�鍒楅噷浼氭挒鍙凤紝鎵�浠ュ繀椤绘寜 b.id 鏄惁涓虹┖鍒嗗紑姣斻�� -->
<select id="getOutboundBatchesByCustomer"
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
+ 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
- and sl.customer_id=#{customerId}
-
- and sor.id NOT IN (
- SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(a.stock_out_record_ids, ',', n.n), ',', -1)
- FROM account_invoice_application a
- CROSS JOIN (
- SELECT 1 n UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL
- SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
- ) n
- WHERE n.n <= CHAR_LENGTH(a.stock_out_record_ids) - CHAR_LENGTH(REPLACE(a.stock_out_record_ids, ',', '')) + 1
- and a.status!=2
+ 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 = ''))
)
-
- order by sor.id DESC
+ AND IFNULL(b.customer_id, sl.customer_id) = #{customerId}
+ AND NOT EXISTS (
+ SELECT 1
+ FROM account_invoice_application a
+ WHERE a.status != 2
+ AND (
+ (b.id IS NULL AND FIND_IN_SET(sor.id, a.stock_out_record_ids) > 0)
+ OR (b.id IS NOT NULL AND FIND_IN_SET(b.id, a.stock_out_binding_ids) > 0)
+ )
+ )
+ order by sor.id DESC, IFNULL(b.id, 0)
</select>
<select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
SELECT COUNT(*) > 0
@@ -69,6 +88,17 @@
AND (
<foreach collection="stockOutRecordIds" item="id" separator=" OR ">
FIND_IN_SET(#{id}, stock_out_record_ids) > 0
+ </foreach>
+ )
+ </select>
+ <!-- 娌瑰搧鍑哄簱鐨勭粦瀹氳涓庡嚭搴撳崟鏄袱涓嫭绔� id 绌洪棿锛屽垽閲嶈鍒嗗紑鏌� -->
+ <select id="existsByStockOutBindingId" resultType="java.lang.Boolean">
+ SELECT COUNT(*) > 0
+ FROM account_invoice_application
+ WHERE status != 2
+ AND (
+ <foreach collection="stockOutBindingIds" item="id" separator=" OR ">
+ FIND_IN_SET(#{id}, stock_out_binding_ids) > 0
</foreach>
)
</select>
@@ -85,6 +115,9 @@
from account_invoice_application aia
left join customer c on aia.customer_id = c.id
left join stock_out_record sour on FIND_IN_SET(sour.id, aia.stock_out_record_ids) > 0
+ OR EXISTS (select 1 from stock_out_record_sales_ledger b
+ where b.stock_out_record_id = sour.id
+ and FIND_IN_SET(b.id, aia.stock_out_binding_ids) > 0)
left join account_sales_invoice asi on aia.id = asi.account_invoice_application_id
GROUP BY aia.id
)A
--
Gitblit v1.9.3