From 6df8411e720cfef1b474f178825bdee32ef71a59 Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期五, 20 三月 2026 15:06:35 +0800
Subject: [PATCH] 新增回馈进度表

---
 service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml |  131 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 129 insertions(+), 2 deletions(-)

diff --git a/service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml b/service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml
index 412abee..aba8560 100644
--- a/service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml
+++ b/service/src/main/resources/mapper/cwgl/ReceivableBillManagementMapper.xml
@@ -42,8 +42,54 @@
         <result property="deleted"    column="deleted"    />
     </resultMap>
 
+    <resultMap type="com.ruoyi.cwgl.domain.vo.ReceivableBillAgingAnalysisVo" id="ReceivableBillAgingAnalysisVoResult">
+        <result property="id"    column="id"    />
+        <result property="systemNo"    column="system_no"    />
+        <result property="billName"    column="bill_name"    />
+        <result property="customerName"    column="customer_name"    />
+        <result property="payee"    column="payee"    />
+        <result property="responsiblePerson"    column="responsible_person"    />
+        <result property="responsibleLeader"    column="responsible_leader"    />
+        <result property="settlementMethod"    column="settlement_method"    />
+        <result property="businessType"    column="business_type"    />
+        <result property="promotionRequirement"    column="promotion_requirement"    />
+        <result property="isInternalSettlement"    column="is_internal_settlement"    />
+        <result property="internalSettlementUnit"    column="internal_settlement_unit"    />
+        <result property="documentCount"    column="document_count"    />
+        <result property="totalAmount"    column="total_amount"    />
+        <result property="currency"    column="currency"    />
+        <result property="discountAmount"    column="discount_amount"    />
+        <result property="receivedAmount"    column="received_amount"    />
+        <result property="pendingAmount"    column="pending_amount"    />
+        <result property="exchangeRate"    column="exchange_rate"    />
+        <result property="cnyAmount"    column="cny_amount"    />
+        <result property="periodType"    column="period_type"    />
+        <result property="businessStartDate"    column="business_start_date"    />
+        <result property="businessEndDate"    column="business_end_date"    />
+        <result property="billingStartDate"    column="billing_start_date"    />
+        <result property="billingEndDate"    column="billing_end_date"    />
+        <result property="billGenerateDate"    column="bill_generate_date"    />
+        <result property="billSendDate"    column="bill_send_date"    />
+        <result property="billDueDate"    column="bill_due_date"    />
+        <result property="status"    column="status"    />
+        <result property="remark"    column="remark"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="dueIn30Days"    column="due_in_30_days"    />
+        <result property="overdueAmount"    column="overdue_amount"    />
+        <result property="overdue1To30Days"    column="overdue_1_to_30_days"    />
+        <result property="overdue31To60Days"    column="overdue_31_to_60_days"    />
+        <result property="overdue61To90Days"    column="overdue_61_to_90_days"    />
+        <result property="overdue91To180Days"    column="overdue_91_to_180_days"    />
+        <result property="overdue181To365Days"    column="overdue_181_to_365_days"    />
+        <result property="overdueOver1Year"    column="overdue_over_1_year"    />
+        <result property="overdueDays"    column="overdue_days"    />
+    </resultMap>
+
     <sql id="selectReceivableBillManagementVo">
