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/pojo/AccountIncome.java                    |   25 +++++++++++-
 src/main/resources/mapper/account/AccountIncomeMapper.xml                  |   21 ++++++++++
 src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java |   37 ++++++++++++++++--
 3 files changed, 75 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/ruoyi/account/pojo/AccountIncome.java b/src/main/java/com/ruoyi/account/pojo/AccountIncome.java
index fee01ad..f074402 100644
--- a/src/main/java/com/ruoyi/account/pojo/AccountIncome.java
+++ b/src/main/java/com/ruoyi/account/pojo/AccountIncome.java
@@ -13,6 +13,7 @@
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 璐㈠姟绠$悊--鏀跺叆绠$悊
@@ -20,7 +21,7 @@
  */
 @TableName(value = "account_income")
 @Data
-public class AccountIncome extends DateQueryDto  implements Serializable {
+public class AccountIncome extends DateQueryDto implements Serializable {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -50,7 +51,7 @@
     /**
      * 鏀跺叆绫诲瀷(閿�鍞敹鍏ワ紝鏈嶅姟鏀跺叆锛屽叾浠栨敹鍏�)
      */
-    @Excel(name = "鏀跺叆绫诲瀷",readConverterExp = "0=閿�鍞敹鍏�,1=鏈嶅姟鏀跺叆,2=鍏朵粬鏀跺叆,3=鍥炴鏀跺叆")
+    @Excel(name = "鏀跺叆绫诲瀷", readConverterExp = "0=閿�鍞敹鍏�,1=鏈嶅姟鏀跺叆,2=鍏朵粬鏀跺叆,3=鍥炴鏀跺叆")
     @NotBlank(message = "鏀跺叆绫诲瀷涓嶈兘涓虹┖!!")
     private String incomeType;
 
@@ -75,10 +76,28 @@
     /**
      * 鏀舵鏂瑰紡(鐜伴噾锛屾敮绁紝閾惰杞处锛屽叾浠�)
      */
-    @Excel(name = "鏀舵鏂瑰紡",readConverterExp = "0=鐜伴噾,1=鏀エ,2=閾惰杞处,3=鍏朵粬")
+    @Excel(name = "鏀舵鏂瑰紡", readConverterExp = "0=鐜伴噾,1=鏀エ,2=閾惰杞处,3=鍏朵粬")
     private String incomeMethod;
 
     /**
+     * 鏀舵鏂瑰紡鏍囩
+     */
+    @TableField(exist = false)
+    private String incomeMethodLabel;
+
+    /**
+     * payment_methods 瀛楀吀缂栫爜闆嗗悎锛坆usiness_type 涓虹┖鏃讹級
+     */
+    @TableField(exist = false)
+    private List<String> paymentMethodList;
+
+    /**
+     * receipt_payment_type 瀛楀吀缂栫爜闆嗗悎锛坆usiness_type=1鏃讹級
+     */
+    @TableField(exist = false)
+    private List<String> receiptPaymentMethodList;
+
+    /**
      * 鍙戠エ鍙风爜
      */
     @Excel(name = "鍙戠エ鍙风爜")
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 4a83ecb..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,13 +5,11 @@
 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;
-import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.dto.DateQueryDto;
 import com.ruoyi.project.system.domain.SysDictData;
@@ -24,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
@@ -40,9 +38,40 @@
     //鍒嗛〉鏌ヨ
     @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());
+    }
+
     //瀵煎嚭
     @Override
     public void accountIncomeExport(HttpServletResponse response, AccountIncome accountIncome) {
diff --git a/src/main/resources/mapper/account/AccountIncomeMapper.xml b/src/main/resources/mapper/account/AccountIncomeMapper.xml
index e4f3361..f2cfbe2 100644
--- a/src/main/resources/mapper/account/AccountIncomeMapper.xml
+++ b/src/main/resources/mapper/account/AccountIncomeMapper.xml
@@ -17,7 +17,26 @@
         <if test="accountIncome.incomeType != null and accountIncome.incomeType != '' ">
             AND income_type = #{accountIncome.incomeType}
         </if>
-        <if test="accountIncome.incomeMethod != null and accountIncome.incomeMethod != '' ">
+        <if test="accountIncome.incomeMethodLabel != null and accountIncome.incomeMethodLabel != ''">
+            AND (
+            (
+            business_type = 1
+            AND income_method in
+            <foreach collection="accountIncome.receiptPaymentMethodList" item="method" open="(" separator="," close=")">
+                #{method}
+            </foreach>
+            )
+            OR
+            (
+            business_type is null
+            AND income_method in
+            <foreach collection="accountIncome.paymentMethodList" item="method" open="(" separator="," close=")">
+                #{method}
+            </foreach>
+            )
+            )
+        </if>
+        <if test="(accountIncome.incomeMethodLabel == null or accountIncome.incomeMethodLabel == '') and accountIncome.incomeMethod != null and accountIncome.incomeMethod != '' ">
             AND income_method = #{accountIncome.incomeMethod}
         </if>
     </select>

--
Gitblit v1.9.3