gaoluyang
5 天以前 f412b5b671a91d7e01dac12507cad9df3648c524
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
@@ -15,8 +15,10 @@
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.customer.*;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerProgressDO;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerProgressService;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@@ -61,6 +63,8 @@
    private CrmCustomerPoolConfigService customerPoolConfigService;
    @Resource
    private CrmContractService contractService;
    @Resource
    private CrmCustomerProgressService customerProgressService;
    @Resource
    private DeptApi deptApi;
@@ -167,6 +171,8 @@
        Set<Long> customerIds = convertSet(list, CrmCustomerDO::getId);
        Map<Long, Long> contractCountMap = contractService.getContractCountMapByCustomerIds(customerIds);
        Map<Long, BigDecimal> contractPriceMap = contractService.getContractPriceMapByCustomerIds(customerIds);
        // 1.4 获取每个客户最新的一条洽谈进度(客户导出时带出)
        Map<Long, CrmCustomerProgressDO> latestProgressMap = customerProgressService.getLatestProgressMap(customerIds);
        // 2. 转换成 VO
        return BeanUtils.toBean(list, CrmCustomerRespVO.class, customerVO -> {
            customerVO.setAreaName(AreaUtils.format(customerVO.getAreaId()));
@@ -185,6 +191,9 @@
            customerVO.setContractCount(
                    contractCountMap.getOrDefault(customerVO.getId(), 0L).intValue());
            customerVO.setContractTotalPrice(contractPriceMap.get(customerVO.getId()));
            // 2.4 设置最新洽谈进度
            MapUtils.findAndThen(latestProgressMap, customerVO.getId(),
                    progress -> customerVO.setNegotiationProgress(progress.getContent()));
        });
    }