-        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.payee, thisTab.responsible_person, thisTab.responsible_leader, thisTab.settlement_method, thisTab.business_type, thisTab.promotion_requirement, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
+        select thisTab.id, thisTab.system_no, thisTab.bill_name, thisTab.customer_name, thisTab.payee, thisTab.responsible_person, thisTab.responsible_leader, thisTab.settlement_method, thisTab.business_type, thisTab.promotion_requirement, thisTab.is_internal_settlement, thisTab.internal_settlement_unit, thisTab.document_count, thisTab.total_amount, thisTab.currency, thisTab.discount_amount, thisTab.received_amount, thisTab.pending_amount, thisTab.exchange_rate, thisTab.cny_amount, thisTab.period_type, thisTab.business_start_date, thisTab.business_end_date, thisTab.billing_start_date, thisTab.billing_end_date, thisTab.bill_generate_date, thisTab.bill_send_date, thisTab.bill_due_date, thisTab.due_in_30_days, thisTab.overdue_amount, thisTab.overdue_1_to_30_days, thisTab.overdue_31_to_60_days, thisTab.overdue_61_to_90_days, thisTab.overdue_91_to_180_days, thisTab.overdue_181_to_365_days, thisTab.overdue_over_1_year, thisTab.overdue_days, thisTab.status, thisTab.remark, thisTab.create_by, thisTab.create_time, thisTab.update_by, thisTab.update_time, thisTab.deleted from receivable_bill_management AS thisTab
     </sql>
     <sql id="selectReceivableBillManagementVoCount">
         select count(0) from receivable_bill_management as thisTab
@@ -310,10 +356,91 @@
             SUM(pending_amount) as totalPendingAmount
         FROM receivable_bill_management
         <where>
-            <include refid="whereCondition"/>
+            <if test="customerName != null  and customerName != ''"> and  customer_name like concat('%', #{customerName}, '%')</if>
+
         </where>
         GROUP BY customer_name
         ORDER BY customer_name
     </select>
 
+    <!-- 鏌ヨ搴旀敹璐﹀崟璐﹂緞鍒嗘瀽鍒楄〃 -->
+    <select id="selectReceivableBillAgingAnalysisList" parameterType="com.ruoyi.cwgl.domain.ReceivableBillManagement" resultMap="ReceivableBillAgingAnalysisVoResult">
+        <include refid="selectReceivableBillManagementVo"/>
+        <where>
+            <include refid="whereCondition"/>
+        </where>
+        ORDER BY customer_name, bill_due_date
+    </select>
+
+    <!-- 鎵归噺鏇存柊搴旀敹璐﹀崟璐﹂緞鍒嗘瀽鏁版嵁 -->
+    <update id="batchUpdateAgingAnalysisData">
+        UPDATE receivable_bill_management 
+        SET 
+            -- 鍙洿鏂板綋鍓嶆椂娈电殑鏁版嵁锛屽叾浠栨椂娈典繚鐣欏師鍊�
+            due_in_30_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date > CURDATE() 
+                     AND DATEDIFF(bill_due_date, CURDATE()) <= 30 
+                THEN pending_amount 
+                ELSE due_in_30_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_amount = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                THEN pending_amount 
+                ELSE overdue_amount  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            -- 鍙洿鏂板綋鍓嶉�炬湡鏃舵鐨勯噾棰濓紝鍏朵粬鏃舵淇濈暀鍘嗗彶鏁版嵁
+            overdue_1_to_30_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) BETWEEN 1 AND 30 
+                THEN pending_amount 
+                ELSE overdue_1_to_30_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_31_to_60_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) BETWEEN 31 AND 60 
+                THEN pending_amount 
+                ELSE overdue_31_to_60_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_61_to_90_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) BETWEEN 61 AND 90 
+                THEN pending_amount 
+                ELSE overdue_61_to_90_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_91_to_180_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) BETWEEN 91 AND 180 
+                THEN pending_amount 
+                ELSE overdue_91_to_180_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_181_to_365_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) BETWEEN 181 AND 365 
+                THEN pending_amount 
+                ELSE overdue_181_to_365_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_over_1_year = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                     AND DATEDIFF(CURDATE(), bill_due_date) &gt; 365 
+                THEN pending_amount 
+                ELSE overdue_over_1_year  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            overdue_days = CASE 
+                WHEN pending_amount > 0 AND bill_due_date IS NOT NULL 
+                     AND bill_due_date &lt;= CURDATE() 
+                THEN DATEDIFF(CURDATE(), bill_due_date) 
+                ELSE overdue_days  -- 淇濈暀鍘嗗彶鏁版嵁
+            END,
+            update_time = NOW()
+        WHERE pending_amount > 0
+    </update>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0