Commit 8266fb8f94f4679e37fdaf3444486aa6d14ca922
1 parent
a8bec191
CRM:完善【排行版】功能
Showing
2 changed files
with
21 additions
and
26 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/statistics/vo/rank/CrmStatisticsRankRespVO.java
| @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | +import java.math.BigDecimal; | ||
| 7 | + | ||
| 6 | 8 | ||
| 7 | @Schema(description = "管理后台 - CRM 排行榜统计 Response VO") | 9 | @Schema(description = "管理后台 - CRM 排行榜统计 Response VO") |
| 8 | @Data | 10 | @Data |
| @@ -17,14 +19,15 @@ public class CrmStatisticsRankRespVO { | @@ -17,14 +19,15 @@ public class CrmStatisticsRankRespVO { | ||
| 17 | @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 19 | @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 18 | private String deptName; | 20 | private String deptName; |
| 19 | 21 | ||
| 20 | - // TODO @芋艿:需要改下,金额是 bigdecimal | ||
| 21 | /** | 22 | /** |
| 22 | * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 | 23 | * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 |
| 23 | - * <p> | 24 | + * |
| 24 | * 1. 金额:合同金额排行、回款金额排行 | 25 | * 1. 金额:合同金额排行、回款金额排行 |
| 25 | * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 | 26 | * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 |
| 27 | + * | ||
| 28 | + * 为什么使用 BigDecimal 的原因: | ||
| 26 | */ | 29 | */ |
| 27 | @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | 30 | @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 28 | - private Integer count; | 31 | + private BigDecimal count; |
| 29 | 32 | ||
| 30 | } | 33 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/statistics/CrmStatisticsRankMapper.xml
| @@ -12,8 +12,7 @@ | @@ -12,8 +12,7 @@ | ||
| 12 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 12 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 13 | #{userId} | 13 | #{userId} |
| 14 | </foreach> | 14 | </foreach> |
| 15 | - AND order_date between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 16 | - #{times[1],javaType=java.time.LocalDateTime} | 15 | + AND order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 17 | GROUP BY owner_user_id | 16 | GROUP BY owner_user_id |
| 18 | </select> | 17 | </select> |
| 19 | 18 | ||
| @@ -27,8 +26,7 @@ | @@ -27,8 +26,7 @@ | ||
| 27 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 26 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 28 | #{userId} | 27 | #{userId} |
| 29 | </foreach> | 28 | </foreach> |
| 30 | - AND return_time between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 31 | - #{times[1],javaType=java.time.LocalDateTime} | 29 | + AND return_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 32 | GROUP BY owner_user_id | 30 | GROUP BY owner_user_id |
| 33 | </select> | 31 | </select> |
| 34 | 32 | ||
| @@ -42,25 +40,23 @@ | @@ -42,25 +40,23 @@ | ||
| 42 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 40 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 43 | #{userId} | 41 | #{userId} |
| 44 | </foreach> | 42 | </foreach> |
| 45 | - AND order_date between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 46 | - #{times[1],javaType=java.time.LocalDateTime} | 43 | + AND order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 47 | GROUP BY owner_user_id | 44 | GROUP BY owner_user_id |
| 48 | </select> | 45 | </select> |
| 49 | 46 | ||
| 50 | - <!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 --> | ||
| 51 | <select id="selectProductSalesRank" | 47 | <select id="selectProductSalesRank" |
| 52 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO"> | 48 | resultType="cn.iocoder.yudao.module.crm.controller.admin.statistics.vo.rank.CrmStatisticsRankRespVO"> |
| 53 | - SELECT COUNT(1) AS count, owner_user_id | ||
| 54 | - FROM crm_contract | ||
| 55 | - WHERE deleted = 0 | ||
| 56 | - AND audit_status = 20 | ||
| 57 | - AND owner_user_id in | 49 | + SELECT COUNT(product.count) AS count, contract.owner_user_id |
| 50 | + FROM crm_contract_product product | ||
| 51 | + INNER JOIN crm_contract contract ON product.contract_id = contract.id | ||
| 52 | + WHERE contract.deleted = 0 AND contract.deleted = 0 | ||
| 53 | + AND contract.audit_status = ${@cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum@APPROVE.status} | ||
| 54 | + AND contract.owner_user_id in | ||
| 58 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 55 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 59 | #{userId} | 56 | #{userId} |
| 60 | </foreach> | 57 | </foreach> |
| 61 | - AND order_date between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 62 | - #{times[1],javaType=java.time.LocalDateTime} | ||
| 63 | - GROUP BY owner_user_id | 58 | + AND contract.order_date between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 59 | + GROUP BY contract.owner_user_id | ||
| 64 | </select> | 60 | </select> |
| 65 | 61 | ||
| 66 | <select id="selectCustomerCountRank" | 62 | <select id="selectCustomerCountRank" |
| @@ -72,8 +68,7 @@ | @@ -72,8 +68,7 @@ | ||
| 72 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 68 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 73 | #{userId} | 69 | #{userId} |
| 74 | </foreach> | 70 | </foreach> |
| 75 | - AND create_time between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 76 | - #{times[1],javaType=java.time.LocalDateTime} | 71 | + AND create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 77 | GROUP BY owner_user_id | 72 | GROUP BY owner_user_id |
| 78 | </select> | 73 | </select> |
| 79 | 74 | ||
| @@ -86,8 +81,7 @@ | @@ -86,8 +81,7 @@ | ||
| 86 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 81 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 87 | #{userId} | 82 | #{userId} |
| 88 | </foreach> | 83 | </foreach> |
| 89 | - AND create_time between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 90 | - #{times[1],javaType=java.time.LocalDateTime} | 84 | + AND create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 91 | GROUP BY owner_user_id | 85 | GROUP BY owner_user_id |
| 92 | </select> | 86 | </select> |
| 93 | 87 | ||
| @@ -102,8 +96,7 @@ | @@ -102,8 +96,7 @@ | ||
| 102 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 96 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 103 | #{userId} | 97 | #{userId} |
| 104 | </foreach> | 98 | </foreach> |
| 105 | - AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 106 | - #{times[1],javaType=java.time.LocalDateTime} | 99 | + AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 107 | GROUP BY cc.owner_user_id | 100 | GROUP BY cc.owner_user_id |
| 108 | </select> | 101 | </select> |
| 109 | 102 | ||
| @@ -118,8 +111,7 @@ | @@ -118,8 +111,7 @@ | ||
| 118 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> | 111 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 119 | #{userId} | 112 | #{userId} |
| 120 | </foreach> | 113 | </foreach> |
| 121 | - AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and | ||
| 122 | - #{times[1],javaType=java.time.LocalDateTime} | 114 | + AND cfur.create_time between #{times[0],javaType=java.time.LocalDateTime} and #{times[1],javaType=java.time.LocalDateTime} |
| 123 | GROUP BY cc.owner_user_id | 115 | GROUP BY cc.owner_user_id |
| 124 | </select> | 116 | </select> |
| 125 | 117 |