From 44c22e1ef549a61a659f6f005766b9463c4e1c5e Mon Sep 17 00:00:00 2001 From: dhb52 Date: Sat, 6 Apr 2024 14:49:37 +0800 Subject: [PATCH] =?UTF-8?q?wip:=20=E5=A2=9E=E5=8A=A0=E5=85=AC=E6=B5=B7?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=86=E6=9E=90(mapper=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsCustomerController.http | 54 +++---- .../CrmStatisticsCustomerController.java | 16 +- .../CrmStatisticsPoolSummaryByDateRespVO.java | 19 +++ .../CrmStatisticsPoolSummaryByUserRespVO.java | 16 ++ .../CrmStatisticsCustomerMapper.java | 153 +++++++++++++++++- .../CrmStatisticsCustomerService.java | 18 ++- .../CrmStatisticsCustomerServiceImpl.java | 54 +++++++ 7 files changed, 294 insertions(+), 36 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http index b5d35f5c4..1882cae31 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http @@ -1,68 +1,58 @@ # == 1. 客户总量分析 == -### 1.1 客户总量分析(按日) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-date?deptId=100&interval=1×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 +### 1.1 客户总量分析(按日期) +GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -### 1.2 客户总量分析(按月) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-date?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 1.3 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-user?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +### 1.2 客户总量统计(按用户) +GET {{baseUrl}}/crm/statistics-customer/get-customer-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} # == 2. 客户跟进次数分析 == -### 2.1 客户跟进次数分析(按日) -GET {{baseUrl}}/crm/statistics-customer/get-followup-summary-by-date?deptId=100&intervalType=11×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 +### 2.1 客户跟进次数分析(按日期) +GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -### 2.2 客户跟进次数分析(按月) -GET {{baseUrl}}/crm/statistics-customer/get-followup-summary-by-date?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 -Authorization: Bearer {{token}} -tenant-id: {{adminTenentId}} - -### 2.3 客户总量统计(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-followup-summary-by-user?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +### 2.2 客户总量统计(按用户) +GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} # == 3. 客户跟进方式分析 == ### 3.1 客户跟进方式分析 -GET {{baseUrl}}/crm/statistics-customer/get-followup-summary-by-type?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +GET {{baseUrl}}/crm/statistics-customer/get-follow-up-summary-by-type?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -tenant-id: {{adminTenentId}} # == 4. 客户成交周期 == ### 4.1 合同摘要信息(客户转化率页面) -GET {{baseUrl}}/crm/statistics-customer/get-contract-summary?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +GET {{baseUrl}}/crm/statistics-customer/get-contract-summary?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -tenant-id: {{adminTenentId}} - # == 5. 客户成交周期 == -### 5.1 客户成交周期(按日) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-date?deptId=100&intervalType=11×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 +### 5.1 获取客户公海分析(按日期) +GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-date?deptId=100&interval=2×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -tenant-id: {{adminTenentId}} -### 5.2 客户成交周期(按月) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-date?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +### 5.2 获取客户公海分析(按用户) +GET {{baseUrl}}/crm/statistics-customer/get-pool-summary-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -tenant-id: {{adminTenentId}} -### 5.3 获取客户成交周期(按用户) -GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-user?deptId=100&intervalType=11×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 +# == 6. 客户成交周期 == +### 6.1 客户成交周期(按日期) +GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-date?deptId=100&interval=2×[0]=2024-01-01 00:00:00×[1]=2024-01-29 23:59:59 +Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} + +### 6.2 获取客户成交周期(按用户) +GET {{baseUrl}}/crm/statistics-customer/get-customer-deal-cycle-by-user?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 Authorization: Bearer {{token}} tenant-id: {{adminTenentId}} -tenant-id: {{adminTenentId}} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java index 450a9cd99..ad7857f9a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.java @@ -61,8 +61,6 @@ public class CrmStatisticsCustomerController { return success(customerService.getFollowUpSummaryByType(reqVO)); } - // TODO @dhb52:【客户转化率】里,应该少了一个接口,给上面图标的; - @GetMapping("/get-contract-summary") @Operation(summary = "获取客户的首次合同、回款信息列表", description = "用于【客户转化率】页面") @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") @@ -70,6 +68,20 @@ public class CrmStatisticsCustomerController { return success(customerService.getContractSummary(reqVO)); } + @GetMapping("/get-pool-summary-by-date") + @Operation(summary = "获取客户成交周期(按日期)") + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") + public CommonResult> getPoolSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { + return success(customerService.getPoolSummaryByDate(reqVO)); + } + + @GetMapping("/get-pool-summary-by-user") + @Operation(summary = "获取客户成交周期(按用户)") + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") + public CommonResult> getPoolSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { + return success(customerService.getPoolSummaryByUser(reqVO)); + } + @GetMapping("/get-customer-deal-cycle-by-date") @Operation(summary = "获取客户成交周期(按日期)") @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java new file mode 100644 index 000000000..ce09a9933 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - CRM 公海客户分析(按日期) VO") +@Data +public class CrmStatisticsPoolSummaryByDateRespVO { + + @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") + private String time; + + @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerPutCount; + + @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerTakeCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java new file mode 100644 index 000000000..fb59e8477 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - CRM 公海客户分析(按用户) VO") +@Data +public class CrmStatisticsPoolSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { + + @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerPutCount; + + @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer customerTakeCount; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java index b7f495b61..f520dddc4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java @@ -1,44 +1,195 @@ package cn.iocoder.yudao.module.crm.dal.mysql.statistics; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.RandomUtil; import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.List; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; + /** - * CRM 数据统计 Mapper + * CRM 客户分析 Mapper * * @author dhb52 */ @Mapper public interface CrmStatisticsCustomerMapper { + /** + * 新建客户数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerCreateCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); + /** + * 成交客户数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerDealCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); + /** + * 新建客户数(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerCreateCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 成交客户数(按用户) + * + * @param reqVO 请求参数@param reqVO 请求参数@param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerDealCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 合同总金额(按用户) + * @return 统计数据@return 统计数据@param reqVO 请求参数 + * @return 统计数据 + */ List selectContractPriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 合同回款金额(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectReceivablePriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 跟进次数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectFollowUpRecordCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); + /** + * 跟进客户数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectFollowUpCustomerCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); + /** + * 跟进次数(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectFollowUpRecordCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); + /** + * 跟进客户数(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectFollowUpCustomerCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); + + /** + * 首次合同、回款信息(用于【客户转化率】页面) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectContractSummary(CrmStatisticsCustomerReqVO reqVO); + /** + * 跟进次数(按类型) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectFollowUpRecordCountGroupByType(CrmStatisticsCustomerReqVO reqVO); + + /** + * 进入公海客户数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 + default List selectPoolCustomerPutCountByDate(CrmStatisticsCustomerReqVO reqVO) { + LocalDateTime currrentDate = LocalDateTimeUtil.beginOfDay(reqVO.getTimes()[0]); + LocalDateTime endDate = LocalDateTimeUtil.endOfDay(reqVO.getTimes()[1]); + List voList = new ArrayList<>(); + while (currrentDate.isBefore(endDate)) { + voList.add(new CrmStatisticsPoolSummaryByDateRespVO() + .setTime(LocalDateTimeUtil.format(currrentDate, "yyyy-MM-dd")) + .setCustomerPutCount(RandomUtil.randomInt(0, 10)) + .setCustomerTakeCount(RandomUtil.randomInt(0, 10))); + currrentDate = currrentDate.plusDays(1); + } + + return voList; + } + + + /** + * 公海领取客户数(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 + default List selectPoolCustomerTakeCountByDate(CrmStatisticsCustomerReqVO reqVO) { + return selectPoolCustomerPutCountByDate(reqVO); + } + + /** + * 进入公海客户数(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 + default List selectPoolCustomerPutCountByUser(CrmStatisticsCustomerReqVO reqVO) { + return convertList(reqVO.getUserIds(), userId -> + (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() + .setCustomerPutCount(RandomUtil.randomInt(0, 10)) + .setCustomerTakeCount(RandomUtil.randomInt(0, 10)) + .setOwnerUserId(userId)); + } + + /** + * 公海领取客户数(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 + default List selectPoolCustomerTakeCountByUser(CrmStatisticsCustomerReqVO reqVO) { + return selectPoolCustomerPutCountByUser(reqVO); + } + + /** + * 客户成交周期(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO); + /** + * 客户成交周期(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ List selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java index 8ef9d436b..0e00e9c22 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java @@ -55,10 +55,26 @@ public interface CrmStatisticsCustomerService { * 获取客户的首次合同、回款信息列表,用于【客户转化率】页面 * * @param reqVO 请求参数 - * @return 客户的首次合同、回款信息列表 + * @return 统计数据 */ List getContractSummary(CrmStatisticsCustomerReqVO reqVO); + /** + * 公海客户分析(按日期) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO); + + /** + * 公海客户分析(按用户) + * + * @param reqVO 请求参数 + * @return 统计数据 + */ + List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO); + /** * 客户成交周期(按日期) * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java index 250560ef2..f4787b20f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java @@ -187,6 +187,60 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe return summaryList; } + @Override + public List getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { + // 1. 获得用户编号数组 + reqVO.setUserIds(getUserIds(reqVO)); + if (CollUtil.isEmpty(reqVO.getUserIds())) { + return Collections.emptyList(); + } + + // 2. 按天统计,获取分项统计数据 + List customerPutCountList = customerMapper.selectPoolCustomerPutCountByDate(reqVO); + List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByDate(reqVO); + + // 3. 按照日期间隔,合并数据 + List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); + return convertList(timeRanges, times -> { + Integer customerPutCount = customerPutCountList.stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) + .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerPutCount).sum(); + Integer customerTakeCount = customerTakeCountList.stream() + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) + .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerTakeCount).sum(); + return new CrmStatisticsPoolSummaryByDateRespVO() + .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) + .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount); + }); + } + + @Override + public List getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { + // 1. 获得用户编号数组 + reqVO.setUserIds(getUserIds(reqVO)); + if (CollUtil.isEmpty(reqVO.getUserIds())) { + return Collections.emptyList(); + } + + // 2. 按用户统计,获取分项统计数据 + List customerPutCountList = customerMapper.selectPoolCustomerPutCountByUser(reqVO); + List customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByUser(reqVO); + + // 3.1 按照用户,合并统计数据 + List summaryList = convertList(reqVO.getUserIds(), userId -> { + Integer customerPutCount = customerPutCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) + .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerPutCount).sum(); + Integer customerTakeCount = customerTakeCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) + .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerTakeCount).sum(); + return (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() + .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount) + .setOwnerUserId(userId); + }); + // 3.2 拼接用户信息 + appendUserInfo(summaryList); + return summaryList; + } + @Override public List getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { // 1. 获得用户编号数组