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 | 146 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 146 insertions(+), 0 deletions(-)
diff --git a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
index c4636e5..8de052d 100644
--- a/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
+++ b/src/main/resources/mapper/purchase/PaymentRegistrationMapper.xml
@@ -88,4 +88,150 @@
where pr.id = #{id}
</select>
+ <select id="paymentHistoryList" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
+ SELECT
+ T1.payment_date,
+ T2.supplier_name,
+ T1.current_payment_amount,
+ T1.payment_method,
+ T3.nick_name AS registrant,
+ T1.registrationt_date
+ FROM
+ payment_registration T1
+ LEFT JOIN
+ supplier_manage T2 ON T1.supplier_id = T2.id
+ LEFT JOIN
+ sys_user T3 ON T3.user_id = T1.registrant_id
+ <where>
+ <if test="params.searchText != null and params.searchText != '' ">
+ AND T2.supplier_name LIKE CONCAT('%',#{params.searchText},'%')
+ </if>
+ </where>
+ ORDER BY T1.payment_date,T1.create_time DESC
+ </select>
+
+ <select id="countPaymentTotalByTicketRegId" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
+ SELECT
+ IFNULL(SUM(current_payment_amount),0) AS paymentAmountTotal,
+ ticket_registration_id
+ FROM
+ payment_registration
+ <where>
+ ticket_registration_id IN
+ <foreach collection="ticketRegistrationIds" separator="," open="(" close=")" item="item">
+ #{item}
+ </foreach>
+ </where>
+ GROUP BY ticket_registration_id
+ </select>
+
+ <select id="getPaymentRecordList" resultType="com.ruoyi.purchase.dto.PaymentHistoryRecordVo">
+ SELECT * FROM(
+ SELECT
+ T1.issue_date AS happenTime,
+ IFNULL(T1.invoice_amount,0) AS invoiceAmount,
+ '1' AS type,
+ 0 AS currentPaymentAmount
+ FROM
+ ticket_registration T1
+ LEFT JOIN purchase_ledger T2 ON T1.purchase_ledger_id = T2.id
+ WHERE T2.supplier_id = #{supplierId}
+ UNION
+ SELECT
+ payment_date AS happenTime,
+ 0 AS invoiceAmount,
+ '0' AS type,
+ current_payment_amount AS currentPaymentAmount
+ FROM payment_registration
+ WHERE supplier_id = #{supplierId}
+ ) T1
+ ORDER BY T1.happenTime ASC
+
+ </select>
+
+ <select id="paymentHistoryListPage" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
+ SELECT
+ T1.id,
+ T1.payment_date,
+ T2.supplier_name,
+ T1.current_payment_amount,
+ T1.payment_method,
+ T3.nick_name AS registrant,
+ T1.registrationt_date,
+ t4.purchase_contract_number,
+ t5.invoice_amount,
+ t5.invoice_number
+ FROM
+ payment_registration T1
+ LEFT JOIN purchase_ledger t4 ON t4.id = T1.purchase_ledger_id
+ LEFT JOIN supplier_manage T2 ON T1.supplier_id = T2.id
+ LEFT JOIN sys_user T3 ON T3.user_id = T1.registrant_id
+ left join ticket_registration t5 on t5.id = T1.ticket_registration_id
+ <where>
+ <if test="params.searchText != null and params.searchText != '' ">
+ AND T2.supplier_name LIKE CONCAT('%',#{params.searchText},'%')
+ </if>
+ <if test="params.paymentDateStart != null and params.paymentDateStart !='' ">
+ AND T1.payment_date >= date_format(#{params.paymentDateStart},'%Y-%m-%d')
+ </if>
+ <if test="params.paymentDateEnd != null and params.paymentDateEnd !='' ">
+ AND T1.payment_date <= date_format(#{params.paymentDateEnd},'%Y-%m-%d')
+ </if>
+ <if test="params.purchaseContractNumber != null and params.purchaseContractNumber !='' ">
+ AND t4.purchase_contract_number LIKE CONCAT('%',#{params.purchaseContractNumber},'%')
+ </if>
+ </where>
+ <!-- 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,
+ 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
+ <!-- 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_id, T1.supplier_name
+ </select>
+
+ <select id="supplierNameListPageDetails" resultType="com.ruoyi.purchase.dto.PaymentRegistrationDto">
+ SELECT
+ T1.supplier_id,
+ T1.supplier_name,
+ 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
+ INNER JOIN payment_registration T2 ON T1.id = T2.purchase_ledger_id
+ <where>
+ T1.supplier_id = #{req.supplierId}
+ <if test="req.supplierName != null and req.supplierName != '' ">
+ T1.supplier_name LIKE CONCAT ('%',#{req.supplierName},'%')
+ </if>
+ </where>
+ 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