From 277b5047d00a3e9094bafd5ecb078976fbf6a92d Mon Sep 17 00:00:00 2001
From: yaowanxin <3588231647@qq.com>
Date: 星期四, 08 一月 2026 18:59:04 +0800
Subject: [PATCH] 华玺砂浆转移-采购代码、发货和发货审核、报修和报修审核、采购模板,查询采购模板接口、财务管理的存货核算数据接口、财务管理的固定资产核算获取台账接口、采购审批,接口、客户分类字段、采购台账字段,实现采购异常记录的添加接口、黑名单,添加资质管理字段,可上传资质文件-至军泰伟业

---
 src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 54 insertions(+), 4 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 fe9550b..48056a9 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/ReceiptPaymentServiceImpl.java
@@ -10,8 +10,10 @@
 import com.ruoyi.sales.dto.InvoiceLedgerDto;
 import com.ruoyi.sales.dto.ReceiptPaymentDto;
 import com.ruoyi.sales.dto.ReceiptPaymentExeclDto;
+import com.ruoyi.sales.mapper.InvoiceLedgerMapper;
 import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
 import com.ruoyi.sales.mapper.SalesLedgerMapper;
+import com.ruoyi.sales.pojo.InvoiceLedger;
 import com.ruoyi.sales.pojo.ReceiptPayment;
 import com.ruoyi.sales.pojo.SalesLedger;
 import com.ruoyi.sales.service.ReceiptPaymentService;
@@ -35,6 +37,8 @@
 
     @Autowired
     private SalesLedgerMapper salesLedgerMapper;
+    @Autowired
+    private InvoiceLedgerMapper invoiceLedgerMapper;
 
     /**
      * 鍥炴鐧昏鏂板
@@ -43,9 +47,27 @@
      */
     @Override
     public int receiptPaymentSaveOrUpdate(ReceiptPayment receiptPayment) {
+        ReceiptPayment byId = receiptPayment;
+        if (!ObjectUtils.isEmpty(receiptPayment.getId())){
+             byId = this.getById(receiptPayment.getId());
+        }
+        InvoiceLedger invoiceLedger = invoiceLedgerMapper.selectById(byId.getInvoiceLedgerId());
+        Page<ReceiptPaymentDto> objectPage = new Page<>();
+        ReceiptPaymentDto receiptPaymentDto = new ReceiptPaymentDto();
+        receiptPaymentDto.setInvoiceLedgerId(invoiceLedger.getId());
+        IPage<ReceiptPaymentDto> receiptPaymentDtoIPage = receiptPaymentMapper.bindInvoiceNoRegPage(objectPage, receiptPaymentDto);
+        ReceiptPaymentDto receiptPaymentDto1 = receiptPaymentDtoIPage.getRecords().get(0);
+        if (!ObjectUtils.isEmpty(byId.getId())){
+            receiptPaymentDto1.setNoReceiptAmount(receiptPaymentDto1.getNoReceiptAmount().add(byId.getReceiptPaymentAmount()));
+        }
+        if (receiptPaymentDto1.getNoReceiptAmount().compareTo(receiptPayment.getReceiptPaymentAmount())<0){
+            throw new RuntimeException("鏈鍥炴閲戦涓嶈兘澶т簬寰呭洖娆鹃噾棰�");
+        }
         if(null==receiptPayment.getId()){
+
             return receiptPaymentMapper.insert(receiptPayment);
         }else {
+
             return receiptPaymentMapper.updateById(receiptPayment);
         }
     }
@@ -139,9 +161,25 @@
     @Override
     public IPage<ReceiptPaymentDto> bindInvoiceNoRegPage(Page page, ReceiptPaymentDto receiptPaymentDto) {
         IPage<ReceiptPaymentDto> receiptPaymentDtoIPage = receiptPaymentMapper.bindInvoiceNoRegPage(page, receiptPaymentDto);
-        if (receiptPaymentDto.getStatus()) {
-            receiptPaymentDtoIPage.getRecords().removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getNoReceiptAmount()));
-        }
+//        if (receiptPaymentDto.getStatus()) {
+//            long count = receiptPaymentDtoIPage.getRecords()
+//                    .stream()
+//                    .filter(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getNoReceiptAmount()))
+//                    .count();
+//            receiptPaymentDtoIPage
+//                    .getRecords()
+//                    .removeIf(receiptPaymentDto1 -> new BigDecimal("0.00").equals(receiptPaymentDto1.getNoReceiptAmount()));
+//            receiptPaymentDtoIPage.setTotal(receiptPaymentDtoIPage.getTotal() - count);
+//        }
+        receiptPaymentDtoIPage.getRecords().forEach(item -> {
+            // 姣旇緝鍥炴閲戦 == 寰呭洖娆鹃噾棰�
+            if (item.getInvoiceTotal().compareTo(item.getReceiptPaymentAmountTotal()) == 0) {
+                item.setStatusName("宸插畬鎴愬洖娆�");
+            }else{
+                item.setStatusName("鏈畬鎴愬洖娆�");
+            }
+
+        });
         return receiptPaymentDtoIPage;
     }
 
@@ -247,7 +285,19 @@
             customerInteractionDto.setUnReceiptAmount(amountTotal);
             result.add(customerInteractionDto);
         }
-        return result;
+        ArrayList<CustomerInteractionDto> newResult = new ArrayList<>();
+        for (int i = 0; i < result.size(); i++) {
+            CustomerInteractionDto customerInteractionDto = result.get(i);
+            if (i == 0) {
+                customerInteractionDto.setUnReceiptAmount(customerInteractionDto.getInvoiceAmount().subtract(customerInteractionDto.getReceiptAmount()));
+            }else {
+                CustomerInteractionDto customerInteractionDto1 = result.get(i-1);
+                customerInteractionDto.setUnReceiptAmount(customerInteractionDto1.getUnReceiptAmount()
+                        .add(customerInteractionDto.getInvoiceAmount()).subtract(customerInteractionDto.getReceiptAmount()));
+            }
+            newResult.add(customerInteractionDto);
+        }
+        return newResult;
     }
 
     /**

--
Gitblit v1.9.3