From bf4b42e868ea0a59ca576d70d60f0b20d9c4742d Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期三, 01 七月 2026 10:46:36 +0800
Subject: [PATCH] 采购入库没有带出对应的采购合同号(不用区分原材料、半成品、成品)
---
src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml | 83 +++++++++++++++++++++++++----------------
1 files changed, 51 insertions(+), 32 deletions(-)
diff --git a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
index c3d6b00..6a35890 100644
--- a/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
+++ b/src/main/resources/mapper/account/sales/AccountSalesCollectionMapper.xml
@@ -20,13 +20,17 @@
</resultMap>
<select id="listPageAccountSalesCollection"
resultType="com.ruoyi.account.bean.vo.sales.AccountSalesCollectionVo">
- select * from (select ascc.*,
+ select
+ A.* ,
+ if(asd.receipt_number is not null, true, false) as isAccountStatemen
+ from (select ascc.*,
c.customer_name,
GROUP_CONCAT(sour.outbound_batches SEPARATOR ',') AS outboundBatches
from account_sales_collection ascc
left join customer c on ascc.customer_id = c.id
left join stock_out_record sour on FIND_IN_SET(sour.id, ascc.stock_out_record_ids) > 0
GROUP BY ascc.id)A
+ left join account_statement_details asd on A.collection_number = asd.receipt_number
<where>
<if test="req.customerId != null">
AND A.customer_id = #{req.customerId}
@@ -41,7 +45,7 @@
AND A.collection_date BETWEEN #{req.startDate} AND #{req.endDate}
</if>
</where>
-
+ order by A.id desc
</select>
<select id="existsByStockOutRecordId" resultType="java.lang.Boolean">
SELECT COUNT(*) > 0
@@ -54,36 +58,51 @@
<select id="getOutboundBatchesByCustomer"
resultType="com.ruoyi.account.bean.vo.sales.SalesOutboundVo">
SELECT
- sor.id,
- sor.outbound_batches,
- sl.customer_name,
- 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,
- s.shipping_no,
- sl.sales_contract_no
- FROM stock_out_record sor
- 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 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_sales_collection 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
- )
-
- order by sor.id DESC
+ id,
+ outbound_batches,
+ customer_name,
+ shipping_date,
+ product_name,
+ specification_model,
+ tax_rate,
+ outbound_amount,
+ shipping_no,
+ sales_contract_no,
+ amount_received
+ FROM
+ (
+ SELECT
+ sor.id,
+ sor.outbound_batches,
+ sl.customer_name,
+ sor.create_time AS shipping_date,
+ p.product_name,
+ pm.model AS specification_model,
+ slp.tax_rate,
+ sor.stock_out_num * slp.tax_inclusive_unit_price AS outbound_amount,
+ s.shipping_no,
+ sl.sales_contract_no,
+ COALESCE ( SUM( acsc.collection_amount ), 0 ) AS amount_received
+ FROM
+ stock_out_record sor
+ 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 product_model pm ON slp.product_model_id = pm.id
+ LEFT JOIN product p ON pm.product_id = p.id
+ LEFT JOIN account_sales_collection acsc ON acsc.stock_out_record_ids = sor.id
+ WHERE
+ sor.record_type = '13'
+ AND sor.approval_status = 1
+ AND sl.customer_id = #{customerId}
+ GROUP BY
+ sor.outbound_batches
+ ORDER BY
+ sor.id
+ ) tempA
+ WHERE
+ amount_received < outbound_amount
</select>
<select id="selectIncomeStats" resultType="com.ruoyi.home.dto.IncomeExpenseAnalysisDto">
SELECT DATE_FORMAT(collection_date, #{dateFormat}) AS dateStr,
--
Gitblit v1.9.3