| | |
| | | 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; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得客户") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<CrmCustomerRespVO> getCustomer(@RequestParam("id") Long id) { |
| | | // 1. 获取客户 |
| | | CrmCustomerDO customer = customerService.getCustomer(id); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得客户分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<PageResult<CrmCustomerRespVO>> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| | | // 1. 查询客户分页 |
| | | PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(pageVO, getLoginUserId()); |
| | |
| | | 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())); |
| | | }); |
| | | } |
| | | |
| | | @GetMapping("/put-pool-remind-page") |
| | | @Operation(summary = "获得待进入公海客户分页") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<PageResult<CrmCustomerRespVO>> getPutPoolRemindCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { |
| | | // 1. 查询客户分页 |
| | | PageResult<CrmCustomerDO> pageResult = customerService.getPutPoolRemindCustomerPage(pageVO, getLoginUserId()); |
| | |
| | | |
| | | @GetMapping("/put-pool-remind-count") |
| | | @Operation(summary = "获得待进入公海客户数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<Long> getPutPoolRemindCustomerCount() { |
| | | return success(customerService.getPutPoolRemindCustomerCount(getLoginUserId())); |
| | | } |
| | | |
| | | @GetMapping("/today-contact-count") |
| | | @Operation(summary = "获得今日需联系客户数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<Long> getTodayContactCustomerCount() { |
| | | return success(customerService.getTodayContactCustomerCount(getLoginUserId())); |
| | | } |
| | | |
| | | @GetMapping("/follow-count") |
| | | @Operation(summary = "获得分配给我、待跟进的线索数量的客户数量") |
| | | @PreAuthorize("@ss.hasPermission('crm:customer:query')") |
| | | public CommonResult<Long> getFollowCustomerCount() { |
| | | return success(customerService.getFollowCustomerCount(getLoginUserId())); |
| | | } |