liding
9 小时以前 84344f16a7f783cd32731764010a75a0af268384
src/main/java/com/ruoyi/basic/service/impl/CustomerServiceImpl.java
@@ -22,7 +22,6 @@
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysUser;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.pojo.SalesLedger;
import lombok.AllArgsConstructor;
@@ -33,10 +32,8 @@
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.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -133,12 +130,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 +146,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 +167,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 +266,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);