Commit 91ffafeb26d0288fd16e5a213be682e521076ae7

Authored by 张志伟
2 parents 038db1f7 d78ae2c0

Merge remote-tracking branch 'origin/test'

Showing 39 changed files with 969 additions and 248 deletions
.gitignore
... ... @@ -23,6 +23,7 @@ target
23 23 *.log
24 24 /bin/
25 25 /*-logs/
  26 +**/.vscode/**
26 27 **/banner.txt
27 28 *LOG_PATH_IS_UNDEFINED
28 29 *dynamic.log.path_IS_UNDEFINED
... ...
doc/v1.1.1/database.sql 0 → 100644
  1 +
  2 +alter table stammkunde_pool
  3 + add reason int(3) null comment '战败原因' after reject_time;
  4 +
  5 +alter table stammkunde_pool
  6 + add new_user_id bigint null comment '新的顾问id(战败only)' after group_id;
  7 +
  8 +alter table stammkunde_pool
  9 + add new_user_name varchar(64) null comment '新的顾问名称' after new_user_id;
  10 +
  11 +alter table stammkunde_pool
  12 + add new_shop_id bigint null comment '新的门店id(战败only)' after new_user_name;
  13 +
  14 +alter table stammkunde_pool
  15 + add new_shop_name varchar(64) null comment '新的门店名称' after new_shop_id;
  16 +
  17 +alter table customer_retention_ratio
  18 + add type int(3) null comment '战败类型';
  19 +
  20 +create index stammkunde_pool_activation_time_index
  21 + on stammkunde_pool (activation_time);
  22 +
  23 +create index stammkunde_pool_new_shop_id_index
  24 + on stammkunde_pool (new_shop_id);
  25 +
  26 +create index stammkunde_pool_new_user_id_index
  27 + on stammkunde_pool (new_user_id);
  28 +
  29 +create index stammkunde_pool_reason_index
  30 + on stammkunde_pool (reason);
  31 +
... ...
fw-valhalla-dao/src/main/java/cn/fw/valhalla/dao/mapper/CustomerCluePoolMapper.java
... ... @@ -47,4 +47,11 @@ public interface CustomerCluePoolMapper extends BaseMapper<CustomerCluePool> {
47 47 * @return
48 48 */
49 49 Long defeatNum(@Param("condition") CustomerCluePoolQueryVO queryVO);
  50 +
  51 + /**
  52 + * 进行中的数量
  53 + * @param queryVO
  54 + * @return
  55 + */
  56 + Long onGoingNum(@Param("condition") CustomerCluePoolQueryVO queryVO);
50 57 }
... ...
fw-valhalla-dao/src/main/resources/mapper/CustomerCluePoolMapper.xml
... ... @@ -9,6 +9,10 @@
9 9 SELECT t2.id customer_id,
10 10 ifnull(t2.plate_no, t3.plate_no) plate_no,
11 11 t1.clue_type type,
  12 + t1.frame_no frame_no,
  13 + t2.buy_date buy_date,
  14 + t2.arrival_time arrival_time,
  15 + t2.insurance_expires insurance_expires,
12 16 t1.add_time add_time,
13 17 t1.start_time create_date,
14 18 t1.deadline deadline,
... ... @@ -22,10 +26,12 @@
22 26 t1.finish_user_id finish_user_id,
23 27 t1.finish_user_name finish_user,
24 28 t1.finish_shop_id finish_shop_id,
25   - t1.finish_shop_name finish_shop
  29 + t1.finish_shop_name finish_shop,
  30 + t4.expires loan_expires
26 31 FROM customer_clue_pool t1
27 32 left join customer t2 on t1.referer_id = t2.id
28 33 left join accident_pool t3 on t1.referer_id = t3.id
  34 + left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
