Commit 44c22e1ef549a61a659f6f005766b9463c4e1c5e
1 parent
d2f48eb2
wip: 增加公海客户分析(mapper模拟数据)
Showing
7 changed files
with
293 additions
and
35 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http
| 1 | 1 | # == 1. 客户总量分析 == |
| 2 | -### 1.1 客户总量分析(按日) | |
| 3 | -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 | |
| 2 | +### 1.1 客户总量分析(按日期) | |
| 3 | +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 | |
| 4 | 4 | Authorization: Bearer {{token}} |
| 5 | 5 | tenant-id: {{adminTenentId}} |
| 6 | 6 | |
| 7 | -### 1.2 客户总量分析(按月) | |
| 8 | -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 | |
| 9 | -Authorization: Bearer {{token}} | |
| 10 | -tenant-id: {{adminTenentId}} | |
| 11 | - | |
| 12 | -### 1.3 客户总量统计(按用户) | |
| 13 | -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 | |
| 7 | +### 1.2 客户总量统计(按用户) | |
| 8 | +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 | |
| 14 | 9 | Authorization: Bearer {{token}} |
| 15 | 10 | tenant-id: {{adminTenentId}} |
| 16 | 11 | |
| 17 | 12 | |
| 18 | 13 | # == 2. 客户跟进次数分析 == |
| 19 | -### 2.1 客户跟进次数分析(按日) | |
| 20 | -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 | |
| 21 | -Authorization: Bearer {{token}} | |
| 22 | -tenant-id: {{adminTenentId}} | |
| 23 | - | |
| 24 | -### 2.2 客户跟进次数分析(按月) | |
| 25 | -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 | |
| 14 | +### 2.1 客户跟进次数分析(按日期) | |
| 15 | +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 | |
| 26 | 16 | Authorization: Bearer {{token}} |
| 27 | 17 | tenant-id: {{adminTenentId}} |
| 28 | 18 | |
| 29 | -### 2.3 客户总量统计(按用户) | |
| 30 | -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 | |
| 19 | +### 2.2 客户总量统计(按用户) | |
| 20 | +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 | |
| 31 | 21 | Authorization: Bearer {{token}} |
| 32 | 22 | tenant-id: {{adminTenentId}} |
| 33 | 23 | |
| 34 | 24 | |
| 35 | 25 | # == 3. 客户跟进方式分析 == |
| 36 | 26 | ### 3.1 客户跟进方式分析 |
| 37 | -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 | |
| 27 | +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 | |
| 38 | 28 | Authorization: Bearer {{token}} |
| 39 | 29 | tenant-id: {{adminTenentId}} |
| 40 | -tenant-id: {{adminTenentId}} | |
| 41 | 30 | |
| 42 | 31 | |
| 43 | 32 | # == 4. 客户成交周期 == |
| 44 | 33 | ### 4.1 合同摘要信息(客户转化率页面) |
| 45 | -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 | |
| 34 | +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 | |
| 46 | 35 | Authorization: Bearer {{token}} |
| 47 | 36 | tenant-id: {{adminTenentId}} |
| 48 | -tenant-id: {{adminTenentId}} | |
| 49 | - | |
| 50 | 37 | |
| 51 | 38 | # == 5. 客户成交周期 == |
| 52 | -### 5.1 客户成交周期(按日) | |
| 53 | -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 | |
| 39 | +### 5.1 获取客户公海分析(按日期) | |
| 40 | +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 | |
| 54 | 41 | Authorization: Bearer {{token}} |
| 55 | 42 | tenant-id: {{adminTenentId}} |
| 56 | -tenant-id: {{adminTenentId}} | |
| 57 | 43 | |
| 58 | -### 5.2 客户成交周期(按月) | |
| 59 | -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 | |
| 44 | +### 5.2 获取客户公海分析(按用户) | |
| 45 | +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 | |
| 60 | 46 | Authorization: Bearer {{token}} |
| 61 | 47 | tenant-id: {{adminTenentId}} |
| 48 | + | |
| 49 | +# == 6. 客户成交周期 == | |
| 50 | +### 6.1 客户成交周期(按日期) | |
| 51 | +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 | |
| 52 | +Authorization: Bearer {{token}} | |
| 62 | 53 | tenant-id: {{adminTenentId}} |
| 63 | 54 | |
| 64 | -### 5.3 获取客户成交周期(按用户) | |
| 65 | -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 | |
| 55 | +### 6.2 获取客户成交周期(按用户) | |
| 56 | +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 | |
| 66 | 57 | Authorization: Bearer {{token}} |
| 67 | 58 | tenant-id: {{adminTenentId}} |
| 68 | -tenant-id: {{adminTenentId}} | |
| 69 | 59 | \ No newline at end of file | ... | ... |
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 { |
| 61 | 61 | return success(customerService.getFollowUpSummaryByType(reqVO)); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - // TODO @dhb52:【客户转化率】里,应该少了一个接口,给上面图标的; | |
| 65 | - | |
| 66 | 64 | @GetMapping("/get-contract-summary") |
| 67 | 65 | @Operation(summary = "获取客户的首次合同、回款信息列表", description = "用于【客户转化率】页面") |
| 68 | 66 | @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") |
| ... | ... | @@ -70,6 +68,20 @@ public class CrmStatisticsCustomerController { |
| 70 | 68 | return success(customerService.getContractSummary(reqVO)); |
| 71 | 69 | } |
| 72 | 70 | |
| 71 | + @GetMapping("/get-pool-summary-by-date") | |
| 72 | + @Operation(summary = "获取客户成交周期(按日期)") | |
| 73 | + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | |
| 74 | + public CommonResult<List<CrmStatisticsPoolSummaryByDateRespVO>> getPoolSummaryByDate(@Valid CrmStatisticsCustomerReqVO reqVO) { | |
| 75 | + return success(customerService.getPoolSummaryByDate(reqVO)); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @GetMapping("/get-pool-summary-by-user") | |
| 79 | + @Operation(summary = "获取客户成交周期(按用户)") | |
| 80 | + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | |
| 81 | + public CommonResult<List<CrmStatisticsPoolSummaryByUserRespVO>> getPoolSummaryByUser(@Valid CrmStatisticsCustomerReqVO reqVO) { | |
| 82 | + return success(customerService.getPoolSummaryByUser(reqVO)); | |
| 83 | + } | |
| 84 | + | |
| 73 | 85 | @GetMapping("/get-customer-deal-cycle-by-date") |
| 74 | 86 | @Operation(summary = "获取客户成交周期(按日期)") |
| 75 | 87 | @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByDateRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - CRM 公海客户分析(按日期) VO") | |
| 7 | +@Data | |
| 8 | +public class CrmStatisticsPoolSummaryByDateRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") | |
| 11 | + private String time; | |
| 12 | + | |
| 13 | + @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 14 | + private Integer customerPutCount; | |
| 15 | + | |
| 16 | + @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 17 | + private Integer customerTakeCount; | |
| 18 | + | |
| 19 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsPoolSummaryByUserRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "管理后台 - CRM 公海客户分析(按用户) VO") | |
| 7 | +@Data | |
| 8 | +public class CrmStatisticsPoolSummaryByUserRespVO extends CrmStatisticsCustomerByUserBaseRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "进入公海客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | + private Integer customerPutCount; | |
| 12 | + | |
| 13 | + @Schema(description = "公海领取客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 14 | + private Integer customerTakeCount; | |
| 15 | + | |
| 16 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.mysql.statistics; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | +import cn.hutool.core.util.RandomUtil; | |
| 3 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.*; |
| 4 | 6 | import org.apache.ibatis.annotations.Mapper; |
| 5 | 7 | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | +import java.util.ArrayList; | |
| 6 | 10 | import java.util.List; |
| 7 | 11 | |
| 12 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 13 | + | |
| 8 | 14 | /** |
| 9 | - * CRM 数据统计 Mapper | |
| 15 | + * CRM 客户分析 Mapper | |
| 10 | 16 | * |
| 11 | 17 | * @author dhb52 |
| 12 | 18 | */ |
| 13 | 19 | @Mapper |
| 14 | 20 | public interface CrmStatisticsCustomerMapper { |
| 15 | 21 | |
| 22 | + /** | |
| 23 | + * 新建客户数(按日期) | |
| 24 | + * | |
| 25 | + * @param reqVO 请求参数 | |
| 26 | + * @return 统计数据 | |
| 27 | + */ | |
| 16 | 28 | List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerCreateCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 17 | 29 | |
| 30 | + /** | |
| 31 | + * 成交客户数(按日期) | |
| 32 | + * | |
| 33 | + * @param reqVO 请求参数 | |
| 34 | + * @return 统计数据 | |
| 35 | + */ | |
| 18 | 36 | List<CrmStatisticsCustomerSummaryByDateRespVO> selectCustomerDealCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 19 | 37 | |
| 38 | + /** | |
| 39 | + * 新建客户数(按用户) | |
| 40 | + * | |
| 41 | + * @param reqVO 请求参数 | |
| 42 | + * @return 统计数据 | |
| 43 | + */ | |
| 20 | 44 | List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerCreateCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 21 | 45 | |
| 46 | + /** | |
| 47 | + * 成交客户数(按用户) | |
| 48 | + * | |
| 49 | + * @param reqVO 请求参数@param reqVO 请求参数@param reqVO 请求参数 | |
| 50 | + * @return 统计数据 | |
| 51 | + */ | |
| 22 | 52 | List<CrmStatisticsCustomerSummaryByUserRespVO> selectCustomerDealCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 23 | 53 | |
| 54 | + /** | |
| 55 | + * 合同总金额(按用户) | |
| 56 | + * @return 统计数据@return 统计数据@param reqVO 请求参数 | |
| 57 | + * @return 统计数据 | |
| 58 | + */ | |
| 24 | 59 | List<CrmStatisticsCustomerSummaryByUserRespVO> selectContractPriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 25 | 60 | |
| 61 | + /** | |
| 62 | + * 合同回款金额(按用户) | |
| 63 | + * | |
| 64 | + * @param reqVO 请求参数 | |
| 65 | + * @return 统计数据 | |
| 66 | + */ | |
| 26 | 67 | List<CrmStatisticsCustomerSummaryByUserRespVO> selectReceivablePriceGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 27 | 68 | |
| 69 | + /** | |
| 70 | + * 跟进次数(按日期) | |
| 71 | + * | |
| 72 | + * @param reqVO 请求参数 | |
| 73 | + * @return 统计数据 | |
| 74 | + */ | |
| 28 | 75 | List<CrmStatisticsFollowUpSummaryByDateRespVO> selectFollowUpRecordCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 29 | 76 | |
| 77 | + /** | |
| 78 | + * 跟进客户数(按日期) | |
| 79 | + * | |
| 80 | + * @param reqVO 请求参数 | |
| 81 | + * @return 统计数据 | |
| 82 | + */ | |
| 30 | 83 | List<CrmStatisticsFollowUpSummaryByDateRespVO> selectFollowUpCustomerCountGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 31 | 84 | |
| 85 | + /** | |
| 86 | + * 跟进次数(按用户) | |
| 87 | + * | |
| 88 | + * @param reqVO 请求参数 | |
| 89 | + * @return 统计数据 | |
| 90 | + */ | |
| 32 | 91 | List<CrmStatisticsFollowUpSummaryByUserRespVO> selectFollowUpRecordCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 33 | 92 | |
| 93 | + /** | |
| 94 | + * 跟进客户数(按用户) | |
| 95 | + * | |
| 96 | + * @param reqVO 请求参数 | |
| 97 | + * @return 统计数据 | |
| 98 | + */ | |
| 34 | 99 | List<CrmStatisticsFollowUpSummaryByUserRespVO> selectFollowUpCustomerCountGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 35 | 100 | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 首次合同、回款信息(用于【客户转化率】页面) | |
| 104 | + * | |
| 105 | + * @param reqVO 请求参数 | |
| 106 | + * @return 统计数据 | |
| 107 | + */ | |
| 36 | 108 | List<CrmStatisticsCustomerContractSummaryRespVO> selectContractSummary(CrmStatisticsCustomerReqVO reqVO); |
| 37 | 109 | |
| 110 | + /** | |
| 111 | + * 跟进次数(按类型) | |
| 112 | + * | |
| 113 | + * @param reqVO 请求参数 | |
| 114 | + * @return 统计数据 | |
| 115 | + */ | |
| 38 | 116 | List<CrmStatisticsFollowUpSummaryByTypeRespVO> selectFollowUpRecordCountGroupByType(CrmStatisticsCustomerReqVO reqVO); |
| 39 | 117 | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * 进入公海客户数(按日期) | |
| 121 | + * | |
| 122 | + * @param reqVO 请求参数 | |
| 123 | + * @return 统计数据 | |
| 124 | + */ | |
| 125 | + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 | |
| 126 | + default List<CrmStatisticsPoolSummaryByDateRespVO> selectPoolCustomerPutCountByDate(CrmStatisticsCustomerReqVO reqVO) { | |
| 127 | + LocalDateTime currrentDate = LocalDateTimeUtil.beginOfDay(reqVO.getTimes()[0]); | |
| 128 | + LocalDateTime endDate = LocalDateTimeUtil.endOfDay(reqVO.getTimes()[1]); | |
| 129 | + List<CrmStatisticsPoolSummaryByDateRespVO> voList = new ArrayList<>(); | |
| 130 | + while (currrentDate.isBefore(endDate)) { | |
| 131 | + voList.add(new CrmStatisticsPoolSummaryByDateRespVO() | |
| 132 | + .setTime(LocalDateTimeUtil.format(currrentDate, "yyyy-MM-dd")) | |
| 133 | + .setCustomerPutCount(RandomUtil.randomInt(0, 10)) | |
| 134 | + .setCustomerTakeCount(RandomUtil.randomInt(0, 10))); | |
| 135 | + currrentDate = currrentDate.plusDays(1); | |
| 136 | + } | |
| 137 | + | |
| 138 | + return voList; | |
| 139 | + } | |
| 140 | + | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * 公海领取客户数(按日期) | |
| 144 | + * | |
| 145 | + * @param reqVO 请求参数 | |
| 146 | + * @return 统计数据 | |
| 147 | + */ | |
| 148 | + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 | |
| 149 | + default List<CrmStatisticsPoolSummaryByDateRespVO> selectPoolCustomerTakeCountByDate(CrmStatisticsCustomerReqVO reqVO) { | |
| 150 | + return selectPoolCustomerPutCountByDate(reqVO); | |
| 151 | + } | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * 进入公海客户数(按用户) | |
| 155 | + * | |
| 156 | + * @param reqVO 请求参数 | |
| 157 | + * @return 统计数据 | |
| 158 | + */ | |
| 159 | + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 | |
| 160 | + default List<CrmStatisticsPoolSummaryByUserRespVO> selectPoolCustomerPutCountByUser(CrmStatisticsCustomerReqVO reqVO) { | |
| 161 | + return convertList(reqVO.getUserIds(), userId -> | |
| 162 | + (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() | |
| 163 | + .setCustomerPutCount(RandomUtil.randomInt(0, 10)) | |
| 164 | + .setCustomerTakeCount(RandomUtil.randomInt(0, 10)) | |
| 165 | + .setOwnerUserId(userId)); | |
| 166 | + } | |
| 167 | + | |
| 168 | + /** | |
| 169 | + * 公海领取客户数(按用户) | |
| 170 | + * | |
| 171 | + * @param reqVO 请求参数 | |
| 172 | + * @return 统计数据 | |
| 173 | + */ | |
| 174 | + // TODO: @芋艿 模拟数据, 需要增加 crm_owner_record 表 | |
| 175 | + default List<CrmStatisticsPoolSummaryByUserRespVO> selectPoolCustomerTakeCountByUser(CrmStatisticsCustomerReqVO reqVO) { | |
| 176 | + return selectPoolCustomerPutCountByUser(reqVO); | |
| 177 | + } | |
| 178 | + | |
| 179 | + /** | |
| 180 | + * 客户成交周期(按日期) | |
| 181 | + * | |
| 182 | + * @param reqVO 请求参数 | |
| 183 | + * @return 统计数据 | |
| 184 | + */ | |
| 40 | 185 | List<CrmStatisticsCustomerDealCycleByDateRespVO> selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO); |
| 41 | 186 | |
| 187 | + /** | |
| 188 | + * 客户成交周期(按用户) | |
| 189 | + * | |
| 190 | + * @param reqVO 请求参数 | |
| 191 | + * @return 统计数据 | |
| 192 | + */ | |
| 42 | 193 | List<CrmStatisticsCustomerDealCycleByUserRespVO> selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); |
| 43 | 194 | |
| 44 | 195 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java
| ... | ... | @@ -55,11 +55,27 @@ public interface CrmStatisticsCustomerService { |
| 55 | 55 | * 获取客户的首次合同、回款信息列表,用于【客户转化率】页面 |
| 56 | 56 | * |
| 57 | 57 | * @param reqVO 请求参数 |
| 58 | - * @return 客户的首次合同、回款信息列表 | |
| 58 | + * @return 统计数据 | |
| 59 | 59 | */ |
| 60 | 60 | List<CrmStatisticsCustomerContractSummaryRespVO> getContractSummary(CrmStatisticsCustomerReqVO reqVO); |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | + * 公海客户分析(按日期) | |
| 64 | + * | |
| 65 | + * @param reqVO 请求参数 | |
| 66 | + * @return 统计数据 | |
| 67 | + */ | |
| 68 | + List<CrmStatisticsPoolSummaryByDateRespVO> getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO); | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 公海客户分析(按用户) | |
| 72 | + * | |
| 73 | + * @param reqVO 请求参数 | |
| 74 | + * @return 统计数据 | |
| 75 | + */ | |
| 76 | + List<CrmStatisticsPoolSummaryByUserRespVO> getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO); | |
| 77 | + | |
| 78 | + /** | |
| 63 | 79 | * 客户成交周期(按日期) |
| 64 | 80 | * |
| 65 | 81 | * 成交周期的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java
| ... | ... | @@ -188,6 +188,60 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | @Override |
| 191 | + public List<CrmStatisticsPoolSummaryByDateRespVO> getPoolSummaryByDate(CrmStatisticsCustomerReqVO reqVO) { | |
| 192 | + // 1. 获得用户编号数组 | |
| 193 | + reqVO.setUserIds(getUserIds(reqVO)); | |
| 194 | + if (CollUtil.isEmpty(reqVO.getUserIds())) { | |
| 195 | + return Collections.emptyList(); | |
| 196 | + } | |
| 197 | + | |
| 198 | + // 2. 按天统计,获取分项统计数据 | |
| 199 | + List<CrmStatisticsPoolSummaryByDateRespVO> customerPutCountList = customerMapper.selectPoolCustomerPutCountByDate(reqVO); | |
| 200 | + List<CrmStatisticsPoolSummaryByDateRespVO> customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByDate(reqVO); | |
| 201 | + | |
| 202 | + // 3. 按照日期间隔,合并数据 | |
| 203 | + List<LocalDateTime[]> timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); | |
| 204 | + return convertList(timeRanges, times -> { | |
| 205 | + Integer customerPutCount = customerPutCountList.stream() | |
| 206 | + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) | |
| 207 | + .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerPutCount).sum(); | |
| 208 | + Integer customerTakeCount = customerTakeCountList.stream() | |
| 209 | + .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) | |
| 210 | + .mapToInt(CrmStatisticsPoolSummaryByDateRespVO::getCustomerTakeCount).sum(); | |
| 211 | + return new CrmStatisticsPoolSummaryByDateRespVO() | |
| 212 | + .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) | |
| 213 | + .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount); | |
| 214 | + }); | |
| 215 | + } | |
| 216 | + | |
| 217 | + @Override | |
| 218 | + public List<CrmStatisticsPoolSummaryByUserRespVO> getPoolSummaryByUser(CrmStatisticsCustomerReqVO reqVO) { | |
| 219 | + // 1. 获得用户编号数组 | |
| 220 | + reqVO.setUserIds(getUserIds(reqVO)); | |
| 221 | + if (CollUtil.isEmpty(reqVO.getUserIds())) { | |
| 222 | + return Collections.emptyList(); | |
| 223 | + } | |
| 224 | + | |
| 225 | + // 2. 按用户统计,获取分项统计数据 | |
| 226 | + List<CrmStatisticsPoolSummaryByUserRespVO> customerPutCountList = customerMapper.selectPoolCustomerPutCountByUser(reqVO); | |
| 227 | + List<CrmStatisticsPoolSummaryByUserRespVO> customerTakeCountList = customerMapper.selectPoolCustomerTakeCountByUser(reqVO); | |
| 228 | + | |
| 229 | + // 3.1 按照用户,合并统计数据 | |
| 230 | + List<CrmStatisticsPoolSummaryByUserRespVO> summaryList = convertList(reqVO.getUserIds(), userId -> { | |
| 231 | + Integer customerPutCount = customerPutCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) | |
| 232 | + .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerPutCount).sum(); | |
| 233 | + Integer customerTakeCount = customerTakeCountList.stream().filter(vo -> userId.equals(vo.getOwnerUserId())) | |
| 234 | + .mapToInt(CrmStatisticsPoolSummaryByUserRespVO::getCustomerTakeCount).sum(); | |
| 235 | + return (CrmStatisticsPoolSummaryByUserRespVO) new CrmStatisticsPoolSummaryByUserRespVO() | |
| 236 | + .setCustomerPutCount(customerPutCount).setCustomerTakeCount(customerTakeCount) | |
| 237 | + .setOwnerUserId(userId); | |
| 238 | + }); | |
| 239 | + // 3.2 拼接用户信息 | |
| 240 | + appendUserInfo(summaryList); | |
| 241 | + return summaryList; | |
| 242 | + } | |
| 243 | + | |
| 244 | + @Override | |
| 191 | 245 | public List<CrmStatisticsCustomerDealCycleByDateRespVO> getCustomerDealCycleByDate(CrmStatisticsCustomerReqVO reqVO) { |
| 192 | 246 | // 1. 获得用户编号数组 |
| 193 | 247 | reqVO.setUserIds(getUserIds(reqVO)); | ... | ... |