| | |
| | | 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; |
| | |
| | | private CrmCustomerPoolConfigService customerPoolConfigService; |
| | | @Resource |
| | | private CrmContractService contractService; |
| | | @Resource |
| | | private CrmCustomerProgressService customerProgressService; |
| | | |
| | | @Resource |
| | | private DeptApi deptApi; |
| | |
| | | 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())); |
| | |
| | | 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())); |
| | | }); |
| | | } |
| | | |