feat: CRM/数据统计/客户总量分析
parent
b285548b9d
commit
7d120a2f36
@ -0,0 +1,19 @@
|
|||||||
|
### 新建客户总量分析(按日)
|
||||||
|
GET {{baseUrl}}/crm/statistics-customer/get-total-customer-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-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-deal-total-customer-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-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}}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package cn.iocoder.yudao.module.crm.controller.admin.statistics;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
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 cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsCustomerService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - CRM 数据统计 员工客户分析")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/crm/statistics-customer")
|
||||||
|
@Validated
|
||||||
|
public class CrmStatisticsCustomerController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CrmStatisticsCustomerService customerService;
|
||||||
|
|
||||||
|
@GetMapping("/get-total-customer-count")
|
||||||
|
@Operation(summary = "获得新建客户数量")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')")
|
||||||
|
public CommonResult<List<CrmStatisticsCustomerCountVO>> getTotalCustomerCount(@Valid CrmStatisticsCustomerReqVO reqVO) {
|
||||||
|
return success(customerService.getTotalCustomerCount(reqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get-deal-total-customer-count")
|
||||||
|
@Operation(summary = "获得成交客户数量")
|
||||||
|
@PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')")
|
||||||
|
public CommonResult<List<CrmStatisticsCustomerCountVO>> getDealTotalCustomerCount(@Valid CrmStatisticsCustomerReqVO reqVO) {
|
||||||
|
return success(customerService.getDealTotalCustomerCount(reqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package cn.iocoder.yudao.module.crm.dal.mysql.statistics;
|
||||||
|
|
||||||
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRM 数据统计 员工客户分析 Mapper
|
||||||
|
*
|
||||||
|
* @author dhb52
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CrmStatisticsCustomerMapper {
|
||||||
|
|
||||||
|
List<CrmStatisticsCustomerCountVO> selectCustomerCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO);
|
||||||
|
|
||||||
|
List<CrmStatisticsCustomerCountVO> selectDealCustomerCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
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 java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CRM 数据统计 员工客户分析 Service 接口
|
||||||
|
*
|
||||||
|
* @author dhb52
|
||||||
|
*/
|
||||||
|
public interface CrmStatisticsCustomerService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取新建客户数量
|
||||||
|
*
|
||||||
|
* @param reqVO 请求参数
|
||||||
|
* @return 新建客户数量统计
|
||||||
|
*/
|
||||||
|
List<CrmStatisticsCustomerCountVO> getTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成交客户数量
|
||||||
|
*
|
||||||
|
* @param reqVO 请求参数
|
||||||
|
* @return 成交客户数量统计
|
||||||
|
*/
|
||||||
|
List<CrmStatisticsCustomerCountVO> getDealTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsCustomerMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectCustomerCountGroupbyDate"
|
||||||
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO">
|
||||||
|
SELECT
|
||||||
|
count(*) AS count,
|
||||||
|
DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category
|
||||||
|
FROM
|
||||||
|
crm_customer
|
||||||
|
WHERE
|
||||||
|
deleted = 0
|
||||||
|
AND owner_user_id 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}
|
||||||
|
GROUP BY
|
||||||
|
DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} )
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDealCustomerCountGroupbyDate"
|
||||||
|
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO">
|
||||||
|
SELECT
|
||||||
|
count( DISTINCT a.id ) AS count,
|
||||||
|
DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} ) AS category
|
||||||
|
FROM
|
||||||
|
crm_customer AS a
|
||||||
|
LEFT JOIN crm_contract AS b ON b.customer_id = a.id
|
||||||
|
WHERE
|
||||||
|
a.deleted = 0 AND b.deleted = 0
|
||||||
|
AND b.audit_status = 20
|
||||||
|
AND a.owner_user_id IN
|
||||||
|
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
AND b.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND
|
||||||
|
#{times[1],javaType=java.time.LocalDateTime}
|
||||||
|
GROUP BY
|
||||||
|
DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} )
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue