mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
CRM:code review【客户统计】的代码实现
This commit is contained in:
parent
90f82b157d
commit
a8bec19196
@ -61,8 +61,10 @@ public class CrmStatisticsCustomerController {
|
||||
return success(customerService.getFollowUpSummaryByType(reqVO));
|
||||
}
|
||||
|
||||
// TODO @dhb52:【客户转化率】里,应该少了一个接口,给上面图标的;
|
||||
|
||||
@GetMapping("/get-contract-summary")
|
||||
@Operation(summary = "获取合同摘要信息(客户转化率页面)")
|
||||
@Operation(summary = "获取客户的首次合同、回款信息列表", description = "用于【客户转化率】页面")
|
||||
@PreAuthorize("@ss.hasPermission('crm:statistics-customer:query')")
|
||||
public CommonResult<List<CrmStatisticsCustomerContractSummaryRespVO>> getContractSummary(@Valid CrmStatisticsCustomerReqVO reqVO) {
|
||||
return success(customerService.getContractSummary(reqVO));
|
||||
@ -82,4 +84,6 @@ public class CrmStatisticsCustomerController {
|
||||
return success(customerService.getCustomerDealCycleByUser(reqVO));
|
||||
}
|
||||
|
||||
// TODO dhb52:【成交周期分析】里,有按照员工(已实现)、地区(未实现)、产品(未实现),需要在看看哈;可以把 CustomerDealCycle 拆成 3 个 tab,员工客户成交周期分析、地区客户成交周期分析、产品客户成交周期分析;
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,6 @@ public interface CrmStatisticsCustomerMapper {
|
||||
|
||||
List<CrmStatisticsCustomerDealCycleByDateRespVO> selectCustomerDealCycleGroupByDate(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
List<CrmStatisticsCustomerDealCycleByUserRespVO> selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO); // TODO
|
||||
List<CrmStatisticsCustomerDealCycleByUserRespVO> selectCustomerDealCycleGroupByUser(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
}
|
||||
|
@ -52,16 +52,18 @@ public interface CrmStatisticsCustomerService {
|
||||
List<CrmStatisticsFollowUpSummaryByTypeRespVO> getFollowUpSummaryByType(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 获取合同摘要信息(客户转化率页面)
|
||||
* 获取客户的首次合同、回款信息列表,用于【客户转化率】页面
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 合同摘要列表
|
||||
* @return 客户的首次合同、回款信息列表
|
||||
*/
|
||||
List<CrmStatisticsCustomerContractSummaryRespVO> getContractSummary(CrmStatisticsCustomerReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 客户成交周期(按日期)
|
||||
*
|
||||
* 成交的定义:客户 customer 在创建出来,到合同 contract 第一次成交的时间差
|
||||
*
|
||||
* @param reqVO 请求参数
|
||||
* @return 统计数据
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@
|
||||
COUNT( DISTINCT customer_id ) AS customerDealCount
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
@ -56,7 +56,7 @@
|
||||
FROM crm_customer AS customer
|
||||
LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id
|
||||
WHERE customer.deleted = 0 AND contract.deleted = 0
|
||||
AND contract.audit_status = 20
|
||||
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND customer.owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
@ -72,7 +72,7 @@
|
||||
IFNULL(SUM(total_price), 0) AS contract_price
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
@ -88,7 +88,7 @@
|
||||
IFNULL(SUM(price), 0) AS receivable_price
|
||||
FROM crm_receivable
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
@ -175,28 +175,24 @@
|
||||
<select id="selectContractSummary"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerContractSummaryRespVO">
|
||||
SELECT
|
||||
customer.name AS customer_name,
|
||||
contract.name AS contract_name,
|
||||
contract.total_price,
|
||||
IFNULL( receivable.price, 0 ) AS receivable_price,
|
||||
customer.industry_id,
|
||||
customer.source,
|
||||
customer.owner_user_id,
|
||||
customer.creator,
|
||||
customer.name AS customer_name, customer.industry_id, customer.source, customer.owner_user_id, customer.creator,
|
||||
customer.create_time,
|
||||
contract.order_date
|
||||
contract.name AS contract_name, contract.total_price, contract.order_date,
|
||||
IFNULL( receivable.price, 0 ) AS receivable_price
|
||||
FROM crm_customer AS customer
|
||||
INNER JOIN crm_contract AS contract ON customer.id = contract.customer_id
|
||||
LEFT JOIN crm_receivable AS receivable ON contract.id = receivable.contract_id
|
||||
WHERE customer.deleted = 0 AND contract.deleted = 0 AND receivable.deleted = 0
|
||||
AND contract.audit_status = 20
|
||||
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND customer.owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<!-- TODO @dhb52:应该是客户的创建时间;因为它的定位,是知道这个时间范围内创建的客户,是否下合同了(转化); -->
|
||||
AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime}
|
||||
</select>
|
||||
|
||||
<!-- TIMESTAMPDIFF 用于求差值;AVG 求平均;TRUNCATE 去掉小数点、只保留整数 -->
|
||||
<select id="selectCustomerDealCycleGroupByDate"
|
||||
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.customer.CrmStatisticsCustomerDealCycleByDateRespVO">
|
||||
SELECT
|
||||
@ -205,11 +201,12 @@
|
||||
FROM crm_customer AS customer
|
||||
LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id
|
||||
WHERE customer.deleted = 0 AND contract.deleted = 0
|
||||
AND contract.audit_status = 20
|
||||
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND customer.owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<!-- TODO @dhb52:应该是客户的创建时间; -->
|
||||
AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY time
|
||||
</select>
|
||||
@ -222,11 +219,12 @@
|
||||
FROM crm_customer AS customer
|
||||
LEFT JOIN crm_contract AS contract ON contract.customer_id = customer.id
|
||||
WHERE customer.deleted = 0 AND contract.deleted = 0
|
||||
AND contract.audit_status = 20
|
||||
AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND customer.owner_user_id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<!-- TODO @dhb52:应该是客户的创建时间; -->
|
||||
AND contract.create_time BETWEEN #{times[0],javaType=java.time.LocalDateTime} AND #{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY customer.owner_user_id
|
||||
</select>
|
||||
|
@ -7,11 +7,11 @@
|
||||
SELECT IFNULL(SUM(total_price), 0) AS count, owner_user_id
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
and owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY owner_user_id
|
||||
@ -22,11 +22,11 @@
|
||||
SELECT IFNULL(SUM(price), 0) AS count, owner_user_id
|
||||
FROM crm_receivable
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND return_time between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY owner_user_id
|
||||
@ -37,11 +37,11 @@
|
||||
SELECT COUNT(1) AS count, owner_user_id
|
||||
FROM crm_contract
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY owner_user_id
|
||||
@ -55,9 +55,9 @@
|
||||
WHERE deleted = 0
|
||||
AND audit_status = 20
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY owner_user_id
|
||||
@ -69,9 +69,9 @@
|
||||
FROM crm_customer
|
||||
WHERE deleted = 0
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<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 owner_user_id
|
||||
@ -83,9 +83,9 @@
|
||||
FROM crm_contact
|
||||
WHERE deleted = 0
|
||||
AND owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<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 owner_user_id
|
||||
@ -99,9 +99,9 @@
|
||||
WHERE cfur.deleted = 0
|
||||
AND cc.deleted = 0
|
||||
AND cc.owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY cc.owner_user_id
|
||||
@ -115,9 +115,9 @@
|
||||
WHERE cfur.deleted = 0
|
||||
AND cc.deleted = 0
|
||||
AND cc.owner_user_id in
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
|
||||
#{userId}
|
||||
</foreach>
|
||||
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and
|
||||
#{times[1],javaType=java.time.LocalDateTime}
|
||||
GROUP BY cc.owner_user_id
|
||||
|
Loading…
Reference in New Issue
Block a user