gongchunyi
4 小时以前 f65f8494fd2e292e5c15c02112fa9217ce655361
fix: 收入管理根据收款方式查询错误
已修改3个文件
83 ■■■■■ 文件已修改
src/main/java/com/ruoyi/account/pojo/AccountIncome.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/AccountIncomeMapper.xml 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 字典编码集合(business_type 为空时)
     */
    @TableField(exist = false)
    private List<String> paymentMethodList;
    /**
     * receipt_payment_type 字典编码集合(business_type=1时)
     */
    @TableField(exist = false)
    private List<String> receiptPaymentMethodList;
    /**
     * 发票号码
     */
    @Excel(name = "发票号码")
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) {
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>