From 1906557491b513a93c8e0ff6c0065896c088be53 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 May 2024 09:54:39 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A7=BB=E9=99=A4=E3=80=91CRM=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CrmStatisticsFunnelController.java | 74 --------- ...atisticsCustomerDealCycleByAreaRespVO.java | 24 --- ...sticsCustomerDealCycleByProductRespVO.java | 19 --- .../CrmStatisticFunnelSummaryRespVO.java | 23 --- ...inessInversionRateSummaryByDateRespVO.java | 21 --- ...StatisticsBusinessSummaryByDateRespVO.java | 21 --- ...sticsBusinessSummaryByEndStatusRespVO.java | 25 --- .../vo/funnel/CrmStatisticsFunnelReqVO.java | 47 ------ .../statistics/CrmStatisticsFunnelMapper.java | 30 ---- .../CrmStatisticsFunnelService.java | 56 ------- .../CrmStatisticsFunnelServiceImpl.java | 154 ------------------ .../statistics/CrmStatisticsFunnelMapper.xml | 87 ---------- 12 files changed, 581 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java deleted file mode 100644 index 17451e768..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/CrmStatisticsFunnelController.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics; - -import cn.hutool.extra.spring.SpringUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.CrmBusinessController; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.service.statistics.CrmStatisticsFunnelService; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -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 javax.annotation.Resource; -import javax.validation.Valid; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - -@Tag(name = "管理后台 - CRM 销售漏斗") -@RestController -@RequestMapping("/crm/statistics-funnel") -@Validated -public class CrmStatisticsFunnelController { - - @Resource - private CrmStatisticsFunnelService funnelService; - - @GetMapping("/get-funnel-summary") - @Operation(summary = "获取销售漏斗统计数据", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult getFunnelSummary(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getFunnelSummary(reqVO)); - } - - @GetMapping("/get-business-summary-by-end-status") - @Operation(summary = "获取商机结束状态统计", description = "用于【销售漏斗】页面的【销售漏斗分析】") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByEndStatus(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByEndStatus(reqVO)); - } - - @GetMapping("/get-business-summary-by-date") - @Operation(summary = "获取新增商机分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-inversion-rate-summary-by-date") - @Operation(summary = "获取商机转化率分析(按日期)", description = "用于【销售漏斗】页面") - @PreAuthorize("@ss.hasPermission('crm:statistics-funnel:query')") - public CommonResult> getBusinessInversionRateSummaryByDate(@Valid CrmStatisticsFunnelReqVO reqVO) { - return success(funnelService.getBusinessInversionRateSummaryByDate(reqVO)); - } - - @GetMapping("/get-business-page-by-date") - @Operation(summary = "获得商机分页(按日期)", description = "用于【销售漏斗】页面的【新增商机分析】") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessPageByDate(@Valid CrmStatisticsFunnelReqVO pageVO) { - PageResult pageResult = funnelService.getBusinessPageByDate(pageVO); - return success(new PageResult<>(buildBusinessDetailList(pageResult.getList()), pageResult.getTotal())); - } - - private List buildBusinessDetailList(List list) { - return SpringUtil.getBean(CrmBusinessController.class).buildBusinessDetailList(list); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java deleted file mode 100644 index 369837827..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByAreaRespVO.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - CRM 客户成交周期分析(按区域) VO") -@Data -public class CrmStatisticsCustomerDealCycleByAreaRespVO { - - @Schema(description = "省份编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @JsonIgnore - private Integer areaId; - - @Schema(description = "省份名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "浙江省") - private String areaName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java deleted file mode 100644 index 442c195aa..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/customer/CrmStatisticsCustomerDealCycleByProductRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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 CrmStatisticsCustomerDealCycleByProductRespVO { - - @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "演示产品") - private String productName; - - @Schema(description = "成交周期", requiredMode = Schema.RequiredMode.REQUIRED, example = "1.0") - private Double customerDealCycle; - - @Schema(description = "成交客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer customerDealCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java deleted file mode 100644 index 38d1c118f..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticFunnelSummaryRespVO.java +++ /dev/null @@ -1,23 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - CRM 销售漏斗 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticFunnelSummaryRespVO { - - @Schema(description = "客户数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long customerCount; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java deleted file mode 100644 index b7650a91d..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessInversionRateSummaryByDateRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 商机转化率分析(按日期) VO") -@Data -public class CrmStatisticsBusinessInversionRateSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "赢单商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessWinCount; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java deleted file mode 100644 index 1f8056c46..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByDateRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 新增商机分析(按日期) VO") -@Data -public class CrmStatisticsBusinessSummaryByDateRespVO { - - @Schema(description = "时间轴", requiredMode = Schema.RequiredMode.REQUIRED, example = "202401") - private String time; - - @Schema(description = "新增商机数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCreateCount; - - @Schema(description = "新增商机金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java deleted file mode 100644 index 023fdb846..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsBusinessSummaryByEndStatusRespVO.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.math.BigDecimal; - -@Schema(description = "管理后台 - CRM 商机结束状态统计 Response VO") -@NoArgsConstructor -@AllArgsConstructor -@Data -public class CrmStatisticsBusinessSummaryByEndStatusRespVO { - - @Schema(description = "结束状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer endStatus; - - @Schema(description = "商机数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long businessCount; - - @Schema(description = "商机总金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private BigDecimal totalPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java deleted file mode 100644 index 85ba52e17..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/funnel/CrmStatisticsFunnelReqVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel; - -import cn.iocoder.yudao.framework.common.enums.DateIntervalEnum; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -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 CrmStatisticsFunnelReqVO extends PageParam { - - @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 读取编号后,设置回来 - * 后续,可能会支持选择部分用户进行查询 - */ - @Schema(description = "负责人用户 id 集合", hidden = true, example = "2") - private List userIds; - - @Schema(description = "时间间隔类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @InEnum(value = DateIntervalEnum.class, message = "时间间隔类型,必须是 {value}") - private Integer interval; - - @Schema(description = "时间范围", requiredMode = Schema.RequiredMode.NOT_REQUIRED) - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - @Size(min = 2, max = 2, message = "请选择时间范围") - private LocalDateTime[] times; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java deleted file mode 100644 index d69fa6290..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/statistics/CrmStatisticsFunnelMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.statistics; - -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessInversionRateSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByDateRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsBusinessSummaryByEndStatusRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.CrmStatisticsFunnelReqVO; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * CRM 销售漏斗 Mapper - * - * @author HUIHUI - */ -@Mapper -public interface CrmStatisticsFunnelMapper { - - Long selectCustomerCountByDate(CrmStatisticsFunnelReqVO reqVO); - - Long selectBusinessCountByDateAndEndStatus(@Param("reqVO") CrmStatisticsFunnelReqVO reqVO, @Param("status") Integer status); - - List selectBusinessSummaryListGroupByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessSummaryGroupByDate(CrmStatisticsFunnelReqVO reqVO); - - List selectBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java deleted file mode 100644 index 10458daac..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelService.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; - -import java.util.List; - -/** - * CRM 销售漏斗分析 Service - * - * @author HUIHUI - */ -public interface CrmStatisticsFunnelService { - - /** - * 获得销售漏斗数据 - * - * @param reqVO 请求 - * @return 销售漏斗数据 - */ - CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机结束状态统计 - * - * @param reqVO 请求 - * @return 商机结束状态统计 - */ - List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获取新增商机分析(按日期) - * - * @param reqVO 请求 - * @return 新增商机分析 - */ - List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机转化率分析(按日期) - * - * @param reqVO 请求 - * @return 商机转化率分析 - */ - List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO); - - /** - * 获得商机分页(按日期) - * - * @param pageVO 请求 - * @return 商机分页 - */ - PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java deleted file mode 100644 index fa1281741..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/statistics/CrmStatisticsFunnelServiceImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.statistics; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; -import cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.funnel.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.mysql.statistics.CrmStatisticsFunnelMapper; -import cn.iocoder.yudao.module.crm.enums.business.CrmBusinessEndStatusEnum; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -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; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; - -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; - -/** - * CRM 销售漏斗分析 Service 实现类 - * - * @author HUIHUI - */ -@Service -public class CrmStatisticsFunnelServiceImpl implements CrmStatisticsFunnelService { - - @Resource - private CrmStatisticsFunnelMapper funnelMapper; - - @Resource - private AdminUserApi adminUserApi; - @Resource - private CrmBusinessService businessService; - @Resource - private DeptApi deptApi; - - @Override - public CrmStatisticFunnelSummaryRespVO getFunnelSummary(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - List userIds = getUserIds(reqVO); - if (CollUtil.isEmpty(userIds)) { - return null; - } - reqVO.setUserIds(userIds); - - // 2. 获得漏斗数据 - Long customerCount = funnelMapper.selectCustomerCountByDate(reqVO); - Long businessCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, null); - Long businessWinCount = funnelMapper.selectBusinessCountByDateAndEndStatus(reqVO, CrmBusinessEndStatusEnum.WIN.getStatus()); - return new CrmStatisticFunnelSummaryRespVO(customerCount, businessCount, businessWinCount); - } - - @Override - public List getBusinessSummaryByEndStatus(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 获得统计数据 - return funnelMapper.selectBusinessSummaryListGroupByEndStatus(reqVO); - } - - @Override - public List getBusinessSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessSummaryGroupByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCreateCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessSummaryByDateRespVO::getBusinessCreateCount).sum(); - BigDecimal businessDealCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .map(CrmStatisticsBusinessSummaryByDateRespVO::getTotalPrice) - .reduce(BigDecimal.ZERO, BigDecimal::add); - return new CrmStatisticsBusinessSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCreateCount(businessCreateCount).setTotalPrice(businessDealCount); - }); - } - - @Override - public List getBusinessInversionRateSummaryByDate(CrmStatisticsFunnelReqVO reqVO) { - // 1. 获得用户编号数组 - reqVO.setUserIds(getUserIds(reqVO)); - if (CollUtil.isEmpty(reqVO.getUserIds())) { - return Collections.emptyList(); - } - - // 2. 按天统计,获取分项统计数据 - List businessSummaryList = funnelMapper.selectBusinessInversionRateSummaryByDate(reqVO); - // 3. 按照日期间隔,合并数据 - List timeRanges = LocalDateTimeUtils.getDateRangeList(reqVO.getTimes()[0], reqVO.getTimes()[1], reqVO.getInterval()); - return convertList(timeRanges, times -> { - Long businessCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessCount).sum(); - Long businessWinCount = businessSummaryList.stream() - .filter(vo -> LocalDateTimeUtils.isBetween(times[0], times[1], vo.getTime())) - .mapToLong(CrmStatisticsBusinessInversionRateSummaryByDateRespVO::getBusinessWinCount).sum(); - return new CrmStatisticsBusinessInversionRateSummaryByDateRespVO() - .setTime(LocalDateTimeUtils.formatDateRange(times[0], times[1], reqVO.getInterval())) - .setBusinessCount(businessCount).setBusinessWinCount(businessWinCount); - }); - } - - @Override - public PageResult getBusinessPageByDate(CrmStatisticsFunnelReqVO pageVO) { - // 1. 获得用户编号数组 - pageVO.setUserIds(getUserIds(pageVO)); - if (CollUtil.isEmpty(pageVO.getUserIds())) { - return PageResult.empty(); - } - // 2. 执行查询 - return businessService.getBusinessPageByDate(pageVO); - } - - /** - * 获取用户编号数组。如果用户编号为空, 则获得部门下的用户编号数组,包括子部门的所有用户编号 - * - * @param reqVO 请求参数 - * @return 用户编号数组 - */ - private List getUserIds(CrmStatisticsFunnelReqVO reqVO) { - // 情况一:选中某个用户 - if (ObjUtil.isNotNull(reqVO.getUserId())) { - return ListUtil.of(reqVO.getUserId()); - } - // 情况二:选中某个部门 - // 2.1 获得部门列表 - List deptIds = convertList(deptApi.getChildDeptList(reqVO.getDeptId()), DeptRespDTO::getId); - deptIds.add(reqVO.getDeptId()); - // 2.2 获得用户编号 - return convertList(adminUserApi.getUserListByDeptIds(deptIds), AdminUserRespDTO::getId); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml deleted file mode 100644 index a07406259..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsFunnelMapper.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - - - - - - - -