From 1317587cd162c419b4ae53d55454d79f0560d1c3 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 五月 2026 15:41:54 +0800
Subject: [PATCH] fix(Account): 校验累计付款金额不超过付款申请金额

---
 src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
index 14936f2..b9953a0 100644
--- a/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/purchase/AccountPurchasePaymentServiceImpl.java
@@ -8,8 +8,10 @@
 import com.ruoyi.account.bean.dto.purchase.AccountPurchasePaymentDto;
 import com.ruoyi.account.bean.vo.purchase.AccountPurchasePaymentVo;
 import com.ruoyi.account.mapper.AccountStatementDetailsMapper;
+import com.ruoyi.account.mapper.purchase.AccountPaymentApplicationMapper;
 import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper;
 import com.ruoyi.account.pojo.AccountStatementDetails;
+import com.ruoyi.account.pojo.purchase.AccountPaymentApplication;
 import com.ruoyi.account.pojo.purchase.AccountPurchasePayment;
 import com.ruoyi.account.service.purchase.AccountPurchasePaymentService;
 import com.ruoyi.common.exception.ServiceException;
@@ -19,6 +21,7 @@
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.List;
@@ -39,6 +42,7 @@
     private static final DateTimeFormatter CODE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyMMddHHmmss");
     private final AccountPurchasePaymentMapper accountPurchasePaymentMapper;
     private final AccountStatementDetailsMapper accountStatementDetailsMapper;
+    private final AccountPaymentApplicationMapper accountPaymentApplicationMapper;
 
     @Override
     public IPage<AccountPurchasePaymentVo> listPageAccountPurchasePayment(Page page, AccountPurchasePaymentDto accountPurchasePaymentDto) {
@@ -50,6 +54,13 @@
         if (StringUtils.isEmpty(accountPurchasePayment.getPaymentNumber())) {
             accountPurchasePayment.setPaymentNumber(genAccountPurchasePaymentNo());
         }
+        //鏍¢獙绱浠樻閲戦涓嶈兘瓒呰繃鐢宠閲戦
+        AccountPaymentApplication accountPaymentApplication = accountPaymentApplicationMapper.selectById(accountPurchasePayment.getAccountPaymentApplicationId());
+        List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery().eq(AccountPurchasePayment::getAccountPaymentApplicationId, accountPurchasePayment.getAccountPaymentApplicationId()));
+        BigDecimal totalPaymentAmount = accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+        if (accountPaymentApplication.getPaymentAmount().compareTo(totalPaymentAmount) < 0) {
+            throw new ServiceException("绱浠樻閲戦涓嶈兘瓒呰繃鐢宠閲戦");
+        }
         return save(accountPurchasePayment);
     }
 

--
Gitblit v1.9.3