From ccc9d4533bc7b696f6d539720a6052abc44ff7a5 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期日, 11 十月 2026 23:46:17 +0800
Subject: [PATCH] fix: 添加设备名称字段并修复多个查询的排序和分组问题
---
src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml | 34 ++++++++++++++++++++++++----------
1 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
index c5c007e..8de052d 100644
--- a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -181,32 +181,45 @@
AND t4.purchase_contract_number LIKE CONCAT('%',#{params.purchaseContractNumber},'%')
</if>
</where>
- ORDER BY T1.payment_date,T1.create_time DESC
+ <!-- 2026-10-13 闇�姹傦細浠樻娴佹按鎸変粯娆炬棩鏈熷�掑簭锛堝師鏉ュ彧鍐欎簡 payment_date 娌″啓鏂瑰悜锛岄粯璁ゅ崌搴忥紝鏈�鏃╃殑鍦ㄦ渶涓婇潰锛� -->
+ ORDER BY T1.payment_date DESC, T1.id DESC
</select>
<select id="supplierNameListPage" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
SELECT
T1.supplier_id,
T1.supplier_name,
- SUM(contract_amount) AS invoiceAmount,
- IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
- IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount
+ IFNULL(SUM(T1.contract_amount), 0) AS invoiceAmount,
+ IFNULL(SUM(T2.paid), 0) AS paymentAmount,
+ IFNULL(SUM(T1.contract_amount), 0) - IFNULL(SUM(T2.paid), 0) AS payableAmount
FROM purchase_ledger T1
- LEFT JOIN payment_registration T2 ON T1.id = T2.purchase_ledger_id
+ <!-- 2026-10-13 淇锛氬師鏉ョ洿鎺� LEFT JOIN payment_registration 鍐� SUM(contract_amount)锛�
+ 涓�绗旈噰璐悎鍚屾湁鍑犵瑪浠樻锛屽悎鍚岄灏辫閲嶅绱姞鍑犳锛堜緵搴斿晢寰�鏉ラ〉銆屽悎鍚岄噾棰�/搴斾粯閲戦銆嶅洜姝よ櫄楂橈級銆�
+ 鏀规垚鍏堟寜鍙拌处姹囨�讳粯娆惧啀 JOIN銆� -->
+ LEFT JOIN (
+ SELECT purchase_ledger_id, SUM(current_payment_amount) AS paid
+ FROM payment_registration WHERE purchase_ledger_id IS NOT NULL GROUP BY purchase_ledger_id
+ ) T2 ON T2.purchase_ledger_id = T1.id
<where>
<if test="req.supplierName != null and req.supplierName != '' ">
T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
</if>
</where>
- GROUP BY T1.supplier_name
+ GROUP BY T1.supplier_id, T1.supplier_name
</select>
<select id="supplierNameListPageDetails" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
SELECT
T1.supplier_id,
T1.supplier_name,
- SUM(contract_amount) AS invoiceAmount,
- IFNULL( SUM(T2.current_payment_amount) , 0 ) AS paymentAmount,
- IFNULL((IFNULL(SUM(contract_amount),0) - IFNULL(SUM(T2.current_payment_amount),0)),0) AS payableAmount,
+ T1.contract_amount AS invoiceAmount,
+ IFNULL(SUM(T2.current_payment_amount), 0) AS paymentAmount,
+ <!-- 2026-10-13 淇锛氬師鏉ュ啓鐨勬槸銆屽悎鍚岄 鈭� 鏈棩鏈熻繖涓�绗斾粯娆俱�嶏紝鍐嶅彔鍔� GROUP BY payment_date锛�
+ 涓�绗斿悎鍚屾湁鍑犵瑪浠樻灏辨媶鎴愬嚑琛屻�佹瘡琛屼竴涓亣鐨�"搴斾粯"锛堜緥濡� CG20260523002 宸插叏棰濅粯娆撅紝
+ 鍗存樉绀哄簲浠� 18524.07锛夈�傚簲浠橀噾棰濆簲褰撴槸**璇ュ悎鍚屽綋鍓嶇湡姝g殑鏈粯娆鹃 = 鍚堝悓棰� 鈭� 鍏ㄩ儴浠樻**銆� -->
+ GREATEST(T1.contract_amount - IFNULL((
+ SELECT SUM(T3.current_payment_amount) FROM payment_registration T3
+ WHERE T3.purchase_ledger_id = T1.id
+ ), 0), 0) AS payableAmount,
T1.purchase_contract_number,
T2.payment_date
FROM purchase_ledger T1
@@ -217,7 +230,8 @@
T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
</if>
</where>
- GROUP BY T1.purchase_contract_number,T2.payment_date
+ GROUP BY T1.id, T1.supplier_id, T1.supplier_name, T1.contract_amount, T1.purchase_contract_number, T2.payment_date
+ ORDER BY T1.entry_date ASC, T2.payment_date ASC
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3