mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
!889 feat: CRM/数据统计/员工客户分析 初稿
Merge pull request !889 from dhb52/develop
This commit is contained in:
commit
2bf5c7a701
@ -0,0 +1,39 @@
|
||||
### 新建客户总量分析(按日)
|
||||
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}}
|
||||
|
||||
### 获取客户跟进次数(按日)
|
||||
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}}
|
@ -0,0 +1,72 @@
|
||||
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));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
||||
@GetMapping("/get-record-type-count")
|
||||
@Operation(summary = "获取客户跟进方式统计数")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')")
|
||||
public CommonResult<List<CrmStatisticsCustomerCountVO>> getRecordTypeCount(@Valid CrmStatisticsCustomerReqVO reqVO) {
|
||||
return success(customerService.getRecordTypeCount(reqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-customer-cycle")
|
||||
@Operation(summary = "获取客户成交周期")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')")
|
||||
public CommonResult<List<CrmStatisticsCustomerCountVO>> getCustomerCycle(@Valid CrmStatisticsCustomerReqVO reqVO) {
|
||||
return success(customerService.getCustomerCycle(reqVO));
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
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.CrmStatisticsRanKRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsRankingService;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsRankService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -19,69 +19,69 @@ import java.util.List;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
|
||||
@Tag(name = "管理后台 - CRM 排行榜统计")
|
||||
@Tag(name = "管理后台 - CRM 数据统计 排行榜统计")
|
||||
@RestController
|
||||
@RequestMapping("/crm/statistics-rank")
|
||||
@Validated
|
||||
public class CrmStatisticsRankController {
|
||||
|
||||
@Resource
|
||||
private CrmStatisticsRankingService rankingService;
|
||||
private CrmStatisticsRankService rankService;
|
||||
|
||||
@GetMapping("/get-contract-price-rank")
|
||||
@Operation(summary = "获得合同金额排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getContractPriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getContractPriceRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getContractPriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getContractPriceRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-receivable-price-rank")
|
||||
@Operation(summary = "获得回款金额排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getReceivablePriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getReceivablePriceRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getReceivablePriceRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getReceivablePriceRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-contract-count-rank")
|
||||
@Operation(summary = "获得签约合同数量排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getContractCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getContractCountRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getContractCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getContractCountRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-product-sales-rank")
|
||||
@Operation(summary = "获得产品销量排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getProductSalesRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getProductSalesRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getProductSalesRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getProductSalesRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-customer-count-rank")
|
||||
@Operation(summary = "获得新增客户数排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getCustomerCountRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getCustomerCountRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-contacts-count-rank")
|
||||
@Operation(summary = "获得新增联系人数排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getContactsCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getContactsCountRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getContactsCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getContactsCountRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-follow-count-rank")
|
||||
@Operation(summary = "获得跟进次数排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getFollowCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getFollowCountRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getFollowCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getFollowCountRank(rankingReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/get-follow-customer-count-rank")
|
||||
@Operation(summary = "获得跟进客户数排行榜")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-rank:query')")
|
||||
public CommonResult<List<CrmStatisticsRanKRespVO>> getFollowCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankingService.getFollowCustomerCountRank(rankingReqVO));
|
||||
public CommonResult<List<CrmStatisticsRankRespVO>> getFollowCustomerCountRank(@Valid CrmStatisticsRankReqVO rankingReqVO) {
|
||||
return success(rankService.getFollowCustomerCountRank(rankingReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
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 CrmStatisticsCustomerCountVO {
|
||||
|
||||
/**
|
||||
* 时间轴
|
||||
* <p>
|
||||
* group by DATE_FORMAT(create_date, '%Y%m')
|
||||
*/
|
||||
@Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 数量是个特别“抽象”的概念,在不同排行下,代表不同含义
|
||||
* <p>
|
||||
* 1. 金额:合同金额排行、回款金额排行
|
||||
* 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行
|
||||
*/
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer count = 0;
|
||||
|
||||
/**
|
||||
* 成交周期(天)
|
||||
*/
|
||||
@Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0")
|
||||
private Double cycle = 0.0;
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
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;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 数据统计 员工客户分析 Request VO")
|
||||
@Data
|
||||
public class CrmStatisticsCustomerReqVO {
|
||||
|
||||
@Schema(description = "部门 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "部门 id 不能为空")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 负责人用户 id, 当用户为空, 则计算部门下用户
|
||||
*/
|
||||
@Schema(description = "负责人用户 id", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来
|
||||
* <p>
|
||||
* 后续,可能会支持选择部分用户进行查询
|
||||
*/
|
||||
@Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2")
|
||||
private List<Long> userIds;
|
||||
|
||||
@Schema(description = "时间范围", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@NotEmpty(message = "时间范围不能为空")
|
||||
private LocalDateTime[] times;
|
||||
|
||||
/**
|
||||
* group by DATE_FORMAT(field, #{dateFormat})
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo;
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
@ -11,7 +11,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 排行榜统计 Request VO")
|
||||
@Schema(description = "管理后台 - CRM 数据统计 排行榜统计 Request VO")
|
||||
@Data
|
||||
public class CrmStatisticsRankReqVO {
|
||||
|
||||
@ -21,7 +21,7 @@ public class CrmStatisticsRankReqVO {
|
||||
|
||||
/**
|
||||
* userIds 目前不用前端传递,目前是方便后端通过 deptId 读取编号后,设置回来
|
||||
*
|
||||
* <p>
|
||||
* 后续,可能会支持选择部分用户进行查询
|
||||
*/
|
||||
@Schema(description = "负责人用户 id 集合", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "2")
|
@ -1,12 +1,12 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo;
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Schema(description = "管理后台 - CRM BI 排行榜统计 Response VO")
|
||||
@Schema(description = "管理后台 - CRM 数据统计 排行榜统计 Response VO")
|
||||
@Data
|
||||
public class CrmStatisticsRanKRespVO {
|
||||
public class CrmStatisticsRankRespVO {
|
||||
|
||||
@Schema(description = "负责人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long ownerUserId;
|
||||
@ -19,7 +19,7 @@ public class CrmStatisticsRanKRespVO {
|
||||
|
||||
/**
|
||||
* 数量是个特别“抽象”的概念,在不同排行下,代表不同含义
|
||||
*
|
||||
* <p>
|
||||
* 1. 金额:合同金额排行、回款金额排行
|
||||
* 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行
|
||||
*/
|
@ -0,0 +1,29 @@
|
||||
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);
|
||||
|
||||
List<CrmStatisticsCustomerCountVO> selectRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
List<CrmStatisticsCustomerCountVO> selectDistinctRecordCountGroupbyDate(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
List<CrmStatisticsCustomerCountVO> selectRecordCountGroupbyType(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
List<CrmStatisticsCustomerCountVO> selectCustomerCycleGroupbyDate(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
}
|
@ -1,18 +1,18 @@
|
||||
package cn.iocoder.yudao.module.crm.dal.mysql.statistics;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 排行榜统计 Mapper
|
||||
* CRM 数据统计 排行榜统计 Mapper
|
||||
*
|
||||
* @author anhaohao
|
||||
*/
|
||||
@Mapper
|
||||
public interface CrmStatisticsRankingMapper {
|
||||
public interface CrmStatisticsRankMapper {
|
||||
|
||||
/**
|
||||
* 查询合同金额排行榜
|
||||
@ -20,7 +20,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 合同金额排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询回款金额排行榜
|
||||
@ -28,7 +28,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 回款金额排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询签约合同数量排行榜
|
||||
@ -36,7 +36,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 签约合同数量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectContractCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectContractCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询产品销量排行榜
|
||||
@ -44,7 +44,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 产品销量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询新增客户数排行榜
|
||||
@ -52,7 +52,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 新增客户数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询联系人数量排行榜
|
||||
@ -60,7 +60,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 联系人数量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询跟进次数排行榜
|
||||
@ -68,7 +68,7 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 跟进次数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 查询跟进客户数排行榜
|
||||
@ -76,6 +76,6 @@ public interface CrmStatisticsRankingMapper {
|
||||
* @param rankReqVO 参数
|
||||
* @return 跟进客户数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> selectFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> selectFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package cn.iocoder.yudao.module.crm.service.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 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);
|
||||
|
||||
|
||||
/**
|
||||
* 获取客户跟进次数
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 客户跟进次数
|
||||
*/
|
||||
List<CrmStatisticsCustomerCountVO> getRecordCount(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取已跟进客户数
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 已跟进客户数
|
||||
*/
|
||||
List<CrmStatisticsCustomerCountVO> getDistinctRecordCount(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取客户跟进方式统计数
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 客户跟进方式统计数
|
||||
*/
|
||||
List<CrmStatisticsCustomerCountVO> getRecordTypeCount(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取客户成交周期
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 客户成交周期
|
||||
*/
|
||||
List<CrmStatisticsCustomerCountVO> getCustomerCycle(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package cn.iocoder.yudao.module.crm.service.statistics;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
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.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.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
|
||||
/**
|
||||
* CRM 数据统计 员工客户分析 Service 实现类
|
||||
*
|
||||
* @author dhb52
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmStatisticsCustomerServiceImpl implements CrmStatisticsCustomerService {
|
||||
|
||||
@Resource
|
||||
private CrmStatisticsCustomerMapper customerMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsCustomerCountVO> getTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO) {
|
||||
return getStat(reqVO, customerMapper::selectCustomerCountGroupbyDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsCustomerCountVO> getDealTotalCustomerCount(CrmStatisticsCustomerReqVO reqVO) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsCustomerCountVO> getRecordTypeCount(CrmStatisticsCustomerReqVO reqVO) {
|
||||
// 1. 获得用户编号数组: 如果用户编号为空, 则获得部门下的用户编号数组
|
||||
if (ObjUtil.isNotNull(reqVO.getUserId())) {
|
||||
reqVO.setUserIds(List.of(reqVO.getUserId()));
|
||||
} else {
|
||||
reqVO.setUserIds(getUserIds(reqVO.getDeptId()));
|
||||
}
|
||||
if (CollUtil.isEmpty(reqVO.getUserIds())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 2. 获得排行数据
|
||||
reqVO.setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType());
|
||||
List<CrmStatisticsCustomerCountVO> stats = customerMapper.selectRecordCountGroupbyType(reqVO);
|
||||
|
||||
// 3. 获取字典数据
|
||||
List<DictDataRespDTO> followUpTypes = dictDataApi.getDictDataList("crm_follow_up_type");
|
||||
final Map<String, String> followUpTypeMap = convertMap(followUpTypes, DictDataRespDTO::getValue, DictDataRespDTO::getLabel);
|
||||
stats.forEach(stat -> {
|
||||
stat.setCategory(followUpTypeMap.get(stat.getCategory()));
|
||||
});
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsCustomerCountVO> getCustomerCycle(CrmStatisticsCustomerReqVO reqVO) {
|
||||
return getStat(reqVO, customerMapper::selectCustomerCycleGroupbyDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得统计数据
|
||||
*
|
||||
* @param reqVO 参数
|
||||
* @param statFunction 统计方法
|
||||
* @return 统计数据
|
||||
*/
|
||||
private List<CrmStatisticsCustomerCountVO> getStat(CrmStatisticsCustomerReqVO reqVO, Function<CrmStatisticsCustomerReqVO, List<CrmStatisticsCustomerCountVO>> statFunction) {
|
||||
// 1. 获得用户编号数组: 如果用户编号为空, 则获得部门下的用户编号数组
|
||||
if (ObjUtil.isNotNull(reqVO.getUserId())) {
|
||||
reqVO.setUserIds(List.of(reqVO.getUserId()));
|
||||
} else {
|
||||
reqVO.setUserIds(getUserIds(reqVO.getDeptId()));
|
||||
}
|
||||
if (CollUtil.isEmpty(reqVO.getUserIds())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 2. 生成日期格式
|
||||
LocalDateTime startTime = reqVO.getTimes()[0];
|
||||
final LocalDateTime endTime = reqVO.getTimes()[1];
|
||||
final long days = LocalDateTimeUtil.between(startTime, endTime).toDays();
|
||||
boolean byMonth = days > 31;
|
||||
if (byMonth) {
|
||||
// 按月
|
||||
reqVO.setSqlDateFormat("%Y%m");
|
||||
} else {
|
||||
// 按日
|
||||
reqVO.setSqlDateFormat("%Y%m%d");
|
||||
}
|
||||
|
||||
// 3. 获得排行数据
|
||||
List<CrmStatisticsCustomerCountVO> stats = statFunction.apply(reqVO);
|
||||
|
||||
// 4. 生成时间序列
|
||||
List<CrmStatisticsCustomerCountVO> result = CollUtil.newArrayList();
|
||||
while (!startTime.isAfter(endTime)) {
|
||||
final String category = LocalDateTimeUtil.format(startTime, byMonth ? "yyyyMM" : "yyyyMMdd");
|
||||
result.add(new CrmStatisticsCustomerCountVO().setCategory(category));
|
||||
if (byMonth)
|
||||
startTime = startTime.plusMonths(1);
|
||||
else
|
||||
startTime = startTime.plusDays(1);
|
||||
}
|
||||
|
||||
// 5. 使用时间序列填充结果
|
||||
final Map<String, CrmStatisticsCustomerCountVO> statMap = convertMap(stats,
|
||||
CrmStatisticsCustomerCountVO::getCategory,
|
||||
Function.identity());
|
||||
result.forEach(r -> {
|
||||
if (statMap.containsKey(r.getCategory())) {
|
||||
r.setCount(statMap.get(r.getCategory()).getCount())
|
||||
.setCycle(statMap.get(r.getCategory()).getCycle());
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得部门下的用户编号数组,包括子部门的
|
||||
*
|
||||
* @param deptId 部门编号
|
||||
* @return 用户编号数组
|
||||
*/
|
||||
public List<Long> getUserIds(Long deptId) {
|
||||
// 1. 获得部门列表
|
||||
List<Long> deptIds = convertList(deptApi.getChildDeptList(deptId), DeptRespDTO::getId);
|
||||
deptIds.add(deptId);
|
||||
// 2. 获得用户编号
|
||||
return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId);
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package cn.iocoder.yudao.module.crm.service.statistics;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CRM 排行榜统计 Service 接口
|
||||
* CRM 数据统计 排行榜统计 Service 接口
|
||||
*
|
||||
* @author anhaohao
|
||||
*/
|
||||
public interface CrmStatisticsRankingService {
|
||||
public interface CrmStatisticsRankService {
|
||||
|
||||
/**
|
||||
* 获得合同金额排行榜
|
||||
@ -19,7 +19,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 合同金额排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得回款金额排行榜
|
||||
@ -27,7 +27,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 回款金额排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得签约合同数量排行榜
|
||||
@ -35,7 +35,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 签约合同数量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得产品销量排行榜
|
||||
@ -43,7 +43,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 产品销量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得新增客户数排行榜
|
||||
@ -51,7 +51,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 新增客户数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得联系人数量排行榜
|
||||
@ -59,7 +59,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 联系人数量排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得跟进次数排行榜
|
||||
@ -67,7 +67,7 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 跟进次数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
/**
|
||||
* 获得跟进客户数排行榜
|
||||
@ -75,6 +75,6 @@ public interface CrmStatisticsRankingService {
|
||||
* @param rankReqVO 排行参数
|
||||
* @return 跟进客户数排行榜
|
||||
*/
|
||||
List<CrmStatisticsRanKRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO);
|
||||
|
||||
}
|
@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.crm.service.statistics;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankingMapper;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankMapper;
|
||||
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;
|
||||
@ -23,16 +23,16 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
* CRM 排行榜统计 Service 实现类
|
||||
* CRM 数据统计 排行榜统计 Service 实现类
|
||||
*
|
||||
* @author anhaohao
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmStatisticsRankingServiceImpl implements CrmStatisticsRankingService {
|
||||
public class CrmStatisticsRankServiceImpl implements CrmStatisticsRankService {
|
||||
|
||||
@Resource
|
||||
private CrmStatisticsRankingMapper rankMapper;
|
||||
private CrmStatisticsRankMapper rankMapper;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@ -40,64 +40,64 @@ public class CrmStatisticsRankingServiceImpl implements CrmStatisticsRankingServ
|
||||
private DeptApi deptApi;
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getContractPriceRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectContractPriceRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getReceivablePriceRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectReceivablePriceRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getContractCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectContractCountRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getProductSalesRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectProductSalesRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectCustomerCountRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getContactsCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectContactsCountRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getFollowCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectFollowCountRank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmStatisticsRanKRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
public List<CrmStatisticsRankRespVO> getFollowCustomerCountRank(CrmStatisticsRankReqVO rankReqVO) {
|
||||
return getRank(rankReqVO, rankMapper::selectFollowCustomerCountRank);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得排行版数据
|
||||
*
|
||||
* @param rankReqVO 参数
|
||||
* @param rankReqVO 参数
|
||||
* @param rankFunction 排行榜方法
|
||||
* @return 排行版数据
|
||||
*/
|
||||
private List<CrmStatisticsRanKRespVO> getRank(CrmStatisticsRankReqVO rankReqVO, Function<CrmStatisticsRankReqVO, List<CrmStatisticsRanKRespVO>> rankFunction) {
|
||||
private List<CrmStatisticsRankRespVO> getRank(CrmStatisticsRankReqVO rankReqVO, Function<CrmStatisticsRankReqVO, List<CrmStatisticsRankRespVO>> rankFunction) {
|
||||
// 1. 获得用户编号数组
|
||||
rankReqVO.setUserIds(getUserIds(rankReqVO.getDeptId()));
|
||||
if (CollUtil.isEmpty(rankReqVO.getUserIds())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
// 2. 获得排行数据
|
||||
List<CrmStatisticsRanKRespVO> ranks = rankFunction.apply(rankReqVO);
|
||||
List<CrmStatisticsRankRespVO> ranks = rankFunction.apply(rankReqVO);
|
||||
if (CollUtil.isEmpty(ranks)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ranks.sort(Comparator.comparing(CrmStatisticsRanKRespVO::getCount).reversed());
|
||||
ranks.sort(Comparator.comparing(CrmStatisticsRankRespVO::getCount).reversed());
|
||||
// 3. 拼接用户信息
|
||||
appendUserInfo(ranks);
|
||||
return ranks;
|
||||
@ -108,8 +108,8 @@ public class CrmStatisticsRankingServiceImpl implements CrmStatisticsRankingServ
|
||||
*
|
||||
* @param ranks 排行榜数据
|
||||
*/
|
||||
private void appendUserInfo(List<CrmStatisticsRanKRespVO> ranks) {
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(ranks, CrmStatisticsRanKRespVO::getOwnerUserId));
|
||||
private void appendUserInfo(List<CrmStatisticsRankRespVO> ranks) {
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(ranks, CrmStatisticsRankRespVO::getOwnerUserId));
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||
ranks.forEach(rank -> MapUtils.findAndThen(userMap, rank.getOwnerUserId(), user -> {
|
||||
rank.setNickname(user.getNickname());
|
@ -0,0 +1,116 @@
|
||||
<?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
|
||||
DATE_FORMAT( create_time, #{sqlDateFormat,javaType=java.lang.String} ) AS category,
|
||||
count(*) AS count
|
||||
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 category
|
||||
</select>
|
||||
|
||||
<select id="selectDealCustomerCountGroupbyDate"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO">
|
||||
SELECT
|
||||
DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} ) AS category,
|
||||
count( DISTINCT a.id ) AS count
|
||||
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 category
|
||||
</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 category
|
||||
</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 category
|
||||
</select>
|
||||
|
||||
<select id="selectRecordCountGroupbyType"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO">
|
||||
SELECT
|
||||
type 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 category
|
||||
</select>
|
||||
|
||||
<select id="selectCustomerCycleGroupbyDate"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerCountVO">
|
||||
SELECT
|
||||
DATE_FORMAT( b.order_date, #{sqlDateFormat,javaType=java.lang.String} ) AS category,
|
||||
IFNULL( TRUNCATE ( AVG( TIMESTAMPDIFF( DAY, a.create_time, b.order_date )), 1 ), 0 ) AS cycle
|
||||
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 category
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -1,9 +1,9 @@
|
||||
<?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.CrmStatisticsRankingMapper">
|
||||
<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsRankMapper">
|
||||
|
||||
<select id="selectContractPriceRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT IFNULL(SUM(total_price), 0) AS count, owner_user_id
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
@ -18,7 +18,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectReceivablePriceRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT IFNULL(SUM(price), 0) AS count, owner_user_id
|
||||
FROM crm_receivable
|
||||
WHERE deleted = 0
|
||||
@ -33,7 +33,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectContractCountRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(1) AS count, owner_user_id
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
@ -49,7 +49,7 @@
|
||||
|
||||
<!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 -->
|
||||
<select id="selectProductSalesRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(1) AS count, owner_user_id
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
@ -64,7 +64,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectCustomerCountRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(1) AS count, owner_user_id
|
||||
FROM crm_customer
|
||||
WHERE deleted = 0
|
||||
@ -78,7 +78,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectContactsCountRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(1) AS count, owner_user_id
|
||||
FROM crm_contact
|
||||
WHERE deleted = 0
|
||||
@ -92,7 +92,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectFollowCountRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(1) AS count, cc.owner_user_id
|
||||
FROM crm_follow_up_record AS cfur
|
||||
LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)
|
||||
@ -108,7 +108,7 @@
|
||||
</select>
|
||||
|
||||
<select id="selectFollowCustomerCountRank"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.CrmStatisticsRanKRespVO">
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
|
||||
SELECT COUNT(DISTINCT cc.id) AS count, cc.owner_user_id
|
||||
FROM crm_follow_up_record AS cfur
|
||||
LEFT JOIN crm_contact AS cc ON FIND_IN_SET(cc.id, cfur.contact_ids)
|
Loading…
Reference in New Issue
Block a user