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 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import java.math.BigDecimal; | |
| 7 | + | |
| 6 | 8 | |
| 7 | 9 | @Schema(description = "管理后台 - CRM 排行榜统计 Response VO") |
| 8 | 10 | @Data |
| ... | ... | @@ -17,14 +19,15 @@ public class CrmStatisticsRankRespVO { |
| 17 | 19 | @Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 18 | 20 | private String deptName; |
| 19 | 21 | |
| 20 | - // TODO @芋艿:需要改下,金额是 bigdecimal | |
| 21 | 22 | /** |
| 22 | 23 | * 数量是个特别“抽象”的概念,在不同排行下,代表不同含义 |
| 23 | - * <p> | |
| 24 | + * | |
| 24 | 25 | * 1. 金额:合同金额排行、回款金额排行 |
| 25 | 26 | * 2. 个数:签约合同排行、产品销量排行、产品销量排行、新增客户数排行、新增联系人排行、跟进次数排行、跟进客户数排行 |
| 27 | + * | |
| 28 | + * 为什么使用 BigDecimal 的原因: | |
| 26 | 29 | */ |
| 27 | 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 | 12 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 13 | 13 | #{userId} |
| 14 | 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 | 16 | GROUP BY owner_user_id |
| 18 | 17 | </select> |
| 19 | 18 | |
| ... | ... | @@ -27,8 +26,7 @@ |
| 27 | 26 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 28 | 27 | #{userId} |
| 29 | 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 | 30 | GROUP BY owner_user_id |
| 33 | 31 | </select> |
| 34 | 32 | |
| ... | ... | @@ -42,25 +40,23 @@ |
| 42 | 40 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 43 | 41 | #{userId} |
| 44 | 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 | 44 | GROUP BY owner_user_id |
| 48 | 45 | </select> |
| 49 | 46 | |
| 50 | - <!-- TODO 待定 这里是否需要关联 crm_contract_product 表,计算销售额 --> | |
| 51 | 47 | <select id="selectProductSalesRank" |
| 52 | 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 | 55 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 59 | 56 | #{userId} |
| 60 | 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 | 60 | </select> |
| 65 | 61 | |
| 66 | 62 | <select id="selectCustomerCountRank" |
| ... | ... | @@ -72,8 +68,7 @@ |
| 72 | 68 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 73 | 69 | #{userId} |
| 74 | 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 | 72 | GROUP BY owner_user_id |
| 78 | 73 | </select> |
| 79 | 74 | |
| ... | ... | @@ -86,8 +81,7 @@ |
| 86 | 81 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 87 | 82 | #{userId} |
| 88 | 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 | 85 | GROUP BY owner_user_id |
| 92 | 86 | </select> |
| 93 | 87 | |
| ... | ... | @@ -102,8 +96,7 @@ |
| 102 | 96 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 103 | 97 | #{userId} |
| 104 | 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 | 100 | GROUP BY cc.owner_user_id |
| 108 | 101 | </select> |
| 109 | 102 | |
| ... | ... | @@ -118,8 +111,7 @@ |
| 118 | 111 | <foreach collection="userIds" item="userId" open="(" close=")" separator=","> |
| 119 | 112 | #{userId} |
| 120 | 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 | 115 | GROUP BY cc.owner_user_id |
| 124 | 116 | </select> |
| 125 | 117 | ... | ... |