src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -1,6 +1,8 @@
package com.ruoyi.basic.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -33,10 +35,9 @@
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -133,12 +134,12 @@
        // 2. 构建查询条件(增强空值安全)
        LambdaQueryWrapper<Customer> queryWrapper = new LambdaQueryWrapper<>();
        String customerName = customer.getCustomerName();
        String customerType = customer.getCustomerType();
        Integer customerType = customer.getCustomerType();
        if (StringUtils.isNotBlank(customerName)) {
            queryWrapper.like(Customer::getCustomerName, customerName);
        }
        if (StringUtils.isNotBlank(customerType)) {
            queryWrapper.like(Customer::getCustomerType, customerType);
        if (customerType != null) {
            queryWrapper.eq(Customer::getCustomerType, customerType);
        }
        // 3. 执行分页查询(保留分页元数据)
@@ -149,10 +150,17 @@
                .filter(Objects::nonNull) // 过滤空对象(避免后续操作NPE)
                .peek(c -> {
                    // 安全获取字段,避免null值拼接
                    String address = StringUtils.defaultString(c.getCompanyAddress(), "");
                    String phone = StringUtils.defaultString(c.getCompanyPhone(), "");
                    c.setAddressPhone(address + "(" + phone + ")");
                    String address = StringUtils.defaultString(c.getCompanyAddress(), "").trim();
                    String phone = StringUtils.defaultString(c.getCompanyPhone(), "").trim();
                    if (StringUtils.isNotEmpty(address) && StringUtils.isNotEmpty(phone)) {
                        c.setAddressPhone(address + "(" + phone + ")");
                    } else if (StringUtils.isNotEmpty(address)) {
                        c.setAddressPhone(address);
                    } else if (StringUtils.isNotEmpty(phone)) {
                        c.setAddressPhone(phone);
                    } else {
                        c.setAddressPhone("");
                    }
                    // 查询最新的跟进记录
                    CustomerFollowUp followUp = customerFollowUpService.getOne(
                            new LambdaQueryWrapper<CustomerFollowUp>()
@@ -163,7 +171,11 @@
                    if (followUp != null) {
                        c.setFollowUpLevel(followUp.getFollowUpLevel());
                        c.setFollowUpTime(followUp.getFollowUpTime());
                        c.setFollowUpTime(
                                Date.from(
                                        followUp.getFollowUpTime().atZone(ZoneId.systemDefault()).toInstant()
                                )
                        );
                    }
                })
                .collect(Collectors.toList());
@@ -258,7 +270,7 @@
    @Override
    public List<Map<String, Object>> customerList(Customer customer) {
        LambdaQueryWrapper<Customer> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber);
        queryWrapper.select(Customer::getId, Customer::getCustomerName, Customer::getTaxpayerIdentificationNumber, Customer::getCustomerType);
        // 获取原始查询结果
        List<Map<String, Object>> result = customerMapper.selectMaps(queryWrapper);