From f65f8494fd2e292e5c15c02112fa9217ce655361 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 29 四月 2026 10:22:03 +0800
Subject: [PATCH] fix: 收入管理根据收款方式查询错误

---
 src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java |  103 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 99 insertions(+), 4 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 b43888c..1d197f1 100644
--- a/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
@@ -1,22 +1,30 @@
 package com.ruoyi.account.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.mapper.AccountFileMapper;
+import com.ruoyi.account.dto.AccountDto3;
+import com.ruoyi.account.dto.ReportDateDto;
 import com.ruoyi.account.mapper.AccountIncomeMapper;
-import com.ruoyi.account.pojo.AccountFile;
 import com.ruoyi.account.pojo.AccountIncome;
-import com.ruoyi.account.service.AccountFileService;
 import com.ruoyi.account.service.AccountIncomeService;
 import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.dto.DateQueryDto;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.mapper.SysDictDataMapper;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @AllArgsConstructor
 @Service
@@ -24,11 +32,44 @@
 
     private AccountIncomeMapper accountIncomeMapper;
 
+    private SysDictDataMapper sysDictDataMapper;
+
 
     //鍒嗛〉鏌ヨ
     @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());
     }
 
     //瀵煎嚭
@@ -38,4 +79,58 @@
         ExcelUtil<AccountIncome> util = new ExcelUtil<AccountIncome>(AccountIncome.class);
         util.exportExcel(response, accountIncomes, "鏀跺叆绠$悊瀵煎嚭");
     }
+
+    //璐㈠姟鎶ヨ〃骞存煡璇�
+    @Override
+    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锛�
+        for (SysDictData incomeType : incomeTypes) {
+            AccountDto3 accountDto3 = new AccountDto3();
+            accountDto3.setTypeName(incomeType.getDictLabel());//绫诲瀷
+            List<BigDecimal> account=new ArrayList<>();
+            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));
+
+                // 褰撴湀鏈�鍚庝竴澶�
+                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);
+        }
+        return accountDto3s;
+    }
+
+    @Override
+    public AccountIncome getByInvoiceNumber(String purchaseContractNumber) {
+        AccountIncome accountIncome = accountIncomeMapper.selectOne(new LambdaQueryWrapper<AccountIncome>()
+                .eq(AccountIncome::getInvoiceNumber, purchaseContractNumber));
+        return accountIncome;
+    }
+
+    @Override
+    public List<AccountIncome> getByInvoiceNumberList(String purchaseContractNumber) {
+        return accountIncomeMapper.selectList(new LambdaQueryWrapper<AccountIncome>()
+                .eq(AccountIncome::getInvoiceNumber, purchaseContractNumber));
+    }
 }

--
Gitblit v1.9.3