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 | 73 +++++++++++++++++++++++++++++++-----
1 files changed, 62 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 b4188e5..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);
@@ -82,4 +127,10 @@
.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