From 63ccaee5545740122a9d58983aa75d9da9de7530 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期一, 26 五月 2025 13:46:11 +0800
Subject: [PATCH] 回款登记功能修改

---
 src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
index f1038ae..7ee2762 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
@@ -11,6 +11,8 @@
 import com.ruoyi.sales.service.ReceiptPaymentService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.time.LocalDate;
@@ -68,7 +70,23 @@
      */
     @Override
     public IPage<ReceiptPaymentDto> receiptPaymentListPage(Page page, ReceiptPaymentDto receiptPaymentDto) {
-        return receiptPaymentMapper.receiptPaymentListPage(page, receiptPaymentDto);
+        // 璁$畻鍒嗛〉鍓峱age.current-1 * limit鏉℃暟鐨勭患鍚堣绠楀凡缁忔敹鍥炵殑鍥炴閲戦
+        // 璁$畻宸茬粡鍒嗛〉鐨勬潯鏁�
+        long total = (page.getCurrent() - 1) * page.getSize();
+        BigDecimal receiptAmount = receiptPaymentMapper.getReceiptAmount(receiptPaymentDto.getCustomerId(), total);
+        if(ObjectUtils.isEmpty(receiptAmount)){
+            receiptAmount = BigDecimal.ZERO;
+        }
+        IPage<ReceiptPaymentDto> iPage = receiptPaymentMapper.receiptPaymentListPage(page, receiptPaymentDto);
+        // 寮�绁ㄦ�婚噾棰�
+        BigDecimal invoiceTotal = CollectionUtils.isEmpty(iPage.getRecords()) ? BigDecimal.ZERO : iPage.getRecords().get(0).getInvoiceTotal();
+        // 褰撳墠搴旀敹閲戦
+        BigDecimal currentUnReceiptAmount = invoiceTotal.subtract(receiptAmount);
+        for (ReceiptPaymentDto record : iPage.getRecords()) {
+            currentUnReceiptAmount = currentUnReceiptAmount.subtract(record.getReceiptPaymentAmount());
+            record.setNoReceiptAmount(currentUnReceiptAmount);
+        }
+        return iPage;
     }
 
     /**

--
Gitblit v1.9.3