mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	feat: CRM/数据统计/员工客户分析/客户跟进次数分析
This commit is contained in:
		| @@ -16,4 +16,24 @@ tenant-id: {{adminTenentId}} | ||||
| ### 成交客户总量分析(按月) | ||||
| 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 | ||||
| Authorization: Bearer {{token}} | ||||
| tenant-id: {{adminTenentId}} | ||||
|  | ||||
| ### 获取客户跟进次数(按日) | ||||
| GET {{baseUrl}}/crm/statistics-customer/get-record-count?deptId=100×[0]=2024-12-01 00:00:00×[1]=2024-12-12 23:59:59 | ||||
| Authorization: Bearer {{token}} | ||||
| tenant-id: {{adminTenentId}} | ||||
|  | ||||
| ### 获取客户跟进次数(按月) | ||||
| GET {{baseUrl}}/crm/statistics-customer/get-record-count?deptId=100×[0]=2023-01-01 00:00:00×[1]=2024-12-12 23:59:59 | ||||
| Authorization: Bearer {{token}} | ||||
| tenant-id: {{adminTenentId}} | ||||
|  | ||||
| ### 获取已跟进客户数(按日) | ||||
| 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 | ||||
| Authorization: Bearer {{token}} | ||||
| tenant-id: {{adminTenentId}} | ||||
|  | ||||
| ### 获取已跟进客户数(按月) | ||||
| 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 | ||||
| Authorization: Bearer {{token}} | ||||
| tenant-id: {{adminTenentId}} | ||||
| @@ -41,4 +41,18 @@ public class CrmStatisticsCustomerController { | ||||
|         return success(customerService.getDealTotalCustomerCount(reqVO)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get-record-count") | ||||
|     @Operation(summary = "获取客户跟进次数") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | ||||
|     public CommonResult<List<CrmStatisticsCustomerCountVO>> getRecordCount(@Valid CrmStatisticsCustomerReqVO reqVO) { | ||||
|         return success(customerService.getRecordCount(reqVO)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/get-distinct-record-count") | ||||
|     @Operation(summary = "获取已跟进客户数") | ||||
|     @PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')") | ||||
|     public CommonResult<List<CrmStatisticsCustomerCountVO>> getDistinctRecordCount(@Valid CrmStatisticsCustomerReqVO reqVO) { | ||||
|         return success(customerService.getDistinctRecordCount(reqVO)); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import jakarta.validation.constraints.NotEmpty; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| @@ -44,4 +45,10 @@ public class CrmStatisticsCustomerReqVO { | ||||
|     @Schema(description = "Group By 日期格式", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "%Y%m") | ||||
|     private String sqlDateFormat; | ||||
|  | ||||
|     /** | ||||
|      * 数据类型 {@link CrmBizTypeEnum} | ||||
|      */ | ||||
|     @Schema(description = "数据类型", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2") | ||||
|     private Integer bizType; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -18,4 +18,8 @@ public interface CrmStatisticsCustomerMapper { | ||||
|  | ||||
|     List<CrmStatisticsCustomerCountVO> selectDealCustomerCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
|     List<CrmStatisticsCustomerCountVO> selectRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
|     List<CrmStatisticsCustomerCountVO> selectDistinctRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.crm.service.statistics; | ||||
|  | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @@ -28,4 +28,21 @@ public interface CrmStatisticsCustomerService { | ||||
|      */ | ||||
|     List<CrmStatisticsCustomerCountVO> getDealTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
|  | ||||
|     /** | ||||
|      * 获取客户跟进次数 | ||||
|      * | ||||
|      * @param reqVO 请求参数 | ||||
|      * @return 客户跟进次数 | ||||
|      */ | ||||
|     List<CrmStatisticsCustomerCountVO> getRecordCount(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
|     /** | ||||
|      * 获取已跟进客户数 | ||||
|      * | ||||
|      * @param reqVO 请求参数 | ||||
|      * @return 已跟进客户数 | ||||
|      */ | ||||
|     List<CrmStatisticsCustomerCountVO> getDistinctRecordCount(CrmStatisticsCustomerReqVO reqVO); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjUtil; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO; | ||||
| import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper; | ||||
| import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||
| import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||||
| import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||||
| @@ -49,6 +50,18 @@ public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerSe | ||||
|         return getStat(reqVO, customerMapper::selectDealCustomerCountGroupbyDate); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmStatisticsCustomerCountVO> getRecordCount(CrmStatisticsCustomerReqVO reqVO) { | ||||
|         reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||||
|         return getStat(reqVO, customerMapper::selectRecordCountGroupbyDate); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public List<CrmStatisticsCustomerCountVO> getDistinctRecordCount(CrmStatisticsCustomerReqVO reqVO) { | ||||
|         reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()); | ||||
|         return getStat(reqVO, customerMapper::selectDistinctRecordCountGroupbyDate); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获得统计数据 | ||||
|      * | ||||
|   | ||||
| @@ -43,4 +43,41 @@ | ||||
|             DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} ) | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectRecordCountGroupbyDate" | ||||
|             resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO"> | ||||
|         SELECT | ||||
|             DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category, | ||||
|             count(*) AS count | ||||
|           FROM | ||||
|             crm_follow_up_record | ||||
|          WHERE | ||||
|             creator IN | ||||
|                 <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||||
|                     #{userId} | ||||
|                 </foreach> | ||||
|           AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||||
|                 #{times[1],javaType=java.time.LocalDateTime} | ||||
|           AND biz_type = #{bizType,javaType=java.lang.Integer} | ||||
|         GROUP BY | ||||
|             DATE_FORMAT (create_time, #{sqlDateFormat,javaType=java.lang.String} ) | ||||
|     </select> | ||||
|  | ||||
|     <select id="selectDistinctRecordCountGroupbyDate" | ||||
|             resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO"> | ||||
|         SELECT | ||||
|             DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category, | ||||
|             count(DISTINCT biz_id) AS count | ||||
|           FROM | ||||
|             crm_follow_up_record | ||||
|          WHERE | ||||
|             creator IN | ||||
|                 <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | ||||
|                     #{userId} | ||||
|                 </foreach> | ||||
|           AND create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND | ||||
|                 #{times[1],javaType=java.time.LocalDateTime} | ||||
|           AND biz_type = #{bizType,javaType=java.lang.Integer} | ||||
|         GROUP BY DATE_FORMAT (create_time, #{sqlDateFormat,javaType=java.lang.String} ) | ||||
|     </select> | ||||
|  | ||||
| </mapper> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 dhb52
					dhb52