CRM:完善【排行版】功能

This commit is contained in:
YunaiV 2024-03-30 11:49:06 +08:00
parent a8bec19196
commit 8266fb8f94
2 changed files with 21 additions and 26 deletions

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - CRM 排行榜统计 Response VO") @Schema(description = "管理后台 - CRM 排行榜统计 Response VO")
@Data @Data
@ -17,14 +19,15 @@ public class CrmStatisticsRankRespVO {
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private String deptName; private String deptName;
// TODO @芋艿需要改下金额是 bigdecimal
/** /**
* 数量是个特别抽象的概念在不同排行下代表不同含义 * 数量是个特别抽象的概念在不同排行下代表不同含义
* <p> *
* 1. 金额合同金额排行回款金额排行 * 1. 金额合同金额排行回款金额排行
* 2. 个数签约合同排行产品销量排行产品销量排行新增客户数排行新增联系人排行跟进次数排行跟进客户数排行 * 2. 个数签约合同排行产品销量排行产品销量排行新增客户数排行新增联系人排行跟进次数排行跟进客户数排行
*
* 为什么使用 BigDecimal 的原因
*/ */
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer count; private BigDecimal count;
} }

View File

@ -12,8 +12,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and AND order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id GROUP BY owner_user_id
</select> </select>
@ -27,8 +26,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND return_time between #{times[0],javaType=java.time.LocalDateTime} and AND return_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id GROUP BY owner_user_id
</select> </select>
@ -42,25 +40,23 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and AND order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id GROUP BY owner_user_id
</select> </select>
<!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 -->
<select id="selectProductSalesRank" <select id="selectProductSalesRank"
resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO"> resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO">
SELECT COUNT(1) AS count, owner_user_id SELECT COUNT(product.count) AS count, contract.owner_user_id
FROM crm_contract FROM crm_contract_product product
WHERE deleted = 0 INNER JOIN crm_contract contract ON product.contract_id = contract.id
AND audit_status = 20 WHERE contract.deleted = 0 AND contract.deleted = 0
AND owner_user_id in AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status}
AND contract.owner_user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND order_date between #{times[0],javaType=java.time.LocalDateTime} and AND contract.order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime} GROUP BY contract.owner_user_id
GROUP BY owner_user_id
</select> </select>
<select id="selectCustomerCountRank" <select id="selectCustomerCountRank"
@ -72,8 +68,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND create_time between #{times[0],javaType=java.time.LocalDateTime} and AND create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id GROUP BY owner_user_id
</select> </select>
@ -86,8 +81,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND create_time between #{times[0],javaType=java.time.LocalDateTime} and AND create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY owner_user_id GROUP BY owner_user_id
</select> </select>
@ -102,8 +96,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY cc.owner_user_id GROUP BY cc.owner_user_id
</select> </select>
@ -118,8 +111,7 @@
<foreach collection="userIds" item="userId" open="(" close=")" separator=","> <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId} #{userId}
</foreach> </foreach>
AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime}
#{times[1],javaType=java.time.LocalDateTime}
GROUP BY cc.owner_user_id GROUP BY cc.owner_user_id
</select> </select>