From d241b67a5728d4f2bb0d33e4921229a4bf15e250 Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期四, 05 六月 2025 14:11:42 +0800
Subject: [PATCH] 付款登记功能开发

---
 src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java |   43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
index 667df89..3f96818 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PaymentRegistrationServiceImpl.java
@@ -11,6 +11,7 @@
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.framework.security.LoginUser;
+import com.ruoyi.purchase.dto.PaymentHistoryRecordVo;
 import com.ruoyi.purchase.dto.PaymentLedgerDto;
 import com.ruoyi.purchase.dto.PaymentRegistrationDto;
 import com.ruoyi.purchase.mapper.*;
@@ -47,8 +48,6 @@
 
     private PurchaseLedgerMapper purchaseLedgerMapper;
 
-    private InvoicePurchaseMapper invoicePurchaseMapper;
-
     private SalesLedgerMapper salesLedgerMapper;
 
     private SupplierManageMapper supplierManageMapper;
@@ -83,7 +82,8 @@
             List<PaymentRegistration> paymentRegistrations = paymentRegistrationMapper.selectList(new QueryWrapper<PaymentRegistration>()
                     .eq("ticket_registration_id", registrationDto.getTicketRegistrationId()));
             BigDecimal total = paymentRegistrations.stream().map(PaymentRegistration::getCurrentPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-            registrationDto.setUnPaymentAmount(registrationDto.getInvoiceAmount().subtract(total));
+            BigDecimal invoiceAmount = (null != registrationDto.getInvoiceAmount())? registrationDto.getInvoiceAmount() : BigDecimal.ZERO;
+            registrationDto.setUnPaymentAmount(invoiceAmount.subtract(total));
         }
         return list;
     }
@@ -202,6 +202,7 @@
         for (SupplierManage supplierManage : supplierManages) {
             Map<String, Object> res = new HashMap<>();
             res.put("supplierName", supplierManage.getSupplierName());
+            res.put("supplierId", supplierManage.getId());
 
             // 搴斾粯閲戦璁$畻
             BigDecimal payableAmount = BigDecimal.ZERO;
@@ -267,7 +268,6 @@
                                             new LambdaQueryWrapper<ProductRecord>().eq(ProductRecord::getTicketRegistrationId, ticketRegistration.getId())
                                     ).stream()
                                     .map(ProductRecord::getTicketsNum)
-                                    .map(BigDecimal::new)
                                     .filter(Objects::nonNull)
                                     .reduce(BigDecimal.ZERO, BigDecimal::add);
                             detail.put("voteCount", voteCount);
@@ -344,6 +344,41 @@
         return result;
     }
 
+    /**
+     * 鏌ヨ浠樻鐧昏鍒楄〃
+     *
+     * @param paymentRegistrationDto 浠樻鐧昏
+     * @return 浠樻鐧昏闆嗗悎
+     */
+    @Override
+    public List<PaymentRegistrationDto> paymentHistoryList(PaymentRegistrationDto paymentRegistrationDto) {
+        return paymentRegistrationMapper.paymentHistoryList(paymentRegistrationDto);
+    }
+
+    /**
+     * 鏌ヨ渚涘簲鍟嗗線鏉ヨ褰�
+     * @param supplierId
+     * @return
+     */
+    @Override
+    public List<PaymentHistoryRecordVo> getPaymentRecordList(Long supplierId) {
+        List<PaymentHistoryRecordVo> paymentRecordList = paymentRegistrationMapper.getPaymentRecordList(supplierId);
+        if(!CollectionUtils.isEmpty(paymentRecordList)) {
+            // 搴斾粯閲戦璁$畻
+            BigDecimal amountTotal = BigDecimal.ZERO;
+            for (PaymentHistoryRecordVo paymentHistoryRecordVo : paymentRecordList) {
+                if(paymentHistoryRecordVo.getType() == 0){
+                    amountTotal = amountTotal.subtract(paymentHistoryRecordVo.getCurrentPaymentAmount());
+                }
+                if(paymentHistoryRecordVo.getType() == 1){
+                    amountTotal = amountTotal.add(paymentHistoryRecordVo.getInvoiceAmount());
+                }
+                paymentHistoryRecordVo.setPayableAmount(amountTotal);
+            }
+        }
+        return paymentRecordList;
+    }
+
     // 鎵归噺鏌ヨ閲囪喘鍙拌处锛堝綋鏈堬級
     private Map<Long, List<PurchaseLedger>> batchQueryPurchaseLedgers(List<Long> supplierIds, LocalDate startDate, LocalDate endDate) {
         LambdaQueryWrapper<PurchaseLedger> query = new LambdaQueryWrapper<>();

--
Gitblit v1.9.3