29 35 <where>
30 36 t1.clue_status != 1
31 37 <if test="condition.type !=null">
... ... @@ -34,6 +40,9 @@
34 40 <if test="condition.groupId !=null">
35 41 and t1.group_id = #{condition.groupId}
36 42 </if>
  43 + <if test="condition.frameNo !=null and condition.frameNo != ''">
  44 + and t1.frame_no like concat('%', #{condition.frameNo}, '%')
  45 + </if>
37 46 <if test="condition.userName !=null and condition.userName != ''">
38 47 and (t1.finish_user_name like concat('%', #{condition.userName}, '%') or t1.original_user_name like concat('%', #{condition.userName}, '%'))
39 48 </if>
... ... @@ -46,6 +55,12 @@
46 55 <if test="condition.startTime !=null">
47 56 and DATE_FORMAT(t1.start_time, '%Y-%m') = DATE_FORMAT(#{condition.startTime}, '%Y-%m')
48 57 </if>
  58 + <if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
  59 + and t4.expires > now()
  60 + </if>
  61 + <if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
  62 + and t4.expires &lt;= now()
  63 + </if>
49 64 <if test="condition.shopIds !=null">
50 65 and t1.original_shop_id in
51 66 <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
... ... @@ -95,6 +110,7 @@
95 110 FROM customer_clue_pool t1
96 111 left join customer t2 on t1.referer_id = t2.id
97 112 left join accident_pool t3 on t1.referer_id = t3.id
  113 + left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
98 114 <where>
99 115 t1.clue_status != 1
100 116 <if test="condition.type !=null">
... ... @@ -103,6 +119,9 @@
103 119 <if test="condition.groupId !=null">
104 120 and t1.group_id = #{condition.groupId}
105 121 </if>
  122 + <if test="condition.frameNo !=null and condition.frameNo != ''">
  123 + and t1.frame_no like concat('%', #{condition.frameNo}, '%')
  124 + </if>
106 125 <if test="condition.userName !=null and condition.userName != ''">
107 126 and (t1.finish_user_name like concat('%', #{condition.userName}, '%') or t1.original_user_name like concat('%', #{condition.userName}, '%'))
108 127 </if>
... ... @@ -115,6 +134,12 @@
115 134 <if test="condition.startTime !=null">
116 135 and DATE_FORMAT(t1.start_time, '%Y-%m') = DATE_FORMAT(#{condition.startTime}, '%Y-%m')
117 136 </if>
  137 + <if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
  138 + and t4.expires > now()
  139 + </if>
  140 + <if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
  141 + and t4.expires &lt;= now()
  142 + </if>
118 143 <if test="condition.comShops !=null">
119 144 and t1.finish_shop_id in
120 145 <foreach collection="condition.comShops" item="id" index="index" open="(" close=")" separator=",">
... ... @@ -217,4 +242,31 @@
217 242 </if>
218 243 </where>
219 244 </select>
  245 +
  246 + <select
  247 + id="onGoingNum"
  248 + resultType="java.lang.Long"
  249 + >
  250 + SELECT
  251 + count(t1.id)
  252 + FROM customer_clue_pool t1
  253 + left join customer t2 on t1.referer_id = t2.id
  254 + left join accident_pool t3 on t1.referer_id = t3.id
  255 + <where>
  256 + t1.clue_status = 2
  257 + and t1.original_shop_id in
  258 + <foreach collection="condition.scope" item="id" index="index" open="(" close=")" separator=",">
  259 + #{id}
  260 + </foreach>
  261 + <if test="condition.type !=null">
  262 + and t1.clue_type = #{condition.type}
  263 + </if>
  264 + <if test="condition.groupId !=null">
  265 + and t1.group_id = #{condition.groupId}
  266 + </if>
  267 + <if test="condition.startTime !=null">
  268 + and DATE_FORMAT(t1.start_time, '%Y-%m') = DATE_FORMAT(#{condition.startTime}, '%Y-%m')
  269 + </if>
  270 + </where>
  271 + </select>
220 272 </mapper>
... ...
fw-valhalla-dao/src/main/resources/mapper/StammkundePoolMapper.xml
... ... @@ -16,6 +16,11 @@
16 16 t1.sources sources,
17 17 t1.reject_time defeat_time,
18 18 t1.pool_status pool_status,
  19 + t1.reason reason,
  20 + t1.new_user_id new_user_id,
  21 + t1.new_user_name new_user_name,
  22 + t1.new_shop_id new_shop_id,
  23 + t1.new_shop_name new_shop_name,
19 24 t3.name customer_name,
20 25 t3.address address,
21 26 t2.cus_level customer_level,
... ... @@ -58,8 +63,14 @@
58 63 #{id}
59 64 </foreach>
60 65 </if>
61   - <if test="condition.startTime !=null">
62   - and t1.activation_time &lt;= #{condition.startTime}
  66 + <if test="condition.activationTime !=null">
  67 + and t1.activation_time &lt;= #{condition.activationTime}
  68 + </if>
  69 + <if test="condition.startTime1 !=null">
  70 + and t1.activation_time >= #{condition.startTime1}
  71 + </if>
  72 + <if test="condition.startTime2 !=null">
  73 + and t1.activation_time &lt;= #{condition.startTime2}
63 74 </if>
64 75 <if test="condition.sources !=null">
65 76 and t1.sources = #{condition.sources}
... ... @@ -91,6 +102,9 @@
91 102 <if test="condition.groupId !=null">
92 103 and t1.group_id = #{condition.groupId}
93 104 </if>
  105 + <if test="condition.reason != null">
  106 + and t1.reason = #{condition.reason}
  107 + </if>
94 108 <if test="condition.defeated !=null and condition.defeated == 1">
95 109 and t1.reject_time is not null
96 110 </if>
... ... @@ -155,8 +169,14 @@
155 169 #{id}
156 170 </foreach>
157 171 </if>
158   - <if test="condition.startTime !=null">
159   - and t1.activation_time &lt;= #{condition.startTime}
  172 + <if test="condition.activationTime !=null">
  173 + and t1.activation_time &lt;= #{condition.activationTime}
  174 + </if>
  175 + <if test="condition.startTime1 !=null">
  176 + and t1.activation_time >= #{condition.startTime1}
  177 + </if>
  178 + <if test="condition.startTime2 !=null">
  179 + and t1.activation_time &lt;= #{condition.startTime2}
160 180 </if>
161 181 <if test="condition.sources !=null">
162 182 and t1.sources = #{condition.sources}
... ... @@ -182,6 +202,9 @@
182 202 <if test="condition.address !=null and condition.address !=''">
183 203 and t3.address like concat('%', #{condition.address}, '%')
184 204 </if>
  205 + <if test="condition.reason != null">
  206 + and t1.reason = #{condition.reason}
  207 + </if>
185 208 <if test="condition.level !=null">
186 209 and t2.cus_level = #{condition.level}
187 210 </if>
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/pool/StammkundePool.java
1 1 package cn.fw.valhalla.domain.db.pool;
2 2  
3 3 import cn.fw.common.data.entity.BaseAuditableTimeEntity;
  4 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
4 5 import cn.fw.valhalla.domain.enums.StammkundeSourcesEnum;
5 6 import cn.fw.valhalla.domain.enums.StammkundeStatusEnum;
6 7 import lombok.Data;
... ... @@ -48,8 +49,31 @@ public class StammkundePool extends BaseAuditableTimeEntity&lt;StammkundePool, Long
48 49 */
49 50 private Date activationTime;
50 51 private Date rejectTime;
  52 + /**
  53 + * 战败原因
  54 + */
  55 + private DefeatReasonEnum reason;
  56 + /**
  57 + * 服务站id
  58 + */
51 59 private Long shopId;
52 60 /**
  61 + * 新顾问id
  62 + */
  63 + private Long newUserId;
  64 + /**
  65 + * 新顾问名称
  66 + */
  67 + private String newUserName;
  68 + /**
  69 + * 新门店id
  70 + */
  71 + private Long newShopId;
  72 + /**
  73 + * 新门店名称
  74 + */
  75 + private String newShopName;
  76 + /**
53 77 * 集团id
54 78 */
55 79 private Long groupId;
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/db/report/CustomerRetentionRatio.java
1 1 package cn.fw.valhalla.domain.db.report;
2 2  
3 3 import cn.fw.common.data.entity.BaseEntity;
  4 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
4 5 import lombok.Data;
5 6 import lombok.EqualsAndHashCode;
6 7 import lombok.ToString;
... ... @@ -46,6 +47,10 @@ public class CustomerRetentionRatio extends BaseEntity&lt;CustomerRetentionRatio, L
46 47 */
47 48 private Integer defeatNum;
48 49 /**
  50 + * 战败类型
  51 + */
  52 + private DefeatReasonEnum type;
  53 + /**
49 54 * 数据日期
50 55 */
51 56 private Date dataDate;
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/CustomerCluePoolDTO.java
... ... @@ -23,6 +23,22 @@ public class CustomerCluePoolDTO {
23 23 */
24 24 private String plateNo;
25 25 /**
  26 + * 车架号
  27 + */
  28 + private String frameNo;
  29 + /**
  30 + * 购车时间
  31 + */
  32 + private Date buyDate;
  33 + /**
  34 + * 上次进站时间
  35 + */
  36 + private Date arrivalTime;
  37 + /**
  38 + * 保险到期时间
  39 + */
  40 + private Date insuranceExpires;
  41 + /**
26 42 * 线索类型
27 43 */
28 44 private Integer type;
... ... @@ -82,4 +98,8 @@ public class CustomerCluePoolDTO {
82 98 * 战败时间
83 99 */
84 100 private Date defeatTime;
  101 + /**
  102 + * 贷款到期时间
  103 + */
  104 + private Date loanExpires;
85 105 }
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/StammkundeDto.java 0 → 100644
  1 +package cn.fw.valhalla.domain.dto;
  2 +
  3 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * @author : kurisu
  8 + * @className : StammkundeDto
  9 + * @description : 保有客池禁用dto
  10 + * @date: 2020-12-21 14:40
  11 + */
  12 +@Data
  13 +public class StammkundeDto {
  14 + /**
  15 + * 档案id
  16 + */
  17 + private Long customerId;
  18 + /**
  19 + * 战败原因
  20 + */
  21 + private DefeatReasonEnum reason;
  22 + /**
  23 + * 服务站id
  24 + */
  25 + private Long shopId;
  26 + /**
  27 + * 新顾问id
  28 + */
  29 + private Long newUserId;
  30 + /**
  31 + * 新顾问名称
  32 + */
  33 + private String newUserName;
  34 + /**
  35 + * 新门店id
  36 + */
  37 + private Long newShopId;
  38 + /**
  39 + * 新门店名称
  40 + */
  41 + private String newShopName;
  42 + /**
  43 + * 集团id
  44 + */
  45 + private Long groupId;
  46 +}
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/dto/StammkundePoolDTO.java
... ... @@ -87,4 +87,24 @@ public class StammkundePoolDTO {
87 87 * 进站次数
88 88 */
89 89 private Integer times;
  90 + /**
  91 + * 战败原因
  92 + */
  93 + private Integer reason;
  94 + /**
  95 + * 新顾问id
  96 + */
  97 + private Long newUserId;
  98 + /**
  99 + * 新顾问名称
  100 + */
  101 + private String newUserName;
  102 + /**
  103 + * 新门店id
  104 + */
  105 + private Long newShopId;
  106 + /**
  107 + * 新门店名称
  108 + */
  109 + private String newShopName;
90 110 }
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/DefeatReasonEnum.java
... ... @@ -13,25 +13,49 @@ import lombok.Getter;
13 13 */
14 14 public enum DefeatReasonEnum implements IEnum<Integer> {
15 15 /**
16   - * 系统战败
  16 + * 保养卡流失
17 17 */
18   - SYS(1, "系统战败"),
  18 + MC(1, "保养卡流失"),
19 19 /**
20   - * 用户更换
  20 + * 质保卡流失
21 21 */
22   - USER(2, "用户更换"),
  22 + WC(2, "质保卡流失"),
23 23 /**
24   - * 跟进逾期战败
  24 + * 保险流失
25 25 */
26   - OVERDUE(3, "跟进逾期战败"),
  26 + IN(3, "保险流失"),
  27 + /**
  28 + * 进另一门店
  29 + */
  30 + TO_SHOP(4, "进另一门店"),
27 31 /**
28 32 * 主动放弃
29 33 */
30   - GIVE_UP(4, "主动放弃"),
  34 + GU(5, "主动放弃"),
  35 + /**
  36 + * 首保流失
  37 + */
  38 + FM(6, "首保流失"),
  39 + /**
  40 + * 流失客户
  41 + */
  42 + RM(7, "流失客户"),
  43 +// /**
  44 +// * 客户变更
  45 +// */
  46 +// CC(8, "客户主动变更"),
  47 +// /**
  48 +// * 接车档案变更
  49 +// */
  50 +// CI(9, "接车档案变更"),
  51 +// /**
  52 +// * 离职调岗档案变更
  53 +// */
  54 +// LC(10, "离职调岗档案变更"),
31 55 /**
32 56 * 其他原因
33 57 */
34   - OTHER(5, "其他原因")
  58 + OT(99, "其他原因")
35 59 ;
36 60  
37 61 /**
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/enums/SettingTypeEnum.java
... ... @@ -53,9 +53,9 @@ public enum SettingTypeEnum implements IEnum&lt;Integer&gt; {
53 53 */
54 54 LIMITATION(10, "待办时效", 0),
55 55 /**
56   - * 首保集团标准最低值(首保only)
  56 + * 保持率集团标准最低值(首保only)
57 57 */
58   - RETENTION_RATIO(11, "待办时效", 10),
  58 + RETENTION_RATIO(11, "保持率标准最低值", 10),
59 59 ;
60 60  
61 61 /**
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/CustomerCluePoolQueryVO.java
... ... @@ -14,6 +14,7 @@ import java.time.ZoneId;
14 14 import java.util.Arrays;
15 15 import java.util.Date;
16 16 import java.util.List;
  17 +import java.util.Objects;
17 18 import java.util.stream.Collectors;
18 19  
19 20 /**
... ... @@ -34,12 +35,24 @@ public class CustomerCluePoolQueryVO extends PoolQuery {
34 35 private Integer status;
35 36 private String shopName;
36 37 private String comShops;
  38 + private String frameNo;
  39 + /**
  40 + * 贷款期客户
  41 + */
  42 + private Boolean loanCustomer;
37 43 /**
38 44 * 管理门店范围
39 45 */
40 46 private String scope;
41 47  
42 48  
  49 + public Integer getLoanCustomer() {
  50 + if (Objects.isNull(loanCustomer)) {
  51 + return null;
  52 + }
  53 + return loanCustomer ? 1 : 0;
  54 + }
  55 +
43 56 public Date getStartTime() {
44 57 if (StringUtils.isNotBlank(startTime) && NumberUtils.isDigits(startTime)) {
45 58 LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(startTime)).atZone(ZoneId.systemDefault()).toLocalDateTime();
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/query/StammkundePoolQueryVO.java
... ... @@ -32,6 +32,7 @@ public class StammkundePoolQueryVO extends PoolQuery {
32 32 */
33 33 private String activationTime;
34 34 private Integer sources;
  35 + private Integer reason;
35 36 /**
36 37 * 区间
37 38 */
... ... @@ -43,6 +44,7 @@ public class StammkundePoolQueryVO extends PoolQuery {
43 44 private Boolean warrantyCard;
44 45 private Boolean maintainCard;
45 46 private Boolean defeated;
  47 + private String startTime;
46 48 /**
47 49 * 贷款期客户
48 50 */
... ... @@ -76,7 +78,7 @@ public class StammkundePoolQueryVO extends PoolQuery {
76 78 return defeated ? 1 : 0;
77 79 }
78 80  
79   - public Date getStartTime() {
  81 + public Date getActivationTime1() {
80 82 if (StringUtils.isNotBlank(activationTime) && NumberUtils.isDigits(activationTime)) {
81 83 LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(activationTime)).atZone(ZoneId.systemDefault()).toLocalDateTime();
82 84 return DateUtil.getEndInTime(DateUtil.localDateTime2Date(localDateTime));
... ... @@ -84,6 +86,33 @@ public class StammkundePoolQueryVO extends PoolQuery {
84 86 return null;
85 87 }
86 88  
  89 + public Date getStartTime1() {
  90 + if (StringUtils.isBlank(startTime)) {
  91 + return null;
  92 + }
  93 + String[] times = startTime.split(",");
  94 + if (StringUtils.isNotBlank(times[0]) && NumberUtils.isDigits(times[0])) {
  95 + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[0])).atZone(ZoneId.systemDefault()).toLocalDateTime();
  96 + return DateUtil.getBeginInTime(DateUtil.localDateTime2Date(localDateTime));
  97 + }
  98 + return null;
  99 + }
  100 +
  101 + public Date getStartTime2() {
  102 + if (StringUtils.isBlank(startTime)) {
  103 + return null;
  104 + }
  105 + String[] times = startTime.split(",");
  106 + if (times.length < 2) {
  107 + return null;
  108 + }
  109 + if (StringUtils.isNotBlank(times[1]) && NumberUtils.isDigits(times[1])) {
  110 + LocalDateTime localDateTime = Instant.ofEpochMilli(NumberUtils.toLong(times[1])).atZone(ZoneId.systemDefault()).toLocalDateTime();
  111 + return DateUtil.getEndInTime(DateUtil.localDateTime2Date(localDateTime));
  112 + }
  113 + return null;
  114 + }
  115 +
87 116 public Date getDefeatTime1() {
88 117 if (StringUtils.isBlank(defeatTime)) {
89 118 return null;
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/CustomerCluePoolVO.java
... ... @@ -24,6 +24,26 @@ public class CustomerCluePoolVO {
24 24 */
25 25 private String plateNo;
26 26 /**
  27 + * 车架号
  28 + */
  29 + private String frameNo;
  30 + /**
  31 + * 是否是贷款客户
  32 + */
  33 + private Boolean loanCustomer;
  34 + /**
  35 + * 购车时间
  36 + */
  37 + private Date buyDate;
  38 + /**
  39 + * 上次进站时间
  40 + */
  41 + private Date arrivalTime;
  42 + /**
  43 + * 保险到期时间
  44 + */
  45 + private Date insuranceExpires;
  46 + /**
27 47 * 线索类型
28 48 */
29 49 private Integer type;
... ... @@ -64,6 +84,10 @@ public class CustomerCluePoolVO {
64 84 * 战败时间
65 85 */
66 86 private Date defeatTime;
  87 + /**
  88 + * 零售门店
  89 + */
  90 + private String saleShop;
67 91  
68 92 public Date getFinishTime() {
69 93 if (ClueStatusEnum.FAILURE.getValue().equals(status)) {
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/CustomerClueSummaryVO.java
... ... @@ -25,6 +25,14 @@ public class CustomerClueSummaryVO {
25 25 * 战败数
26 26 */
27 27 private Long defeatNum;
  28 + /**
  29 + * 关单线索总数
  30 + */
  31 + private Long closedNum;
  32 + /**
  33 + * 进行中的数量
  34 + */
  35 + private Long onGoingNum;
28 36  
29 37 public BigDecimal getCompleteRatio() {
30 38 if (Objects.isNull(completeNum) || completeNum == 0) {
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/pool/StammkundePoolVO.java
... ... @@ -48,6 +48,10 @@ public class StammkundePoolVO {
48 48 */
49 49 private Date defeatTime;
50 50 /**
  51 + * 战败原因
  52 + */
  53 + private Integer reason;
  54 + /**
51 55 * 状态
52 56 */
53 57 private Integer poolStatus;
... ... @@ -91,4 +95,20 @@ public class StammkundePoolVO {
91 95 * 进站次数
92 96 */
93 97 private Integer times;
  98 + /**
  99 + * 新顾问id
  100 + */
  101 + private Long newUserId;
  102 + /**
  103 + * 新顾问名称
  104 + */
  105 + private String newUserName;
  106 + /**
  107 + * 新门店id
  108 + */
  109 + private Long newShopId;
  110 + /**
  111 + * 新门店名称
  112 + */
  113 + private String newShopName;
94 114 }
... ...
fw-valhalla-domain/src/main/java/cn/fw/valhalla/domain/vo/setting/SettingVO.java
... ... @@ -41,7 +41,7 @@ public class SettingVO {
41 41 SettingVO vo = new SettingVO();
42 42 vo.setId(detail.getId());
43 43 vo.setDetailValue(detail.getDetailValue());
44   - if (SettingTypeEnum.REVISE_RATIO.equals(detail.getType())) {
  44 + if (SettingTypeEnum.REVISE_RATIO.equals(detail.getType()) || SettingTypeEnum.RETENTION_RATIO.equals(detail.getType())) {
45 45 vo.setDetailValue(detail.getDetailValue() / 100);
46 46 }
47 47 vo.setSettingId(detail.getSettingId());
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/AbsBaseRpcService.java 0 → 100644
  1 +package cn.fw.valhalla.rpc;
  2 +
  3 +import cn.fw.valhalla.common.utils.StringUtils;
  4 +import com.alibaba.fastjson.JSON;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.beans.factory.annotation.Autowired;
  8 +import org.springframework.data.redis.core.BoundListOperations;
  9 +import org.springframework.data.redis.core.BoundValueOperations;
  10 +import org.springframework.data.redis.core.StringRedisTemplate;
  11 +import org.springframework.lang.NonNull;
  12 +import org.springframework.lang.Nullable;
  13 +
  14 +import java.util.ArrayList;
  15 +import java.util.List;
  16 +import java.util.Objects;
  17 +import java.util.Optional;
  18 +import java.util.concurrent.TimeUnit;
  19 +
  20 +/**
  21 + * @author : kurisu
  22 + * @className : AbsBaseRpcService
  23 + * @description : 公共方法
  24 + * @date: 2020-12-17 14:13
  25 + */
  26 +@Slf4j
  27 +public abstract class AbsBaseRpcService {
  28 + /**
  29 + * Redis工具
  30 + */
  31 + @Autowired
  32 + protected StringRedisTemplate redisTemplate;
  33 +
  34 + /**
  35 + * 缓存KEY前缀
  36 + *
  37 + * @return
  38 + */
  39 + protected abstract String getKeyPrefix();
  40 +
  41 + /**
  42 + * 从缓存获取对象
  43 + *
  44 + * @param key
  45 + * @param clazz
  46 + * @param <E> 获取的对象
  47 + * @return
  48 + */
  49 + @Nullable
  50 + protected <E> E getFromCache(@NonNull final String key, Class<E> clazz) {
  51 + String cache = getFromCache(key);
  52 + if (StringUtils.isEmpty(cache)) {
  53 + return null;
  54 + }
  55 + return JSON.parseObject(cache, clazz);
  56 + }
  57 +
  58 + protected String getFromCache(@NonNull final String key) {
  59 + String json = null;
  60 + try {
  61 + BoundValueOperations<String, String> ops = redisTemplate.boundValueOps(key);
  62 + json = ops.get();
  63 + log.info("从缓存获信息成功[{}]->[{}]", key, json);
  64 + } catch (Exception e) {
  65 + log.error("从缓存获信息失败[{}]", key, e);
  66 + }
  67 + return json;
  68 + }
  69 +
  70 + protected void setToCache(@NonNull final String key, @NonNull final String value) {
  71 + setToCache(key, value, 30);
  72 + }
  73 +
  74 + /**
  75 + * 缓存信息
  76 + * @param key
  77 + * @param value
  78 + * @param timeout 缓存时间(秒)
  79 + */
  80 + protected void setToCache(@NonNull final String key, @NonNull final String value, long timeout) {
  81 + log.info("缓存信息[{}]:{}", key, value);
  82 + try {
  83 + redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
  84 + } catch (Exception e) {
  85 + log.error("缓存信息失败[{}][{}]", key, value, e);
  86 + }
  87 + }
  88 +
  89 + protected <E> List<E> getListFromCache(final String key, Class<E> clazz) {
  90 + try {
  91 + BoundListOperations<String, String> queue = getQueue(key);
  92 + final long size = Optional.ofNullable(queue.size()).orElse(0L);
  93 + if (size > 0) {
  94 + final List<E> dtos = new ArrayList<>();
  95 + for (long i = 0; i < size; i++) {
  96 + final String json = Objects.requireNonNull(queue.index(i));
  97 + dtos.add(JSONObject.parseObject(json, clazz));
  98 + }
  99 + return dtos;
  100 + }
  101 + } catch (Exception e) {
  102 + log.error("从缓存获取信息失败[{}]", key, e);
  103 + }
  104 + return null;
  105 + }
  106 +
  107 + protected void setListToCache(@NonNull final String key, @NonNull final String value) {
  108 + try {
  109 + getQueue(key).rightPush(value);
  110 + } catch (Exception e) {
  111 + log.error("缓存息失败[{}][{}]", key, value, e);
  112 + }
  113 + }
  114 +
  115 + protected BoundListOperations<String, String> getQueue(@NonNull final String key) {
  116 + return redisTemplate.boundListOps(key);
  117 + }
  118 +}
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/erp/UserService.java
... ... @@ -7,23 +7,24 @@ import cn.fw.erp.sdk.api.result.UserBaseInfo;
7 7 import cn.fw.erp.sdk.api.result.UserRoleDataRange;
8 8 import cn.fw.erp.sdk.api.result.UserRoleInfo;
9 9 import cn.fw.valhalla.common.utils.StringUtils;
  10 +import cn.fw.valhalla.rpc.AbsBaseRpcService;
10 11 import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
11 12 import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
12 13 import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO;
13 14 import com.alibaba.fastjson.JSONObject;
14 15 import lombok.Getter;
  16 +import lombok.RequiredArgsConstructor;
15 17 import lombok.extern.slf4j.Slf4j;
16 18 import org.springframework.beans.BeanUtils;
17   -import org.springframework.beans.factory.annotation.Autowired;
18 19 import org.springframework.beans.factory.annotation.Value;
19   -import org.springframework.data.redis.core.BoundListOperations;
20   -import org.springframework.data.redis.core.BoundValueOperations;
21   -import org.springframework.data.redis.core.StringRedisTemplate;
22 20 import org.springframework.stereotype.Service;
23 21 import org.springframework.util.Assert;
24 22 import org.springframework.util.CollectionUtils;
25 23  
26   -import java.util.*;
  24 +import java.util.ArrayList;
  25 +import java.util.Collections;
  26 +import java.util.List;
  27 +import java.util.Objects;
27 28 import java.util.concurrent.TimeUnit;
28 29 import java.util.stream.Collectors;
29 30  
... ... @@ -39,7 +40,8 @@ import static org.apache.commons.lang3.Validate.notNull;
39 40 */
40 41 @Slf4j
41 42 @Service
42   -public class UserService {
  43 +@RequiredArgsConstructor
  44 +public class UserService extends AbsBaseRpcService {
43 45 /**
44 46 * 用户服务
45 47 */
... ... @@ -48,28 +50,11 @@ public class UserService {
48 50 * 岗位用户服务
49 51 */
50 52 private final UserRoleApi userRoleApi;
51   - /**
52   - * Redis工具
53   - */
54   - private final StringRedisTemplate redisTemplate;
55 53  
56 54 @Value("${spring.cache.custom.global-prefix}:rpc:erp")
57 55 @Getter
58 56 private String keyPrefix;
59 57  
60   -
61   - /**
62   - * 默认构造器
63   - */
64   - @Autowired
65   - public UserService(final UserApi userApi,
66   - final UserRoleApi userRoleApi,
67   - final StringRedisTemplate redisTemplate) {
68   - this.userApi = userApi;
69   - this.userRoleApi = userRoleApi;
70   - this.redisTemplate = redisTemplate;
71   - }
72   -
73 58 /**
74 59 * 根据用户ID获取用户信息
75 60 *
... ... @@ -81,7 +66,7 @@ public class UserService {
81 66 return null;
82 67 }
83 68 String key = generateKey(userId);
84   - String json = getUserFromCache(key);
  69 + String json = getFromCache(key);
85 70 if (StringUtils.isValid(json)) {
86 71 return JSONObject.parseObject(json, UserInfoDTO.class);
87 72 }
... ... @@ -97,7 +82,7 @@ public class UserService {
97 82 userInfoDTO.setUserName(userBaseInfo.getUserName());
98 83 userInfoDTO.setHeadImg(userBaseInfo.getHeadImg());
99 84 userInfoDTO.setMobile(msg.getData().getMobile());
100   - setUserToCache(key, JSONObject.toJSONString(userInfoDTO));
  85 + setToCache(key, JSONObject.toJSONString(userInfoDTO), 60);
101 86 return userInfoDTO;
102 87 } catch (Exception e) {
103 88 log.info("调用ERP[根据用户ID[{}]获取用户信息]系统失败", userId, e);
... ... @@ -190,7 +175,7 @@ public class UserService {
190 175 return Collections.emptyList();
191 176 }
192 177 String key = generateKey(shopId, roleCode);
193   - List<PostUserDTO> dtos = getFromCache(key);
  178 + List<PostUserDTO> dtos = getListFromCache(key, PostUserDTO.class);
194 179 if (!CollectionUtils.isEmpty(dtos)) {
195 180 return dtos;
196 181 }
... ... @@ -206,7 +191,7 @@ public class UserService {
206 191 PostUserDTO dto = new PostUserDTO();
207 192 BeanUtils.copyProperties(datum, dto);
208 193 list.add(dto);
209   - setToCache(key, JSONObject.toJSONString(dto));
  194 + setListToCache(key, JSONObject.toJSONString(dto));
210 195 }
211 196 getQueue(key).expire(10, TimeUnit.MINUTES);
212 197 return list;
... ... @@ -216,38 +201,6 @@ public class UserService {
216 201 return Collections.emptyList();
217 202 }
218 203  
219   -
220   - private List<PostUserDTO> getFromCache(final String key) {
221   - try {
222   - BoundListOperations<String, String> queue = getQueue(key);
223   - final long size = Optional.ofNullable(queue.size()).orElse(0L);
224   - if (size > 0) {
225   - final List<PostUserDTO> userDTOS = new ArrayList<>();
226   - for (long i = 0; i < size; i++) {
227   - final String json = Objects.requireNonNull(queue.index(i));
228   - userDTOS.add(JSONObject.parseObject(json, PostUserDTO.class));
229   - }
230   - return userDTOS;
231   - }
232   - } catch (Exception e) {
233   - log.error("erpRpc 从缓存获取用户信息失败", e);
234   - }
235   - return null;
236   - }
237   -
238   - private void setToCache(final String key, final String value) {
239   - try {
240   - getQueue(key).rightPush(value);
241   - } catch (Exception e) {
242   - log.error("erpRpc 缓存用户信息失败", e);
243   - }
244   - }
245   -
246   - private BoundListOperations<String, String> getQueue(final String key) {
247   - return redisTemplate.boundListOps(key);
248   - }
249   -
250   -
251 204 private String generateKey(final Long shopId, final String roleCOde) {
252 205 Assert.notNull(shopId, "id cannot be null");
253 206 Assert.hasLength(roleCOde, "roleCOde cannot be null");
... ... @@ -260,24 +213,4 @@ public class UserService {
260 213  
261 214 return String.format("%s:%s:%s", getKeyPrefix(), "user", userId);
262 215 }
263   -
264   - private String getUserFromCache(final String key) {
265   - String json = null;
266   - try {
267   - BoundValueOperations<String, String> ops = redisTemplate.boundValueOps(key);
268   - json = ops.get();
269   - } catch (Exception e) {
270   - log.error("erpRpc 从缓存获取用户信息失败", e);
271   - }
272   - return json;
273   - }
274   -
275   -
276   - private void setUserToCache(final String key, final String value) {
277   - try {
278   - redisTemplate.opsForValue().set(key, value, 60, TimeUnit.SECONDS);
279   - } catch (Exception e) {
280   - log.error("erpRpc 从缓存获取用户信息失败", e);
281   - }
282   - }
283 216 }
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/oop/OopService.java
... ... @@ -5,18 +5,16 @@ import cn.fw.oop.sdk.*;
5 5 import cn.fw.oop.sdk.enums.BizTypeEnum;
6 6 import cn.fw.oop.sdk.result.*;
7 7 import cn.fw.valhalla.common.utils.StringUtils;
  8 +import cn.fw.valhalla.rpc.AbsBaseRpcService;
8 9 import cn.fw.valhalla.rpc.oop.dto.*;
9 10 import com.alibaba.fastjson.JSON;
10 11 import com.alibaba.fastjson.JSONArray;
11 12 import com.alibaba.fastjson.JSONObject;
12   -import lombok.Getter;
  13 +import lombok.RequiredArgsConstructor;
13 14 import lombok.extern.slf4j.Slf4j;
14 15 import org.apache.commons.collections4.CollectionUtils;
15 16 import org.springframework.beans.BeanUtils;
16   -import org.springframework.beans.factory.annotation.Autowired;
17 17 import org.springframework.beans.factory.annotation.Value;
18   -import org.springframework.data.redis.core.BoundValueOperations;
19   -import org.springframework.data.redis.core.StringRedisTemplate;
20 18 import org.springframework.stereotype.Service;
21 19 import org.springframework.util.Assert;
22 20  
... ... @@ -24,7 +22,6 @@ import java.util.ArrayList;
24 22 import java.util.Collections;
25 23 import java.util.List;
26 24 import java.util.Objects;
27   -import java.util.concurrent.TimeUnit;
28 25 import java.util.stream.Collectors;
29 26  
30 27 import static cn.fw.common.businessvalidator.Validator.BV;
... ... @@ -38,8 +35,9 @@ import static cn.fw.common.businessvalidator.Validator.BV;
38 35 */
39 36 @Slf4j
40 37 @Service
  38 +@RequiredArgsConstructor
41 39 @SuppressWarnings("Duplicates")
42   -public class OopService {
  40 +public class OopService extends AbsBaseRpcService {
43 41  
44 42 /**
45 43 * 门店服务
... ... @@ -62,45 +60,17 @@ public class OopService {
62 60 */
63 61 private final CarSpecApiService carSpecApiService;
64 62  
65   -
66 63 private final RegionApiService regionApiService;
67 64  
68 65 /**
69 66 * 集团服务
70 67 */
71 68 private final GroupApiService groupApiService;
72   - /**
73   - * Redis工具
74   - */
75   - private final StringRedisTemplate redisTemplate;
76 69  
77 70 @Value("${spring.cache.custom.global-prefix}:rpc:oop")
78   - @Getter
79 71 private String keyPrefix;
80 72  
81 73 /**
82   - * 默认构造器
83   - */
84   - @Autowired
85   - public OopService(final ShopApiService shopApiService,
86   - final DealerApiService dealerApiService,
87   - final CarBrandApiService carBrandApiService,
88   - final CarSeriesApiService carSeriesApiService,
89   - final CarSpecApiService carSpecApiService,
90   - final GroupApiService groupApiService,
91   - final RegionApiService regionApiService,
92   - final StringRedisTemplate redisTemplate) {
93   - this.shopApiService = shopApiService;
94   - this.dealerApiService = dealerApiService;
95   - this.carBrandApiService = carBrandApiService;
96   - this.carSeriesApiService = carSeriesApiService;
97   - this.carSpecApiService = carSpecApiService;
98   - this.groupApiService = groupApiService;
99   - this.regionApiService = regionApiService;
100   - this.redisTemplate = redisTemplate;
101   - }
102   -
103   - /**
104 74 * 根据车系ID获取车系信息
105 75 *
106 76 * @param seriesId 车系ID
... ... @@ -110,10 +80,10 @@ public class OopService {
110 80 if (seriesId == null) {
111 81 return null;
112 82 }
113   - String key = generateKey(OopTypeEnum.SERIES, seriesId);
114   - String json = getFromCache(key);
115   - if (StringUtils.isValid(json)) {
116   - return JSONObject.parseObject(json, SeriesDTO.class);
  83 + final String key = generateKey(OopTypeEnum.SERIES, seriesId);
  84 + SeriesDTO seriesDTO = getFromCache(key, SeriesDTO.class);
  85 + if (Objects.nonNull(seriesDTO)) {
  86 + return seriesDTO;
117 87 }
118 88 try {
119 89 final Message<CarSeriesInfoVo> msg = carSeriesApiService.getSeriesInfo(seriesId);
... ... @@ -141,9 +111,9 @@ public class OopService {
141 111 return null;
142 112 }
143 113 String key = generateKey(OopTypeEnum.BRAND, brandId);
144   - String json = getFromCache(key);
145   - if (StringUtils.isValid(json)) {
146   - return JSONObject.parseObject(json, BrandDTO.class);
  114 + BrandDTO brandDTO = getFromCache(key, BrandDTO.class);
  115 + if (Objects.nonNull(brandDTO)) {
  116 + return brandDTO;
147 117 }
148 118 try {
149 119 final Message<CarBrandInfoVo> msg = carBrandApiService.getBrandInfo(brandId);
... ... @@ -451,30 +421,11 @@ public class OopService {
451 421 return new ArrayList<>();
452 422 }
453 423  
454   - private String getFromCache(final String key) {
455   - String json = null;
456   - try {
457   - BoundValueOperations<String, String> ops = redisTemplate.boundValueOps(key);
458   - json = ops.get();
459   - } catch (Exception e) {
460   - log.error("oopRpc 从缓存获取门店信息失败", e);
461   - }
462   - return json;
  424 + @Override
  425 + protected String getKeyPrefix() {
  426 + return keyPrefix;
463 427 }
464 428  
465   - private void setToCache(final String key, final String value) {
466   - setToCache(key, value, 30);
467   - }
468   -
469   - private void setToCache(final String key, final String value, long timeout) {
470   - try {
471   - redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
472   - } catch (Exception e) {
473   - log.error("oopRpc 缓存门店信息失败", e);
474   - }
475   - }
476   -
477   -
478 429 private String generateKey(final OopTypeEnum typeEnum, final Long id) {
479 430 Assert.notNull(id, "id cannot be null");
480 431  
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/order/OrderRpcService.java
... ... @@ -2,52 +2,75 @@ package cn.fw.valhalla.rpc.order;
2 2  
3 3 import cn.fw.data.base.domain.common.Message;
4 4 import cn.fw.order.sdk.api.CarOrderApiService;
5   -import cn.fw.order.sdk.result.CarOrderCustomerResultDto;
  5 +import cn.fw.order.sdk.result.CarOrderResultDto;
  6 +import cn.fw.valhalla.rpc.AbsBaseRpcService;
  7 +import cn.fw.valhalla.rpc.order.dto.NewCarOrderInfo;
6 8 import com.alibaba.fastjson.JSON;
  9 +import com.alibaba.fastjson.JSONObject;
  10 +import lombok.RequiredArgsConstructor;
7 11 import lombok.extern.slf4j.Slf4j;
8   -import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.beans.BeanUtils;
  13 +import org.springframework.beans.factory.annotation.Value;
9 14 import org.springframework.stereotype.Service;
10 15  
11 16 import java.util.Objects;
12 17  
  18 +import static cn.fw.common.businessvalidator.Validator.BV;
  19 +
13 20 /**
14   - * fw-cas
15   - * <p>
16   - * create at 2020-05-18
  21 + * OrderRpcService
  22 + * create at 2020-12-17
17 23 *
18 24 * @author kurisu
19 25 */
20 26 @Slf4j
21 27 @Service
22   -public class OrderRpcService {
  28 +@RequiredArgsConstructor
  29 +public class OrderRpcService extends AbsBaseRpcService {
23 30  
24   - private CarOrderApiService carOrderApiService;
  31 + private final CarOrderApiService carOrderApiService;
25 32  
26   - @Autowired
27   - OrderRpcService(CarOrderApiService carOrderApiService) {
28   - this.carOrderApiService = carOrderApiService;
29   - }
  33 + @Value("${spring.cache.custom.global-prefix}:rpc:newcar:order")
  34 + private String keyPrefix;
30 35  
31 36 /**
32   - * 查询会员在门店进行中工单关联的客户档案id
  37 + * 查询vin对应的订单信息
33 38 *
34   - * @param memberId 会员id
35   - * @param shopId 门店id
  39 + * @param vin 车架号
36 40 */
37   - public Long getOrderCustomer(Long memberId, Long shopId) {
  41 + public NewCarOrderInfo getOrderInfo(final String vin) {
  42 + final String message = "查询vin对应的订单信息[getOrderInfo]";
38 43 try {
39   - log.info("查询正在进行中的新车订单关联的客户档案id,memberId:{},shopId:{}", memberId, shopId);
40   - Message<CarOrderCustomerResultDto> msg = carOrderApiService.getMemberOrderInProgress(shopId,memberId);
41   - log.info("查询正在进行中的新车订单关联的客户档案id,memberId:{},shopId:{},result:{}", JSON.toJSONString(msg));
42   - if (Objects.isNull(msg.getData())) {
  44 + log.info("{},vin:{}", message, vin);
  45 + final String key = generateKey(vin);
  46 + NewCarOrderInfo orderInfo = getFromCache(key, NewCarOrderInfo.class);
  47 + if (Objects.nonNull(orderInfo)) {
  48 + return orderInfo;
  49 + }
  50 + Message<CarOrderResultDto> msg = carOrderApiService.getCarOrderByVin(vin);
  51 + log.info("{},vin:{},result:{}", message, vin, JSON.toJSONString(msg));
  52 + CarOrderResultDto data = msg.getData();
  53 + if (!msg.isSuccess() || Objects.isNull(data)) {
43 54 return null;
44 55 }
45   - return msg.getData().getCustomerId();
  56 + NewCarOrderInfo order = new NewCarOrderInfo();
  57 + BeanUtils.copyProperties(data, order);
  58 + setToCache(key, JSONObject.toJSONString(order), 60 * 60 * 24);
  59 + return order;
46 60 } catch (Exception ex) {
47   - log.error("查询正在进行中的新车订单关联的客户档案id失败,memberId:{},shopId:{},原因:{}", JSON.toJSONString(ex));
  61 + log.error("{}失败,vin:{}", message, vin, ex);
48 62 }
49 63 return null;
50 64 }
51 65  
  66 + @Override
  67 + protected String getKeyPrefix() {
  68 + return keyPrefix;
  69 + }
  70 +
  71 + private String generateKey(final String vin) {
  72 + BV.isNotBlank(vin, "vin cannot be blank");
52 73  
  74 + return String.format("%s:%s", getKeyPrefix(), vin);
  75 + }
53 76 }
... ...
fw-valhalla-rpc/src/main/java/cn/fw/valhalla/rpc/order/dto/NewCarOrderInfo.java 0 → 100644
  1 +package cn.fw.valhalla.rpc.order.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @author : kurisu
  7 + * @className : NewCarOrderInfo
  8 + * @description : 新车订单信息
  9 + * @date: 2020-12-17 11:35
  10 + */
  11 +@Data
  12 +public class NewCarOrderInfo {
  13 + /**
  14 + * 销顾id
  15 + */
  16 + private Long consultId;
  17 + /**
  18 + * 销顾名称
  19 + */
  20 + private String consultName;
  21 + /**
  22 + * 门店id
  23 + */
  24 + private Long shopId;
  25 + /**
  26 + * 集团id
  27 + */
  28 + private Long groupId;
  29 +}
... ...
fw-valhalla-sdk/pom.xml
... ... @@ -10,7 +10,7 @@
10 10 <relativePath>../pom.xml</relativePath>
11 11 </parent>
12 12 <artifactId>fw-valhalla-sdk</artifactId>
13   - <version>1.1.0</version>
  13 + <version>1.1.1</version>
14 14 <packaging>jar</packaging>
15 15 <name>fw-valhalla-sdk</name>
16 16  
... ...
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/enums/ReasonEnum.java 0 → 100644
  1 +package cn.fw.valhalla.sdk.enums;
  2 +
  3 +import com.baomidou.mybatisplus.core.enums.IEnum;
  4 +import com.fasterxml.jackson.annotation.JsonCreator;
  5 +import com.fasterxml.jackson.annotation.JsonValue;
  6 +import lombok.Getter;
  7 +
  8 +/**
  9 + * @author : kurisu
  10 + * @className : ReasonEnum
  11 + * @description : 变更原因
  12 + * @date: 2020-08-11 17:37
  13 + */
  14 +public enum ReasonEnum implements IEnum<Integer> {
  15 + /**
  16 + * 购买保养卡
  17 + */
  18 + MC(1, "购买保养卡"),
  19 + /**
  20 + * 购买质保卡
  21 + */
  22 + WC(2, "购买质保卡"),
  23 + /**
  24 + * 购买保险
  25 + */
  26 + IN(3, "购买保险"),
  27 + /**
  28 + * 到店消费
  29 + */
  30 + TO_SHOP(4, "到店消费");
  31 +
  32 + /**
  33 + * 值
  34 + */
  35 + private final Integer value;
  36 + /**
  37 + * 名称
  38 + */
  39 + @Getter
  40 + private final String name;
  41 +
  42 + ReasonEnum(final Integer value, final String name) {
  43 + this.value = value;
  44 + this.name = name;
  45 + }
  46 +
  47 + /**
  48 + * 根据枚举值获取枚举对象
  49 + */
  50 + @JsonCreator
  51 + public static ReasonEnum ofValue(final Integer value) {
  52 + for (final ReasonEnum typeEnum : ReasonEnum.values()) {
  53 + if (typeEnum.value.equals(value)) {
  54 + return typeEnum;
  55 + }
  56 + }
  57 + return null;
  58 + }
  59 +
  60 + /**
  61 + * 获取值
  62 + *
  63 + * @return 值
  64 + */
  65 + @JsonValue
  66 + @Override
  67 + public Integer getValue() {
  68 + return value;
  69 + }
  70 +}
... ...
fw-valhalla-sdk/src/main/java/cn/fw/valhalla/sdk/param/ChangeAdviserReq.java
... ... @@ -18,7 +18,12 @@ public class ChangeAdviserReq {
18 18 */
19 19 @NotNull(message = "保有客id不能为空")
20 20 private Long cusId;
21   -
  21 + /**
  22 + * 变更原因
  23 + * @see cn.fw.valhalla.sdk.enums.ReasonEnum
  24 + */
  25 + @NotNull(message = "变更原因不能为空")
  26 + private Integer reason;
22 27 /**
23 28 * 服务顾问id
24 29 */
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/CustomerRetentionRatioBizService.java
... ... @@ -4,6 +4,7 @@ import cn.fw.valhalla.common.constant.RoleCode;
4 4 import cn.fw.valhalla.common.utils.DateUtil;
5 5 import cn.fw.valhalla.domain.db.pool.StammkundePool;
6 6 import cn.fw.valhalla.domain.db.report.CustomerRetentionRatio;
  7 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
7 8 import cn.fw.valhalla.domain.enums.StammkundeStatusEnum;
8 9 import cn.fw.valhalla.rpc.erp.UserService;
9 10 import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
... ... @@ -14,16 +15,15 @@ import cn.fw.valhalla.service.data.StammkundePoolService;
14 15 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
15 16 import lombok.RequiredArgsConstructor;
16 17 import lombok.extern.slf4j.Slf4j;
  18 +import org.springframework.beans.BeanUtils;
17 19 import org.springframework.stereotype.Service;
18 20 import org.springframework.transaction.annotation.Transactional;
19 21 import org.springframework.util.CollectionUtils;
20 22  
21 23 import java.sql.Timestamp;
22 24 import java.time.LocalDate;
23   -import java.util.ArrayList;
24   -import java.util.Date;
25   -import java.util.List;
26   -import java.util.Objects;
  25 +import java.util.*;
  26 +import java.util.stream.Stream;
27 27  
28 28 /**
29 29 * @author : kurisu
... ... @@ -43,19 +43,48 @@ public class CustomerRetentionRatioBizService {
43 43 @Transactional(rollbackFor = Exception.class)
44 44 public void extracting(Date nowDate) {
45 45 log.info("开始抽取保有客保持率数据,日期:{}", DateUtil.getStringDateShort(nowDate));
46   - List<ShopDTO> allShops = oopService.getAllShops(2L);
47   - if (CollectionUtils.isEmpty(allShops)) {
48   - return;
  46 + Stream.of(1L, 2L).forEach(groupId -> {
  47 + List<StammkundePool> pools = Optional.ofNullable(stammkundePoolService.list(Wrappers.<StammkundePool>query()
  48 + .select("DISTINCT shop_id").eq("group_id", groupId))
  49 + ).orElse(new ArrayList<>());
  50 + List<ShopDTO> allShops = Optional.ofNullable(oopService.getAllShops(groupId)).orElse(new ArrayList<>());
  51 + Set<ShopInfo> set = new HashSet<>();
  52 + for (StammkundePool pool : pools) {
  53 + ShopDTO shop = oopService.shop(pool.getShopId());
  54 + if (Objects.nonNull(shop)) {
  55 + set.add(new ShopInfo(pool.getShopId(), shop.getShortName()));
  56 + } else {
  57 + set.add(new ShopInfo(pool.getShopId(), String.valueOf(pool.getShopId())));
  58 + }
  59 + }
  60 + for (ShopDTO allShop : allShops) {
  61 + set.add(new ShopInfo(allShop.getId(), allShop.getShortName()));
  62 + }
  63 + if (CollectionUtils.isEmpty(set)) {
  64 + return;
  65 + }
  66 + Timestamp day = DateUtil.getExpiredDay(nowDate, -1);
  67 + customerRetentionRatioService.removeByDate(DateUtil.startDate(day));
  68 + for (ShopInfo shop : set) {
  69 + extractingPerson(shop, day);
  70 + }
  71 + });
  72 + }
  73 +
  74 + private void extractingPerson(ShopInfo shop, Date nowDate) {
  75 + List<StammkundePool> pools = Optional.ofNullable(stammkundePoolService.list(Wrappers.<StammkundePool>query()
  76 + .select("DISTINCT adviser_id", "adviser_name").eq("shop_id", shop.getId()))
  77 + ).orElse(new ArrayList<>());
  78 + List<PostUserDTO> userDTOS = Optional.ofNullable(userService.getUserByRole(shop.getId(), RoleCode.FWGW)).orElse(new ArrayList<>());
  79 + Set<UserInfo> set = new HashSet<>();
  80 + for (StammkundePool pool : pools) {
  81 + set.add(new UserInfo(pool.getAdviserId(), pool.getAdviserName()));
49 82 }
50   - customerRetentionRatioService.removeByDate(DateUtil.startDate(nowDate));
51   - for (ShopDTO shop : allShops) {
52   - extractingPerson(shop, nowDate);
  83 + for (PostUserDTO pool : userDTOS) {
  84 + set.add(new UserInfo(pool.getUserId(), pool.getUserName()));
53 85 }
54   - }
55 86  
56   - private void extractingPerson(ShopDTO shop, Date nowDate) {
57   - List<PostUserDTO> userDTOS = userService.getUserByRole(shop.getId(), RoleCode.FWGW);
58   - if (CollectionUtils.isEmpty(userDTOS)) {
  87 + if (CollectionUtils.isEmpty(set)) {
59 88 return;
60 89 }
61 90 Timestamp expiredDay = DateUtil.getExpiredMonth(nowDate, -1);
... ... @@ -63,18 +92,20 @@ public class CustomerRetentionRatioBizService {
63 92 final LocalDate initialDay = DateUtil.date2LocalDate(monthEndDay);
64 93  
65 94 List<CustomerRetentionRatio> list = new ArrayList<>();
66   - for (PostUserDTO userDTO : userDTOS) {
  95 + for (UserInfo userInfo : set) {
67 96 CustomerRetentionRatio ratio = new CustomerRetentionRatio();
68 97 ratio.setDataDate(nowDate);
69 98 ratio.setDimensions(1);
70   - ratio.setUserId(userDTO.getUserId());
71   - ratio.setUserName(userDTO.getUserName());
  99 + ratio.setUserId(userInfo.getUserId());
  100 + ratio.setUserName(userInfo.getUserName());
72 101 ratio.setShopId(shop.getId());
73   - ratio.setShopName(shop.getShortName());
74   - StammkundePool pool = firstOne(userDTO.getUserId(), shop.getId());
  102 + ratio.setShopName(shop.getName());
  103 + StammkundePool pool = firstOne(userInfo.getUserId(), shop.getId());
75 104 if (Objects.isNull(pool)) {
76 105 ratio.setInitialNum(0);
77 106 ratio.setDefeatNum(0);
  107 + List<CustomerRetentionRatio> allZero = createAllZero(ratio);
  108 + list.addAll(allZero);
78 109 } else {
79 110 Date startDay = DateUtil.getMonthEndDay(pool.getActivationTime());
80 111 LocalDate acTime = DateUtil.date2LocalDate(startDay);
... ... @@ -82,25 +113,48 @@ public class CustomerRetentionRatioBizService {
82 113 if (startDay.after(nowDate)) {
83 114 startDay = nowDate;
84 115 }
85   - int initialNum = initialNum(userDTO.getUserId(), shop.getId(), startDay);
86   - int defeatNum = defeatNum(userDTO.getUserId(), shop.getId(), startDay);
  116 + int initialNum = initialNum(userInfo.getUserId(), shop.getId(), startDay);
87 117 ratio.setInitialNum(initialNum);
88   - ratio.setDefeatNum(defeatNum);
  118 + for (DefeatReasonEnum reasonEnum : DefeatReasonEnum.values()) {
  119 + CustomerRetentionRatio r = new CustomerRetentionRatio();
  120 + BeanUtils.copyProperties(ratio, r);
  121 + r.setType(reasonEnum);
  122 + r.setDefeatNum(defeatNum(userInfo.getUserId(), shop.getId(), startDay, reasonEnum));
  123 + list.add(r);
  124 + }
89 125 } else {
90   - int initialNum = initialNum(userDTO.getUserId(), shop.getId(), monthEndDay);
91   - int defeatNum = defeatNum(userDTO.getUserId(), shop.getId(), monthEndDay);
  126 + int initialNum = initialNum(userInfo.getUserId(), shop.getId(), monthEndDay);
92 127 ratio.setInitialNum(initialNum);
93   - ratio.setDefeatNum(defeatNum);
  128 + for (DefeatReasonEnum reasonEnum : DefeatReasonEnum.values()) {
  129 + CustomerRetentionRatio r = new CustomerRetentionRatio();
  130 + BeanUtils.copyProperties(ratio, r);
  131 + r.setType(reasonEnum);
  132 + r.setDefeatNum(defeatNum(userInfo.getUserId(), shop.getId(), monthEndDay, reasonEnum));
  133 + list.add(r);
  134 + }
94 135 }
95 136 }
96   - list.add(ratio);
97 137 }
98 138 customerRetentionRatioService.saveBatch(list);
99 139 }
100 140  
  141 + private List<CustomerRetentionRatio> createAllZero(CustomerRetentionRatio ratio) {
  142 + DefeatReasonEnum[] values = DefeatReasonEnum.values();
  143 + List<CustomerRetentionRatio> list = new ArrayList<>(values.length);
  144 + for (DefeatReasonEnum reasonEnum : values) {
  145 + CustomerRetentionRatio r = new CustomerRetentionRatio();
  146 + BeanUtils.copyProperties(ratio, r);
  147 + r.setType(reasonEnum);
  148 + list.add(r);
  149 + }
  150 + return list;
  151 + }
  152 +
101 153 private StammkundePool firstOne(Long userId, Long shopId) {
102 154 return stammkundePoolService.getOne(Wrappers.<StammkundePool>lambdaQuery()
103 155 .eq(Objects.nonNull(userId), StammkundePool::getAdviserId, userId)
  156 + .eq(StammkundePool::getPoolStatus, StammkundeStatusEnum.KUNDE)
  157 + .eq(StammkundePool::getAktiv, Boolean.TRUE)
104 158 .eq(StammkundePool::getShopId, shopId)
105 159 .orderByAsc(StammkundePool::getActivationTime)
106 160 .last(" limit 1")
... ... @@ -116,15 +170,102 @@ public class CustomerRetentionRatioBizService {
116 170 );
117 171 }
118 172  
119   - private int defeatNum(Long userId, Long shopId, Date expire) {
  173 + private int defeatNum(Long userId, Long shopId, Date expire, DefeatReasonEnum reason) {
120 174 Timestamp endDay = DateUtil.getExpiredDay(expire, 30);
121 175 return stammkundePoolService.count(Wrappers.<StammkundePool>lambdaQuery()
122 176 .eq(StammkundePool::getAdviserId, userId)
123 177 .eq(StammkundePool::getPoolStatus, StammkundeStatusEnum.KUNDE)
124 178 .eq(StammkundePool::getShopId, shopId)
  179 + .eq(StammkundePool::getReason, reason)
125 180 .lt(StammkundePool::getActivationTime, expire)
126 181 .le(StammkundePool::getRejectTime, endDay)
127 182  
128 183 );
129 184 }
  185 +
  186 + class UserInfo {
  187 + private Long userId;
  188 + private String userName;
  189 +
  190 + public UserInfo(Long userId, String userName) {
  191 + this.userId = userId;
  192 + this.userName = userName;
  193 + }
  194 +
  195 + public Long getUserId() {
  196 + return userId;
  197 + }
  198 +
  199 + public void setUserId(Long userId) {
  200 + this.userId = userId;
  201 + }
  202 +
  203 + public String getUserName() {
  204 + return userName;
  205 + }
  206 +
  207 + public void setUserName(String userName) {
  208 + this.userName = userName;
  209 + }
  210 +
  211 + @Override
  212 + public boolean equals(Object o) {
  213 + if (this == o) {
  214 + return true;
  215 + }
  216 + if (o == null || getClass() != o.getClass()) {
  217 + return false;
  218 + }
  219 + UserInfo userInfo = (UserInfo) o;
  220 + return Objects.equals(userId, userInfo.userId) && Objects.equals(userName, userInfo.userName);
  221 + }
  222 +
  223 + @Override
  224 + public int hashCode() {
  225 + return Objects.hash(userId, userName);
  226 + }
  227 + }
  228 +
  229 + class ShopInfo {
  230 + private Long id;
  231 + private String name;
  232 +
  233 + public ShopInfo(Long id, String name) {
  234 + this.id = id;
  235 + this.name = name;
  236 + }
  237 +
  238 + public Long getId() {
  239 + return id;
  240 + }
  241 +
  242 + public void setId(Long id) {
  243 + this.id = id;
  244 + }
  245 +
  246 + public String getName() {
  247 + return name;
  248 + }
  249 +
  250 + public void setName(String name) {
  251 + this.name = name;
  252 + }
  253 +
  254 + @Override
  255 + public boolean equals(Object o) {
  256 + if (this == o) {
  257 + return true;
  258 + }
  259 + if (o == null || getClass() != o.getClass()) {
  260 + return false;
  261 + }
  262 + ShopInfo shopInfo = (ShopInfo) o;
  263 + return Objects.equals(id, shopInfo.id) && Objects.equals(name, shopInfo.name);
  264 + }
  265 +
  266 + @Override
  267 + public int hashCode() {
  268 + return Objects.hash(id, name);
  269 + }
  270 + }
130 271 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/LeaveNeedDoBizService.java
... ... @@ -153,7 +153,8 @@ public class LeaveNeedDoBizService {
153 153 dto.setType(typeEnum);
154 154 LeaveNeedDo needDo = leaveNeedDoService.queryProcessableById(dto.getId());
155 155 BV.notNull(needDo, () -> "该条记录已处理或不存在,请刷新后重试");
156   - stammkundePoolService.reject(needDo.getUserId(), needDo.getShopId(), null);
  156 + stammkundePoolService.reject(needDo.getUserId(), needDo.getShopId(), null, DefeatReasonEnum.OT);
  157 +
157 158 dto.setAdviserId(needDo.getUserId());
158 159 if (AllocationTypeEnum.ONE.equals(typeEnum)) {
159 160 BV.notNull(dto.getUserId(), () -> "指定人员不能为空");
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AbstractCustomerService.java
... ... @@ -9,6 +9,8 @@ import cn.fw.valhalla.domain.db.customer.CustomerBaseInfo;
9 9 import cn.fw.valhalla.domain.db.customer.CustomerLoanInfo;
10 10 import cn.fw.valhalla.domain.db.pool.StammkundePool;
11 11 import cn.fw.valhalla.domain.dto.CustomerDetailDto;
  12 +import cn.fw.valhalla.domain.dto.StammkundeDto;
  13 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
12 14 import cn.fw.valhalla.domain.enums.StammkundeSourcesEnum;
13 15 import cn.fw.valhalla.domain.enums.StammkundeStatusEnum;
14 16 import cn.fw.valhalla.rpc.angel.InsurerRpcService;
... ... @@ -157,9 +159,9 @@ public abstract class AbstractCustomerService {
157 159 */
158 160 protected ShopDTO queryDealId(Long userId, String roleCOde) {
159 161 List<UserRoleDataRangeDTO> dataRange = userService.getUserRoleDataRange(userId, roleCOde);
160   - if (CollectionUtils.isEmpty(dataRange)) {
161   - return null;
162   - }
  162 + if (CollectionUtils.isEmpty(dataRange)) {
  163 + return null;
  164 + }
163 165 Long shopId = dataRange.get(0).getRangeValue();
164 166 ShopDTO shop = oopService.shop(shopId);
165 167 BV.isTrue(shop != null && BizTypeEnum.AFTER_SALE.getValue().equals(shop.getBizType()), "角色门店信息不正确");
... ... @@ -252,17 +254,14 @@ public abstract class AbstractCustomerService {
252 254 return customer.getId();
253 255 }
254 256  
255   - protected StammkundePool rejectAndNew(Customer customer, Long userId) {
256   - stammkundePoolService.reject(customer.getId(), customer.getGroupId());
  257 + protected StammkundePool rejectAndNew(StammkundeDto dto) {
  258 + stammkundePoolService.reject(dto);
257 259 StammkundePool stammkundePool = new StammkundePool();
258   - stammkundePool.setCustomerId(customer.getId());
259   - stammkundePool.setShopId(customer.getShopId());
260   - stammkundePool.setGroupId(customer.getGroupId());
261   - stammkundePool.setAdviserId(userId);
262   - UserInfoDTO user = userService.user(userId);
263   - if (Objects.nonNull(user)) {
264   - stammkundePool.setAdviserName(user.getUserName());
265   - }
  260 + stammkundePool.setCustomerId(dto.getCustomerId());
  261 + stammkundePool.setShopId(dto.getShopId());
  262 + stammkundePool.setGroupId(dto.getGroupId());
  263 + stammkundePool.setAdviserId(dto.getNewUserId());
  264 + stammkundePool.setAdviserName(dto.getNewUserName());
266 265 return stammkundePool;
267 266 }
268 267  
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/AccidentPoolBizService.java
... ... @@ -104,6 +104,7 @@ public class AccidentPoolBizService {
104 104 CustomerCluePool cluePool = customerCluePoolService.queryByPlateNo(plateNo, pool.getGroupId(), FollowTypeEnum.AC);
105 105 if (Objects.nonNull(cluePool) && ClueStatusEnum.ONGOING.equals(cluePool.getClueStatus())) {
106 106 cluePool.setClueStatus(ClueStatusEnum.FAILURE);
  107 + cluePool.setCloseTime(new Date());
107 108 customerCluePoolService.updateById(cluePool);
108 109 clearTask(cluePool.getId(), cluePool.getGroupId());
109 110 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerBizService.java
... ... @@ -349,10 +349,10 @@ public class CustomerBizService extends AbstractCustomerService {
349 349 return;
350 350 }
351 351 AffiliationRecord entity = createEntity(detailDto);
352   - entity.setReason(DefeatReasonEnum.GIVE_UP.getName());
  352 + entity.setReason(DefeatReasonEnum.GU.getName());
353 353 affiliationRecordService.save(entity);
354 354 publicPoolService.save(publicPool);
355   - stammkundePoolService.reject(customerId, detailDto.getGroupId());
  355 + stammkundePoolService.reject(customerId, detailDto.getGroupId(), DefeatReasonEnum.GU);
356 356 PublicPoolEvent poolEvent = new PublicPoolEvent(customerId, detailDto.getGroupId());
357 357 eventPublisher.publishEvent(poolEvent);
358 358 }
... ... @@ -390,11 +390,19 @@ public class CustomerBizService extends AbstractCustomerService {
390 390 if (!updated) {
391 391 return;
392 392 }
  393 + DefeatReasonEnum reasonEnum = DefeatReasonEnum.OT;
  394 + if (FollowTypeEnum.FM.equals(task.getType())) {
  395 + reasonEnum = DefeatReasonEnum.FM;
  396 + }
  397 + if (FollowTypeEnum.RM.equals(task.getType())) {
  398 + reasonEnum = DefeatReasonEnum.RM;
  399 + }
393 400 AffiliationRecord entity = createEntity(detailDto);
394   - entity.setReason(DefeatReasonEnum.SYS.getName());
  401 + entity.setReason(reasonEnum.getName());
395 402 affiliationRecordService.save(entity);
396 403 publicPoolService.save(publicPool);
397   - stammkundePoolService.reject(task.getCustomerId(), task.getGroupId());
  404 + stammkundePoolService.reject(task.getCustomerId(), task.getGroupId(), reasonEnum);
  405 +
398 406 PublicPoolEvent poolEvent = new PublicPoolEvent(task.getCustomerId(), task.getGroupId());
399 407 eventPublisher.publishEvent(poolEvent);
400 408 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java
... ... @@ -22,11 +22,13 @@ import cn.fw.valhalla.domain.db.pool.CustomerCluePool;
22 22 import cn.fw.valhalla.domain.db.pool.StammkundePool;
23 23 import cn.fw.valhalla.domain.dto.CustomerChangeDto;
24 24 import cn.fw.valhalla.domain.dto.CustomerDetailDto;
  25 +import cn.fw.valhalla.domain.dto.StammkundeDto;
25 26 import cn.fw.valhalla.domain.enums.*;
26 27 import cn.fw.valhalla.domain.vo.customer.CustomerChangeInfoVO;
27 28 import cn.fw.valhalla.domain.vo.customer.CustomerChangeQrCodeVO;
28 29 import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO;
29 30 import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
  31 +import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
30 32 import cn.fw.valhalla.rpc.erp.dto.UserRoleDataRangeDTO;
31 33 import cn.fw.valhalla.rpc.member.MemberRpcService;
32 34 import cn.fw.valhalla.rpc.member.dto.MemberUserDTO;
... ... @@ -201,7 +203,7 @@ public class CustomerChangeBizService extends AbstractCustomerService {
201 203 //档案和行驶证不一致 作废旧档案 更新档案
202 204 boolean bool = saveDto.getId().equals(saveDto.getMotoId());
203 205 if (!bool) {
204   - stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId());
  206 + stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId(), DefeatReasonEnum.OT);
205 207 customerService.forbidden(saveDto.getMotoId());
206 208 }
207 209 Customer customer = customerService.queryById(saveDto.getId());
... ... @@ -214,7 +216,7 @@ public class CustomerChangeBizService extends AbstractCustomerService {
214 216 customer.setYn(Boolean.TRUE);
215 217 nid = this.edit(customer);
216 218 } else {
217   - stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId());
  219 + stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId(), DefeatReasonEnum.OT);
218 220 customerService.forbidden(saveDto.getMotoId());
219 221 Customer customer = new Customer();
220 222 BeanUtils.copyProperties(saveDto, customer);
... ... @@ -225,7 +227,7 @@ public class CustomerChangeBizService extends AbstractCustomerService {
225 227 } else {
226 228 //vin有档案 行驶证车主和vin档案车主一致的情况app直接替换车牌不会到这个流程
227 229 if (Objects.nonNull(saveDto.getId())) {
228   - stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId());
  230 + stammkundePoolService.reject(saveDto.getId(), saveDto.getGroupId(), DefeatReasonEnum.OT);
229 231 customerService.forbidden(saveDto.getId());
230 232 saveDto.setId(null);
231 233 }
... ... @@ -294,8 +296,11 @@ public class CustomerChangeBizService extends AbstractCustomerService {
294 296 .eq(Customer::getId, changeAdviserReq.getCusId()));
295 297 BV.isTrue(updated, () -> "变更档案服务顾问失败,请重试");
296 298 if (Objects.nonNull(customer.getAdviserId()) && Objects.nonNull(customer.getShopId())) {
  299 + Integer reason = changeAdviserReq.getReason();
  300 + DefeatReasonEnum reasonEnum = DefeatReasonEnum.ofValue(reason);
  301 + BV.notNull(reasonEnum, () -> "档案变更原因不正确");
297 302 AffiliationRecord entity = createEntity(customer, adviserId, shopId);
298   - entity.setReason(DefeatReasonEnum.SYS.getName());
  303 + entity.setReason(reasonEnum.getName());
299 304 affiliationRecordService.save(entity);
300 305 StammkundePool pool = stammkundePoolService.getOne(Wrappers.<StammkundePool>lambdaQuery()
301 306 .eq(StammkundePool::getCustomerId, customer.getId())
... ... @@ -304,7 +309,23 @@ public class CustomerChangeBizService extends AbstractCustomerService {
304 309 .eq(StammkundePool::getAktiv, Boolean.TRUE)
305 310 );
306 311 if (Objects.nonNull(pool)) {
307   - stammkundePoolService.reject(customer.getId(), customer.getGroupId());
  312 + StammkundeDto stammkundeDto = new StammkundeDto();
  313 + stammkundeDto.setCustomerId(customer.getId());
  314 + stammkundeDto.setReason(reasonEnum);
  315 + stammkundeDto.setShopId(customer.getShopId());
  316 + UserInfoDTO user = userService.user(adviserId);
  317 + stammkundeDto.setNewUserId(adviserId);
  318 + if (Objects.nonNull(user)) {
  319 + stammkundeDto.setNewUserName(user.getUserName());
  320 + }
  321 + ShopDTO shop = oopService.shop(shopId);
  322 + stammkundeDto.setNewShopId(shopId);
  323 + if (Objects.nonNull(shop)) {
  324 + stammkundeDto.setNewShopName(shop.getShortName());
  325 + }
  326 + stammkundeDto.setGroupId(customer.getGroupId());
  327 +
  328 + stammkundePoolService.reject(stammkundeDto);
308 329 }
309 330 }
310 331 if (Objects.isNull(customer.getAdviserId()) && Objects.isNull(customer.getShopId())) {
... ... @@ -342,13 +363,31 @@ public class CustomerChangeBizService extends AbstractCustomerService {
342 363 userDTO = userList.get(1);
343 364 }
344 365 customer.setAdviserId(userDTO.getUserId());
345   - customer.setShopId(customer.getShopId());
346 366 customerService.updateById(customer);
347   -
  367 + DefeatReasonEnum reasonEnum = DefeatReasonEnum.OT;
  368 + if (FollowTypeEnum.FM.equals(task.getType())) {
  369 + reasonEnum = DefeatReasonEnum.FM;
  370 + }
  371 + if (FollowTypeEnum.RM.equals(task.getType())) {
  372 + reasonEnum = DefeatReasonEnum.RM;
  373 + }
348 374 AffiliationRecord entity = createEntity(customer, userDTO.getUserId(), customer.getShopId());
349   - entity.setReason(DefeatReasonEnum.OVERDUE.getName());
  375 + entity.setReason(reasonEnum.getName());
350 376 affiliationRecordService.save(entity);
351   - StammkundePool stammkundePool = rejectAndNew(customer, userDTO.getUserId());
  377 + StammkundeDto stammkundeDto = new StammkundeDto();
  378 + stammkundeDto.setCustomerId(customer.getId());
  379 + stammkundeDto.setReason(reasonEnum);
  380 + stammkundeDto.setShopId(customer.getShopId());
  381 + stammkundeDto.setNewUserId(userDTO.getUserId());
  382 + stammkundeDto.setNewUserName(userDTO.getUserName());
  383 + ShopDTO shop = oopService.shop(customer.getShopId());
  384 + stammkundeDto.setNewShopId(customer.getShopId());
  385 + if (Objects.nonNull(shop)) {
  386 + stammkundeDto.setNewShopName(shop.getShortName());
  387 + }
  388 + stammkundeDto.setGroupId(customer.getGroupId());
  389 +
  390 + StammkundePool stammkundePool = rejectAndNew(stammkundeDto);
352 391 stammkundePool.setSources(StammkundeSourcesEnum.REDISTRIBUTION);
353 392 stammkundePool.setPoolStatus(StammkundeStatusEnum.TWICE);
354 393 stammkundePool.setAktiv(Boolean.FALSE);
... ... @@ -476,7 +515,7 @@ public class CustomerChangeBizService extends AbstractCustomerService {
476 515 }
477 516  
478 517 private void create(Customer customer, Long adviserId, boolean publicPool) {
479   - StammkundePool stammkundePool = rejectAndNew(customer, adviserId);
  518 + StammkundePool stammkundePool = createSimpleInfo(customer, adviserId);
480 519 stammkundePool.setSources(StammkundeSourcesEnum.SYSTEMATIC);
481 520 if (publicPool) {
482 521 stammkundePool.setSources(StammkundeSourcesEnum.PUBLIC_POOL);
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/PoolBizService.java
... ... @@ -9,10 +9,7 @@ import cn.fw.valhalla.domain.db.pool.PublicPool;
9 9 import cn.fw.valhalla.domain.dto.CustomerCluePoolDTO;
10 10 import cn.fw.valhalla.domain.dto.FollowPoolDTO;
11 11 import cn.fw.valhalla.domain.dto.StammkundePoolDTO;
12   -import cn.fw.valhalla.domain.enums.ClueStatusEnum;
13   -import cn.fw.valhalla.domain.enums.CusTagEnum;
14   -import cn.fw.valhalla.domain.enums.CustomerChangeTypeEnum;
15   -import cn.fw.valhalla.domain.enums.TaskDefeatTypeEnum;
  12 +import cn.fw.valhalla.domain.enums.*;
16 13 import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO;
17 14 import cn.fw.valhalla.domain.query.FollowPoolQueryVO;
18 15 import cn.fw.valhalla.domain.query.PoolQuery;
... ... @@ -23,6 +20,8 @@ import cn.fw.valhalla.rpc.erp.UserService;
23 20 import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
24 21 import cn.fw.valhalla.rpc.oop.OopService;
25 22 import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
  23 +import cn.fw.valhalla.rpc.order.OrderRpcService;
  24 +import cn.fw.valhalla.rpc.order.dto.NewCarOrderInfo;
26 25 import cn.fw.valhalla.service.data.*;
27 26 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
28 27 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
... ... @@ -55,6 +54,7 @@ public class PoolBizService {
55 54 private final OopService oopService;
56 55 private final UserService userService;
57 56 private final AffiliationRecordService affiliationRecordService;
  57 + private final OrderRpcService orderRpcService;
58 58  
59 59  
60 60 /**
... ... @@ -183,6 +183,8 @@ public class PoolBizService {
183 183 CustomerClueSummaryVO vo = new CustomerClueSummaryVO();
184 184 vo.setCompleteNum(cluePoolService.completeNum(queryVO));
185 185 vo.setDefeatNum(cluePoolService.defeatNum(queryVO));
  186 + vo.setOnGoingNum(cluePoolService.onGoingNum(queryVO));
  187 + vo.setClosedNum(vo.getCompleteNum() + vo.getDefeatNum());
186 188 return vo;
187 189 }
188 190  
... ... @@ -232,6 +234,9 @@ public class PoolBizService {
232 234 CustomerCluePoolVO vo = new CustomerCluePoolVO();
233 235 BeanUtils.copyProperties(poolDTO, vo);
234 236 vo.setStatus(poolDTO.getClueStatus());
  237 + if (Objects.nonNull(poolDTO.getLoanExpires())) {
  238 + vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
  239 + }
235 240 if (ClueStatusEnum.COMPLETE.getValue().equals(poolDTO.getClueStatus()) && scope.contains(poolDTO.getFinishShopId())) {
236 241 vo.setStatus(ClueStatusEnum.COMPLETE.getValue());
237 242 }
... ... @@ -239,6 +244,14 @@ public class PoolBizService {
239 244 (Objects.nonNull(poolDTO.getFinishShopId()) && !scope.contains(poolDTO.getFinishShopId()))) {
240 245 vo.setStatus(ClueStatusEnum.FAILURE.getValue());
241 246 }
  247 + //首保
  248 + if (FollowTypeEnum.FM.getValue().equals(poolDTO.getType())) {
  249 + NewCarOrderInfo orderInfo = orderRpcService.getOrderInfo(poolDTO.getFrameNo());
  250 + if (Objects.nonNull(orderInfo)) {
  251 + ShopDTO shop = oopService.shop(orderInfo.getShopId());
  252 + vo.setSaleShop(Objects.nonNull(shop) ? shop.getShortName() : "");
  253 + }
  254 + }
242 255 return vo;
243 256 }
244 257  
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/setting/strategy/AbstractSettingStrategy.java
... ... @@ -148,7 +148,7 @@ public abstract class AbstractSettingStrategy implements SettingStrategy {
148 148 detail.setSettingId(setting.getId());
149 149 detail.setId(settingDTO.getId());
150 150 detail.setDetailValue(settingDTO.getDetailValue());
151   - if (SettingTypeEnum.REVISE_RATIO.getValue().equals(settingDTO.getType())) {
  151 + if (SettingTypeEnum.REVISE_RATIO.getValue().equals(settingDTO.getType()) || SettingTypeEnum.RETENTION_RATIO.getValue().equals(settingDTO.getType())) {
152 152 detail.setDetailValue(settingDTO.getDetailValue() * 100);
153 153 }
154 154 detail.setType(SettingTypeEnum.ofValue(settingDTO.getType()));
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/CustomerCluePoolService.java
... ... @@ -78,4 +78,11 @@ public interface CustomerCluePoolService extends IService&lt;CustomerCluePool&gt; {
78 78 * @return
79 79 */
80 80 Long defeatNum(CustomerCluePoolQueryVO queryVO);
  81 +
  82 + /**
  83 + * 进行中的数量
  84 + * @param queryVO
  85 + * @return
  86 + */
  87 + Long onGoingNum(CustomerCluePoolQueryVO queryVO);
81 88 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/StammkundePoolService.java
1 1 package cn.fw.valhalla.service.data;
2 2  
3 3 import cn.fw.valhalla.domain.db.pool.StammkundePool;
  4 +import cn.fw.valhalla.domain.dto.StammkundeDto;
4 5 import cn.fw.valhalla.domain.dto.StammkundePoolDTO;
  6 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
5 7 import cn.fw.valhalla.domain.query.StammkundePoolQueryVO;
6 8 import com.baomidou.mybatisplus.extension.service.IService;
7 9  
... ... @@ -15,13 +17,21 @@ import java.util.List;
15 17 */
16 18 public interface StammkundePoolService extends IService<StammkundePool> {
17 19 /**
18   - * 作废有效档案
  20 + * 作废有效档案(没有新的顾问接手档案的情况)
19 21 *
20 22 * @param customerId
21 23 * @param groupId
  24 + * @param reason
  25 + * @return
  26 + */
  27 + boolean reject(Long customerId, Long groupId, DefeatReasonEnum reason);
  28 +
  29 + /**
  30 + * 作废档案
  31 + * @param dto
22 32 * @return
23 33 */
24   - boolean reject(Long customerId, Long groupId);
  34 + boolean reject(StammkundeDto dto);
25 35  
26 36 /**
27 37 * 作废有效档案
... ... @@ -29,9 +39,10 @@ public interface StammkundePoolService extends IService&lt;StammkundePool&gt; {
29 39 * @param userId
30 40 * @param shopId
31 41 * @param groupId
  42 + * @param reason
32 43 * @return
33 44 */
34   - boolean reject(Long userId, Long shopId, Long groupId);
  45 + boolean reject(Long userId, Long shopId, Long groupId, DefeatReasonEnum reason);
35 46  
36 47 /**
37 48 * 激活档案
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/CustomerCluePoolServiceImpl.java
... ... @@ -81,4 +81,9 @@ public class CustomerCluePoolServiceImpl extends ServiceImpl&lt;CustomerCluePoolMap
81 81 public Long defeatNum(CustomerCluePoolQueryVO queryVO) {
82 82 return Optional.ofNullable(getBaseMapper().defeatNum(queryVO)).orElse(0L);
83 83 }
  84 +
  85 + @Override
  86 + public Long onGoingNum(CustomerCluePoolQueryVO queryVO) {
  87 + return Optional.ofNullable(getBaseMapper().onGoingNum(queryVO)).orElse(0L);
  88 + }
84 89 }
... ...
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/data/impl/StammkundePoolServiceImpl.java
... ... @@ -2,7 +2,9 @@ package cn.fw.valhalla.service.data.impl;
2 2  
3 3 import cn.fw.valhalla.dao.mapper.StammkundePoolMapper;
4 4 import cn.fw.valhalla.domain.db.pool.StammkundePool;
  5 +import cn.fw.valhalla.domain.dto.StammkundeDto;
5 6 import cn.fw.valhalla.domain.dto.StammkundePoolDTO;
  7 +import cn.fw.valhalla.domain.enums.DefeatReasonEnum;
6 8 import cn.fw.valhalla.domain.enums.StammkundeStatusEnum;
7 9 import cn.fw.valhalla.domain.query.StammkundePoolQueryVO;
8 10 import cn.fw.valhalla.service.data.StammkundePoolService;
... ... @@ -21,10 +23,11 @@ import java.util.*;
21 23 @Service
22 24 public class StammkundePoolServiceImpl extends ServiceImpl<StammkundePoolMapper, StammkundePool> implements StammkundePoolService {
23 25 @Override
24   - public boolean reject(Long customerId, Long groupId) {
  26 + public boolean reject(Long customerId, Long groupId, DefeatReasonEnum reason) {
25 27 return this.update(Wrappers.<StammkundePool>lambdaUpdate()
26 28 .set(StammkundePool::getAktiv, Boolean.FALSE)
27 29 .set(StammkundePool::getRejectTime, new Date())
  30 + .set(StammkundePool::getReason, reason)
28 31 .eq(StammkundePool::getCustomerId, customerId)
29 32 .eq(StammkundePool::getGroupId, groupId)
30 33 .isNull(StammkundePool::getRejectTime)
... ... @@ -32,10 +35,27 @@ public class StammkundePoolServiceImpl extends ServiceImpl&lt;StammkundePoolMapper,
32 35 }
33 36  
34 37 @Override
35   - public boolean reject(Long userId, Long shopId, Long groupId) {
  38 + public boolean reject(StammkundeDto dto) {
36 39 return this.update(Wrappers.<StammkundePool>lambdaUpdate()
37 40 .set(StammkundePool::getAktiv, Boolean.FALSE)
38 41 .set(StammkundePool::getRejectTime, new Date())
  42 + .set(StammkundePool::getReason, dto.getReason())
  43 + .set(StammkundePool::getNewUserId, dto.getNewUserId())
  44 + .set(StammkundePool::getNewUserName, dto.getNewUserName())
  45 + .set(StammkundePool::getNewShopId, dto.getNewShopId())
  46 + .set(StammkundePool::getNewShopName, dto.getNewShopName())
  47 + .eq(StammkundePool::getCustomerId, dto.getCustomerId())
  48 + .eq(StammkundePool::getGroupId, dto.getGroupId())
  49 + .isNull(StammkundePool::getRejectTime)
  50 + );
  51 + }
  52 +
  53 + @Override
  54 + public boolean reject(Long userId, Long shopId, Long groupId, DefeatReasonEnum reason) {
  55 + return this.update(Wrappers.<StammkundePool>lambdaUpdate()
  56 + .set(StammkundePool::getAktiv, Boolean.FALSE)
  57 + .set(StammkundePool::getRejectTime, new Date())
  58 + .set(StammkundePool::getReason, reason)
39 59 .eq(StammkundePool::getAdviserId, userId)
40 60 .eq(StammkundePool::getShopId, shopId)
41 61 .eq(Objects.nonNull(groupId), StammkundePool::getGroupId, groupId)
... ...
... ... @@ -112,7 +112,7 @@
112 112 <dependency>
113 113 <groupId>cn.fw</groupId>
114 114 <artifactId>fw-valhalla-sdk</artifactId>
115   - <version>1.1.0</version>
  115 + <version>1.1.1</version>
116 116 </dependency>
117 117 <dependency>
118 118 <groupId>cn.fw</groupId>
... ...