From bab4925a2f17275f819241aba7e014f5f730773c Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期二, 13 一月 2026 17:59:28 +0800
Subject: [PATCH] 新增确认接口

---
 service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java |  105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 0 deletions(-)

diff --git a/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java b/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java
index c0f7e38..2afdac7 100644
--- a/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java
+++ b/service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java
@@ -4,6 +4,8 @@
 
 import com.ruoyi.common.utils.DateUtils;
 import javax.annotation.Resource;
+
+import lombok.NonNull;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.stereotype.Service;
 import org.springframework.scheduling.annotation.Async;
@@ -16,9 +18,12 @@
 import com.ruoyi.common.core.service.BaseService;
 
 import com.ruoyi.cwgl.mapper.FundFlowClaimDetailMapper;
+import com.ruoyi.cwgl.mapper.FundFlowMapper;
 import com.ruoyi.cwgl.domain.FundFlowClaimDetail;
+import com.ruoyi.cwgl.domain.FundFlow;
 import com.ruoyi.cwgl.service.IFundFlowClaimDetailService;
 import com.ruoyi.common.core.text.Convert;
+import java.math.BigDecimal;
 
 /**
  * 璐﹀崟璁ら鏄庣粏Service涓氬姟灞傚鐞�
@@ -33,6 +38,9 @@
     protected final Logger logger = LoggerFactory.getLogger(getClass());
     @Resource
     private FundFlowClaimDetailMapper fundFlowClaimDetailMapper;
+    
+    @Resource
+    private FundFlowMapper fundFlowMapper;
 
 
     /**
@@ -179,4 +187,101 @@
     {
         return fundFlowClaimDetailMapper.deleteFundFlowClaimDetailById(id);
     }
+
+    /**
+     * 璐﹀崟璁ら
+     *
+     * @param fundFlowId 璧勯噾娴佹按ID
+     * @param claimDetails 璐﹀崟璁ら鏄庣粏鍒楄〃
+     * @return 缁撴灉
+     */
+    @Override
+    public int claimBill(Integer fundFlowId, List<FundFlowClaimDetail> claimDetails)
+    {
+        if (fundFlowId == null) {
+            throw new RuntimeException("璧勯噾娴佹按ID涓嶈兘涓虹┖");
+        }
+        
+        if (claimDetails == null || claimDetails.isEmpty()) {
+            throw new RuntimeException("璁ら鏄庣粏鍒楄〃涓嶈兘涓虹┖");
+        }
+        
+        // 楠岃瘉璁ら鏄庣粏鐨勫繀濉瓧娈�
+        for (FundFlowClaimDetail claimDetail : claimDetails) {
+            if (claimDetail.getClaimAmount() == null || claimDetail.getClaimAmount().compareTo(BigDecimal.ZERO) <= 0) {
+                throw new RuntimeException("璁ら閲戦蹇呴』澶т簬0");
+            }
+        }
+        
+        // 鏌ヨ璧勯噾娴佹按淇℃伅
+        FundFlow fundFlow = fundFlowMapper.selectFundFlowById(fundFlowId);
+        String newStatus = getString(fundFlowId, claimDetails, fundFlow);
+
+        // 鏇存柊璧勯噾娴佹按鐘舵��
+        fundFlow.setStatus(newStatus);
+        fundFlow.setUpdateTime(DateUtils.getNowDate());
+        int updateResult = fundFlowMapper.updateFundFlow(fundFlow);
+        if (updateResult <= 0) {
+            throw new RuntimeException("鏇存柊璧勯噾娴佹按鐘舵�佸け璐ワ紝ID: " + fundFlowId);
+        }
+        
+        // 鍏堝垹闄よ璧勯噾娴佹按ID涓嬬殑鎵�鏈夎棰嗘槑缁嗭紙閬垮厤閲嶅璁ら锛�
+        fundFlowClaimDetailMapper.deleteFundFlowClaimDetailByFundFlowId(fundFlowId);
+        
+        // 鎵归噺淇濆瓨鎵�鏈夎处鍗曡棰嗘槑缁�
+        for (FundFlowClaimDetail claimDetail : claimDetails) {
+            // 璁剧疆璧勯噾娴佹按ID
+            claimDetail.setFundFlowId(fundFlowId);
+            // 璁剧疆璁ら鏃ユ湡
+            claimDetail.setClaimDate(DateUtils.getNowDate());
+            // 璁剧疆鍒涘缓鏃堕棿
+            claimDetail.setCreateTime(DateUtils.getNowDate());
+        }
+        
+        int insertResult = fundFlowClaimDetailMapper.insertFundFlowClaimDetailBatch(claimDetails);
+        return insertResult;
+    }
+
+/**
+ * 鏍规嵁璧勯噾娴佹按ID銆佽棰嗚鎯呭垪琛ㄥ拰璧勯噾娴佹按瀵硅薄鑾峰彇鐘舵�佸瓧绗︿覆
+ * @param fundFlowId 璧勯噾娴佹按ID锛岀敤浜庢爣璇嗙壒瀹氱殑璧勯噾娴佹按璁板綍
+ * @param claimDetails 璁ら璇︽儏鍒楄〃锛屽寘鍚墍鏈夎棰嗛噾棰濅俊鎭�
+ * @param fundFlow 璧勯噾娴佹按瀵硅薄锛屽寘鍚氦鏄撻噾棰濈瓑鍏抽敭淇℃伅
+ * @return 杩斿洖澶勭悊鍚庣殑鐘舵�佸瓧绗︿覆
+ * @throws RuntimeException 褰撹祫閲戞祦姘村璞′负null鏃舵姏鍑哄紓甯�
+ */
+    private static @NonNull String getString(Integer fundFlowId, List<FundFlowClaimDetail> claimDetails, FundFlow fundFlow) {
+    // 妫�鏌ヨ祫閲戞祦姘村璞℃槸鍚︿负绌猴紝濡傛灉涓虹┖鍒欐姏鍑哄紓甯�
+        if (fundFlow == null) {
+            throw new RuntimeException("璧勯噾娴佹按涓嶅瓨鍦紝ID: " + fundFlowId);
+        }
+
+        // 璁$畻鎬昏棰嗛噾棰�
+        BigDecimal totalClaimAmount = BigDecimal.ZERO;
+        for (FundFlowClaimDetail claimDetail : claimDetails) {
+            totalClaimAmount = totalClaimAmount.add(claimDetail.getClaimAmount());
+        }
+
+        // 楠岃瘉鎬昏棰嗛噾棰濅笉鑳借秴杩囦氦鏄撻噾棰�
+        String newStatus = getString(fundFlow, totalClaimAmount);
+        return newStatus;
+    }
+
+    private static @NonNull String getString(FundFlow fundFlow, BigDecimal totalClaimAmount) {
+        BigDecimal transactionAmount = fundFlow.getTransactionAmount();
+        if (totalClaimAmount.compareTo(transactionAmount) > 0) {
+            throw new RuntimeException("鎬昏棰嗛噾棰濅笉鑳借秴杩囦氦鏄撻噾棰濄�備氦鏄撻噾棰�: " + transactionAmount + ", 鎬昏棰嗛噾棰�: " + totalClaimAmount);
+        }
+
+        // 鏍规嵁鎬昏棰嗛噾棰濅笌浜ゆ槗閲戦鐨勬瘮杈冭缃姸鎬�
+        String newStatus;
+        if (totalClaimAmount.compareTo(transactionAmount) < 0) {
+            // 鎬昏棰嗛噾棰濆皬浜庝氦鏄撻噾棰濓紝鐘舵�佹敼涓�2锛堥儴鍒嗚棰嗭級
+            newStatus = "2";
+        } else {
+            // 鎬昏棰嗛噾棰濈瓑浜庝氦鏄撻噾棰濓紝鐘舵�佹敼涓�3锛堝畬鍏ㄨ棰嗭級
+            newStatus = "3";
+        }
+        return newStatus;
+    }
 }

--
Gitblit v1.8.0