From c34f874753481fc5105c86f9bcf1eb21efcab92d Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 29 四月 2026 13:04:56 +0800
Subject: [PATCH] fix: 合并回款与收付款方式相关修复

---
 src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java |   67 ++++++++++++++++++++++++++++-----
 1 files changed, 56 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
index 199e399..1d197f1 100644
--- a/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
@@ -5,8 +5,8 @@
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.account.dto.AccountDto2;
 import com.ruoyi.account.dto.AccountDto3;
+import com.ruoyi.account.dto.ReportDateDto;
 import com.ruoyi.account.mapper.AccountIncomeMapper;
 import com.ruoyi.account.pojo.AccountIncome;
 import com.ruoyi.account.service.AccountIncomeService;
@@ -22,9 +22,9 @@
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collections;
 import java.util.List;
-import java.util.Map;
+import java.util.stream.Collectors;
 
 @AllArgsConstructor
 @Service
@@ -38,7 +38,38 @@
     //鍒嗛〉鏌ヨ
     @Override
     public IPage<AccountIncome> accountIncomeListPage(Page page, AccountIncome accountIncome) {
+        resolveIncomeMethodLabelFilter(accountIncome);
         return accountIncomeMapper.accountIncomeListPage(page,accountIncome);
+    }
+
+    private void resolveIncomeMethodLabelFilter(AccountIncome accountIncome) {
+        if (accountIncome == null) {
+            return;
+        }
+        if (accountIncome.getIncomeMethodLabel() == null || accountIncome.getIncomeMethodLabel().trim().isEmpty()) {
+            return;
+        }
+        String targetLabel = accountIncome.getIncomeMethodLabel().trim();
+        List<String> paymentMethodList = selectDictValuesByLabel("payment_methods", targetLabel);
+        List<String> receiptPaymentMethodList = selectDictValuesByLabel("receipt_payment_type", targetLabel);
+        if (paymentMethodList.isEmpty()) {
+            paymentMethodList = Collections.singletonList("__NO_MATCH__");
+        }
+        if (receiptPaymentMethodList.isEmpty()) {
+            receiptPaymentMethodList = Collections.singletonList("__NO_MATCH__");
+        }
+        accountIncome.setPaymentMethodList(paymentMethodList);
+        accountIncome.setReceiptPaymentMethodList(receiptPaymentMethodList);
+        accountIncome.setIncomeMethod(null);
+    }
+
+    private List<String> selectDictValuesByLabel(String dictType, String label) {
+        return sysDictDataMapper.selectDictDataByType(dictType).stream()
+                .filter(item -> label.equals(item.getDictLabel()))
+                .map(SysDictData::getDictValue)
+                .filter(v -> v != null && !v.trim().isEmpty())
+                .distinct()
+                .collect(Collectors.toList());
     }
 
     //瀵煎嚭
@@ -51,24 +82,38 @@
 
     //璐㈠姟鎶ヨ〃骞存煡璇�
     @Override
-    public List<AccountDto3> reportIncome() {
+    public List<AccountDto3> reportIncome(ReportDateDto reportDateDto) {
         List<AccountDto3> accountDto3s = new ArrayList<>();
         //鍏堟煡璇㈡敹鍏ョ被鍨嬫湁鍝簺
         List<SysDictData> incomeTypes = sysDictDataMapper.selectDictDataByType("income_types");
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        int currentYear = LocalDate.now().getYear(); // 鑾峰彇褰撳墠骞翠唤锛堝2025锛�
+//        int currentYear = LocalDate.now().getYear(); // 鑾峰彇褰撳墠骞翠唤锛堝2025锛�
         for (SysDictData incomeType : incomeTypes) {
             AccountDto3 accountDto3 = new AccountDto3();
             accountDto3.setTypeName(incomeType.getDictLabel());//绫诲瀷
             List<BigDecimal> account=new ArrayList<>();
-            for (int i = 1; i <= 12; i++) {
-                // 褰撴湀绗竴澶╋細骞翠唤涓哄綋鍓嶅勾锛屾湀浠戒负i锛屾棩鏈熶负1
-                LocalDate firstDay = LocalDate.of(currentYear, i, 1);
+            LocalDate startDate = reportDateDto.getEntryDateStart();
+            LocalDate endDate = reportDateDto.getEntryDateEnd();
+
+            // 鍒濆鍖栧惊鐜彉閲忎负璧峰鏃ユ湡
+            LocalDate currentDate = startDate;
+
+            // 寰幆锛氬綋鍓嶆棩鏈熶笉瓒呰繃缁撴潫鏃ユ湡鏃剁户缁�
+            while (!currentDate.isAfter(endDate)) {
+                // 褰撴湀绗竴澶�
+                LocalDate firstDay = currentDate.withDayOfMonth(1);
                 DateQueryDto dateQueryDto = new DateQueryDto();
                 dateQueryDto.setEntryDateStart(firstDay.format(formatter));
-                // 褰撴湀鏈�鍚庝竴澶╋細绗竴澶╃殑鏈堜唤鐨勬渶鍚庝竴澶�
-                dateQueryDto.setEntryDateEnd(firstDay.plusMonths(1).minusDays(1).format(formatter));
-                account.add(accountIncomeMapper.report1(dateQueryDto,incomeType.getDictValue()));
+
+                // 褰撴湀鏈�鍚庝竴澶�
+                LocalDate lastDay = firstDay.plusMonths(1).minusDays(1);
+                dateQueryDto.setEntryDateEnd(lastDay.format(formatter));
+
+                // 绱姞鏁版嵁
+                account.add(accountIncomeMapper.report1(dateQueryDto, incomeType.getDictValue()));
+
+                // 鏈堜唤鍔犱竴锛堣嚜鍔ㄥ鐞嗚法骞达紝姣斿12鏈堝姞1涓湀浼氬彉鎴愪笅涓�骞�1鏈堬級
+                currentDate = currentDate.plusMonths(1);
             }
             accountDto3.setAccount(account);//绫诲瀷
             accountDto3s.add(accountDto3);

--
Gitblit v1.9.3