Commit fbb624d826667a6ae7b537ac89d2bf60d2ae1948
1 parent
a0b413b3
feat: CRM/数据统计/员工客户分析/客户跟进次数分析
Showing
7 changed files
with
113 additions
and
1 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsCustomerController.http
| ... | ... | @@ -16,4 +16,24 @@ tenant-id: {{adminTenentId}} |
| 16 | 16 | ### 成交客户总量分析(按月) |
| 17 | 17 | GET {{baseUrl}}/crm/statistics-customer/get-deal-total-customer-count?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 |
| 18 | 18 | Authorization: Bearer {{token}} |
| 19 | +tenant-id: {{adminTenentId}} | |
| 20 | + | |
| 21 | +### 获取客户跟进次数(按日) | |
| 22 | +GET {{baseUrl}}/crm/statistics-customer/get-record-count?deptId=100×[0]=2024-12-01 00:00:00×[1]=2024-12-12 23:59:59 | |
| 23 | +Authorization: Bearer {{token}} | |
| 24 | +tenant-id: {{adminTenentId}} | |
| 25 | + | |
| 26 | +### 获取客户跟进次数(按月) | |
| 27 | +GET {{baseUrl}}/crm/statistics-customer/get-record-count?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 | |
| 28 | +Authorization: Bearer {{token}} | |
| 29 | +tenant-id: {{adminTenentId}} | |
| 30 | + | |
| 31 | +### 获取已跟进客户数(按日) | |
| 32 | +GET {{baseUrl}}/crm/statistics-customer/get-distinct-record-count?deptId=100×[0]=2024-12-01 00:00:00×[1]=2024-12-12 23:59:59 | |
| 33 | +Authorization: Bearer {{token}} | |
| 34 | +tenant-id: {{adminTenentId}} | |
| 35 | + | |
| 36 | +### 获取已跟进客户数(按月) | |
| 37 | +GET {{baseUrl}}/crm/statistics-customer/get-distinct-record-count?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 | |
| 38 | +Authorization: Bearer {{token}} | |
| 19 | 39 | tenant-id: {{adminTenentId}} |
| 20 | 40 | \ 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
| ... | ... | @@ -41,4 +41,18 @@ public class CrmStatisticsCustomerController { |
| 41 | 41 | return success(customerService.getDealTotalCustomerCount(reqVO)); |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | + @GetMapping("/get-record-count") | |
| 45 | + @Operation(summary = "获取客户跟进次数") | |
| 46 | + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | |
| 47 | + public CommonResult<List<CrmStatisticsCustomerCountVO>> getRecordCount(@Valid CrmStatisticsCustomerReqVO reqVO) { | |
| 48 | + return success(customerService.getRecordCount(reqVO)); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @GetMapping("/get-distinct-record-count") | |
| 52 | + @Operation(summary = "获取已跟进客户数") | |
| 53 | + @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | |
| 54 | + public CommonResult<List<CrmStatisticsCustomerCountVO>> getDistinctRecordCount(@Valid CrmStatisticsCustomerReqVO reqVO) { | |
| 55 | + return success(customerService.getDistinctRecordCount(reqVO)); | |
| 56 | + } | |
| 57 | + | |
| 44 | 58 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 5 | import jakarta.validation.constraints.NotEmpty; |
| 5 | 6 | import jakarta.validation.constraints.NotNull; |
| ... | ... | @@ -44,4 +45,10 @@ public class CrmStatisticsCustomerReqVO { |
| 44 | 45 | @Schema(description = "Group By 日期格式", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "%Y%m") |
| 45 | 46 | private String sqlDateFormat; |
| 46 | 47 | |
| 48 | + /** | |
| 49 | + * 数据类型 {@link CrmBizTypeEnum} | |
| 50 | + */ | |
| 51 | + @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") | |
| 52 | + private Integer bizType; | |
| 53 | + | |
| 47 | 54 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsCustomerMapper.java
| ... | ... | @@ -18,4 +18,8 @@ public interface CrmStatisticsCustomerMapper { |
| 18 | 18 | |
| 19 | 19 | List<CrmStatisticsCustomerCountVO> selectDealCustomerCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); |
| 20 | 20 | |
| 21 | + List<CrmStatisticsCustomerCountVO> selectRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | |
| 22 | + | |
| 23 | + List<CrmStatisticsCustomerCountVO> selectDistinctRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | |
| 24 | + | |
| 21 | 25 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.statistics; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; | |
| 4 | 3 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO; |
| 4 | +import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; | |
| 5 | 5 | |
| 6 | 6 | import java.util.List; |
| 7 | 7 | |
| ... | ... | @@ -28,4 +28,21 @@ public interface CrmStatisticsCustomerService { |
| 28 | 28 | */ |
| 29 | 29 | List<CrmStatisticsCustomerCountVO> getDealTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO); |
| 30 | 30 | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 获取客户跟进次数 | |
| 34 | + * | |
| 35 | + * @param reqVO 请求参数 | |
| 36 | + * @return 客户跟进次数 | |
| 37 | + */ | |
| 38 | + List<CrmStatisticsCustomerCountVO> getRecordCount(CrmStatisticsCustomerReqVO reqVO); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获取已跟进客户数 | |
| 42 | + * | |
| 43 | + * @param reqVO 请求参数 | |
| 44 | + * @return 已跟进客户数 | |
| 45 | + */ | |
| 46 | + List<CrmStatisticsCustomerCountVO> getDistinctRecordCount(CrmStatisticsCustomerReqVO reqVO); | |
| 47 | + | |
| 31 | 48 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsCustomerServiceImpl.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjUtil; |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; |
| 9 | +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | |
| 9 | 10 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 10 | 11 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 11 | 12 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| ... | ... | @@ -49,6 +50,18 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe |
| 49 | 50 | return getStat(reqVO, customerMapper::selectDealCustomerCountGroupbyDate); |
| 50 | 51 | } |
| 51 | 52 | |
| 53 | + @Override | |
| 54 | + public List<CrmStatisticsCustomerCountVO> getRecordCount(CrmStatisticsCustomerReqVO reqVO) { | |
| 55 | + reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | |
| 56 | + return getStat(reqVO, customerMapper::selectRecordCountGroupbyDate); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + public List<CrmStatisticsCustomerCountVO> getDistinctRecordCount(CrmStatisticsCustomerReqVO reqVO) { | |
| 61 | + reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | |
| 62 | + return getStat(reqVO, customerMapper::selectDistinctRecordCountGroupbyDate); | |
| 63 | + } | |
| 64 | + | |
| 52 | 65 | /** |
| 53 | 66 | * 获得统计数据 |
| 54 | 67 | * | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsCustomerMapper.xml
| ... | ... | @@ -43,4 +43,41 @@ |
| 43 | 43 | DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} ) |
| 44 | 44 | </select> |
| 45 | 45 | |
| 46 | + <select id="selectRecordCountGroupbyDate" | |
| 47 | + resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO"> | |
| 48 | + SELECT | |
| 49 | + DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category, | |
| 50 | + count(*) AS count | |
| 51 | + FROM | |
| 52 | + crm_follow_up_record | |
| 53 | + WHERE | |
| 54 | + creator IN | |
| 55 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | |
| 56 | + #{userId} | |
| 57 | + </foreach> | |
| 58 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | |
| 59 | + #{times[1],javaType=java.time.LocalDateTime} | |
| 60 | + AND biz_type = #{bizType,javaType=java.lang.Integer} | |
| 61 | + GROUP BY | |
| 62 | + DATE_FORMAT (create_time, #{sqlDateFormat,javaType=java.lang.String} ) | |
| 63 | + </select> | |
| 64 | + | |
| 65 | + <select id="selectDistinctRecordCountGroupbyDate" | |
| 66 | + resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO"> | |
| 67 | + SELECT | |
| 68 | + DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category, | |
| 69 | + count(DISTINCT biz_id) AS count | |
| 70 | + FROM | |
| 71 | + crm_follow_up_record | |
| 72 | + WHERE | |
| 73 | + creator IN | |
| 74 | + <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | |
| 75 | + #{userId} | |
| 76 | + </foreach> | |
| 77 | + AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | |
| 78 | + #{times[1],javaType=java.time.LocalDateTime} | |
| 79 | + AND biz_type = #{bizType,javaType=java.lang.Integer} | |
| 80 | + GROUP BY DATE_FORMAT (create_time, #{sqlDateFormat,javaType=java.lang.String} ) | |
| 81 | + </select> | |
| 82 | + | |
| 46 | 83 | </mapper> | ... | ... |