From b991ccbe475c50390eebd4a3253162fc6b4a9b2c Mon Sep 17 00:00:00 2001
From: wujianwei <wjw@11.com>
Date: 星期四, 15 一月 2026 10:26:36 +0800
Subject: [PATCH] 新增日志
---
service/src/main/java/com/ruoyi/cwgl/service/impl/FundFlowClaimDetailServiceImpl.java | 147 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 142 insertions(+), 5 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 54a98f0..bcc23d9 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
@@ -21,11 +21,13 @@
import com.ruoyi.cwgl.mapper.FundFlowMapper;
import com.ruoyi.cwgl.domain.FundFlowClaimDetail;
import com.ruoyi.cwgl.domain.FundFlow;
+import com.ruoyi.cwgl.domain.FundFlowLog;
import com.ruoyi.cwgl.domain.ReceivableBillSettlementDetail;
import com.ruoyi.cwgl.domain.PayableBillSettlementDetail;
import com.ruoyi.cwgl.domain.ReceivableBillManagement;
import com.ruoyi.cwgl.domain.PayableBillManagement;
import com.ruoyi.cwgl.service.IFundFlowClaimDetailService;
+import com.ruoyi.cwgl.service.IFundFlowLogService;
import com.ruoyi.cwgl.service.IReceivableBillSettlementDetailService;
import com.ruoyi.cwgl.service.IPayableBillSettlementDetailService;
import com.ruoyi.cwgl.service.IReceivableBillManagementService;
@@ -62,6 +64,9 @@
@Resource
private IPayableBillManagementService payableBillManagementService;
+
+ @Resource
+ private IFundFlowLogService fundFlowLogService;
/**
@@ -195,9 +200,65 @@
@Override
public int deleteFundFlowClaimDetailByIds(Integer[] ids)
{
-
-
- return fundFlowClaimDetailMapper.deleteFundFlowClaimDetailByIds(ids);
+ if (ids == null || ids.length == 0) {
+ throw new RuntimeException("鍒犻櫎鐨勮棰嗘槑缁咺D涓嶈兘涓虹┖");
+ }
+
+ // 鐢变簬鍒犻櫎鍙細鏈変竴鏉¤褰曪紝鍙栫涓�鏉¤繘琛屽鐞�
+ Integer id = ids[0];
+ FundFlowClaimDetail claimDetail = fundFlowClaimDetailMapper.selectFundFlowClaimDetailById(id);
+ if (claimDetail == null) {
+ throw new RuntimeException("鏈壘鍒拌鍒犻櫎鐨勮棰嗘槑缁嗚褰曪紝ID: " + id);
+ }
+
+ Integer fundFlowId = claimDetail.getFundFlowId();
+ BigDecimal deleteAmount = claimDetail.getClaimAmount();
+
+ // 鏌ヨ璧勯噾娴佹按淇℃伅
+ FundFlow fundFlow = fundFlowMapper.selectFundFlowById(fundFlowId);
+ if (fundFlow == null) {
+ throw new RuntimeException("璧勯噾娴佹按涓嶅瓨鍦紝ID: " + fundFlowId);
+ }
+
+ // 鏇存柊璧勯噾娴佹按鐨勫凡璁ら閲戦
+ BigDecimal newClaimedAmount = fundFlow.getClaimedAmount().subtract(deleteAmount);
+ if (newClaimedAmount.compareTo(BigDecimal.ZERO) < 0) {
+ newClaimedAmount = BigDecimal.ZERO;
+ }
+
+ // 鏍规嵁鏂扮殑璁ら閲戦璁剧疆鐘舵��
+ String newStatus =fundFlow.getStatus();
+ if (newClaimedAmount.compareTo(BigDecimal.ZERO) == 0) {
+ // 宸茶棰嗛噾棰濅负0锛岀姸鎬佹敼涓�1锛堟湭璁ら锛�
+ newStatus = "1";
+ } else if (newClaimedAmount.compareTo(fundFlow.getTransactionAmount()) < 0) {
+ // 宸茶棰嗛噾棰濆皬浜庝氦鏄撻噾棰濓紝鐘舵�佹敼涓�2锛堥儴鍒嗚棰嗭級
+ newStatus = "2";
+ }
+
+ // 鏇存柊璧勯噾娴佹按鐘舵�佸拰宸茶棰嗛噾棰�
+ fundFlow.setStatus(newStatus);
+ fundFlow.setClaimedAmount(newClaimedAmount);
+ fundFlow.setUpdateTime(DateUtils.getNowDate());
+ int updateResult = fundFlowMapper.updateFundFlow(fundFlow);
+ if (updateResult <= 0) {
+ throw new RuntimeException("鏇存柊璧勯噾娴佹按鐘舵�佸け璐ワ紝ID: " + fundFlowId);
+ }
+
+ // 鍒犻櫎缁撶畻鏄庣粏骞舵洿鏂拌处鍗曠姸鎬�
+ deleteSettlementDetailsAndUpdateBillStatus(claimDetail,fundFlow);
+
+ int result = fundFlowClaimDetailMapper.deleteFundFlowClaimDetailByIds(ids);
+
+ // 璁板綍鎿嶄綔鏃ュ織
+ if (result > 0) {
+ FundFlowLog log = new FundFlowLog();
+ log.setFlowId(fundFlowId);
+ log.setOperation("鍒犻櫎璐﹀崟璁ら鏄庣粏锛岃处鍗曠紪鍙凤細" + claimDetail.getBillNo() + "锛岃棰嗛噾棰濓細" + deleteAmount + "锛岃祫閲戞祦姘村彿锛�" + fundFlow.getBankFlowNo());
+ fundFlowLogService.insertFundFlowLog(log);
+ }
+
+ return result;
}
/**
@@ -268,9 +329,14 @@
// 鏂板锛氬垱寤虹粨绠楁槑缁嗗苟鏇存柊璐﹀崟鐘舵��
if (insertResult > 0) {
-
createSettlementDetailsAndUpdateBillStatus(claimDetail, fundFlow);
+
+ // 璁板綍鎿嶄綔鏃ュ織
+ FundFlowLog log = new FundFlowLog();
+ log.setFlowId(fundFlowId);
+ log.setOperation("鏂板璐﹀崟璁ら鏄庣粏锛岃处鍗曠紪鍙凤細" + claimDetail.getBillNo() + "锛岃棰嗛噾棰濓細" + claimAmount + "锛岃祫閲戞祦姘村彿锛�" + fundFlow.getBankFlowNo());
+ fundFlowLogService.insertFundFlowLog(log);
}
return insertResult;
@@ -326,7 +392,7 @@
BigDecimal claimAmount = claimDetail.getClaimAmount();
Integer claimDetailId = claimDetail.getId();
- // 鏍规嵁鍏宠仈浼佷笟绫诲瀷鍒ゆ柇鏄簲鏀惰处鍗曡繕鏄簲浠樿处鍗�
+ // 鏍规嵁鏀舵敮鏍囪瘑鍊熻捶鏍囧織鍒ゆ柇鏄簲鏀惰处鍗曡繕鏄簲浠樿处鍗�
if (fundFlow.getIncomeExpenseFlag().equals(0)) {
// 搴旀敹璐﹀崟
createReceivableSettlementDetail(billNo, claimAmount, fundFlow, claimDetailId);
@@ -399,5 +465,76 @@
}
}
+ /**
+ * 鍒犻櫎缁撶畻鏄庣粏骞舵洿鏂拌处鍗曠姸鎬�
+ */
+ private void deleteSettlementDetailsAndUpdateBillStatus(FundFlowClaimDetail claimDetail, FundFlow fundFlow) {
+ String billNo = claimDetail.getBillNo();
+ Integer claimDetailId = claimDetail.getId();
+
+ try {
+
+
+ // 鏍规嵁鏀舵敮鏍囪瘑鍊熻捶鏍囧織鍒ゆ柇鏄簲鏀惰处鍗曡繕鏄簲浠樿处鍗�
+ if (fundFlow.getIncomeExpenseFlag().equals(0)) {
+ // 搴旀敹璐﹀崟
+ deleteReceivableSettlementDetail(claimDetailId);
+ } else {
+ // 搴斾粯璐﹀崟
+ deletePayableSettlementDetail(claimDetailId);
+ }
+
+ logger.info("鎴愬姛鍒犻櫎缁撶畻鏄庣粏锛岃棰嗘槑缁咺D锛歿}", claimDetailId);
+ } catch (Exception e) {
+ logger.error("鍒犻櫎缁撶畻鏄庣粏澶辫触锛岃棰嗘槑缁咺D锛歿}", claimDetailId, e);
+ // 杩欓噷鍙互閫夋嫨鎶涘嚭寮傚父鎴栬褰曟棩蹇楋紝浣嗕笉涓柇鏁翠釜鍒犻櫎娴佺▼
+ }
+ }
+
+ /**
+ * 鍒犻櫎搴旀敹璐﹀崟缁撶畻鏄庣粏
+ */
+ private void deleteReceivableSettlementDetail(Integer claimDetailId) {
+ try {
+ // 鏍规嵁璁ら鏄庣粏ID鏌ヨ搴旀敹璐﹀崟缁撶畻鏄庣粏
+ ReceivableBillSettlementDetail receivableQuery = new ReceivableBillSettlementDetail();
+ receivableQuery.setClaimDetailId(claimDetailId);
+ List<ReceivableBillSettlementDetail> receivableDetails = receivableBillSettlementDetailService.selectReceivableBillSettlementDetailList(receivableQuery);
+
+ if (!receivableDetails.isEmpty()) {
+ Integer[] receivableIds = receivableDetails.stream()
+ .map(ReceivableBillSettlementDetail::getId)
+ .toArray(Integer[]::new);
+ receivableBillSettlementDetailService.deleteReceivableBillSettlementDetailByIds(receivableIds);
+ logger.info("鎴愬姛鍒犻櫎搴旀敹璐﹀崟缁撶畻鏄庣粏锛岃棰嗘槑缁咺D锛歿}", claimDetailId);
+ }
+ } catch (Exception e) {
+ logger.error("鍒犻櫎搴旀敹璐﹀崟缁撶畻鏄庣粏澶辫触锛岃棰嗘槑缁咺D锛歿}", claimDetailId, e);
+ throw e;
+ }
+ }
+
+ /**
+ * 鍒犻櫎搴斾粯璐﹀崟缁撶畻鏄庣粏
+ */
+ private void deletePayableSettlementDetail(Integer claimDetailId) {
+ try {
+ // 鏍规嵁璁ら鏄庣粏ID鏌ヨ搴斾粯璐﹀崟缁撶畻鏄庣粏
+ PayableBillSettlementDetail payableQuery = new PayableBillSettlementDetail();
+ payableQuery.setClaimDetailId(claimDetailId);
+ List<PayableBillSettlementDetail> payableDetails = payableBillSettlementDetailService.selectPayableBillSettlementDetailList(payableQuery);
+
+ if (!payableDetails.isEmpty()) {
+ Integer[] payableIds = payableDetails.stream()
+ .map(PayableBillSettlementDetail::getId)
+ .toArray(Integer[]::new);
+ payableBillSettlementDetailService.deletePayableBillSettlementDetailByIds(payableIds);
+ logger.info("鎴愬姛鍒犻櫎搴斾粯璐﹀崟缁撶畻鏄庣粏锛岃棰嗘槑缁咺D锛歿}", claimDetailId);
+ }
+ } catch (Exception e) {
+ logger.error("鍒犻櫎搴斾粯璐﹀崟缁撶畻鏄庣粏澶辫触锛岃棰嗘槑缁咺D锛歿}", claimDetailId, e);
+ throw e;
+ }
+ }
}
--
Gitblit v1.8.0