d1659148
张志伟
✨ 战败池 100%
|
1
2
3
|
package cn.fw.valhalla.service.bus.follow;
import cn.fw.common.page.AppPage;
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
4
|
import cn.fw.common.web.auth.LoginAuthBean;
|
2c93da14
张志伟
✨ 战败池 100%
|
5
|
import cn.fw.valhalla.common.utils.DateUtil;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
6
|
import cn.fw.valhalla.common.utils.StringUtils;
|
abc1b038
张志伟
|
7
|
import cn.fw.valhalla.domain.db.customer.AffiliationRecord;
|
b27b4375
张志伟
|
8
|
import cn.fw.valhalla.domain.dto.*;
|
886c770a
张志伟
|
9
|
import cn.fw.valhalla.domain.enums.*;
|
8c7566e0
张志伟
|
10
|
import cn.fw.valhalla.domain.query.*;
|
cc14a87c
张志伟
|
11
|
import cn.fw.valhalla.domain.vo.AppPageVO;
|
fdf7fb2f
张志伟
|
12
|
import cn.fw.valhalla.domain.vo.pool.*;
|
3fc19e59
张志伟
升级erpsdk
|
13
|
import cn.fw.valhalla.rpc.ehr.EhrRpcService;
|
d1659148
张志伟
✨ 战败池 100%
|
14
|
import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
|
d1659148
张志伟
✨ 战败池 100%
|
15
16
|
import cn.fw.valhalla.rpc.oop.OopService;
import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
|
886c770a
张志伟
|
17
18
|
import cn.fw.valhalla.rpc.order.OrderRpcService;
import cn.fw.valhalla.rpc.order.dto.NewCarOrderInfo;
|
cacb1a42
张志伟
|
19
|
import cn.fw.valhalla.service.data.*;
|
d1659148
张志伟
✨ 战败池 100%
|
20
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
7c9f5c47
张志伟
|
21
|
import lombok.RequiredArgsConstructor;
|
d1659148
张志伟
✨ 战败池 100%
|
22
|
import lombok.extern.slf4j.Slf4j;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
23
|
import org.springframework.beans.BeanUtils;
|
d1659148
张志伟
✨ 战败池 100%
|
24
25
|
import org.springframework.stereotype.Service;
|
e7aefdc4
张志伟
|
26
|
import java.time.LocalDate;
|
ee7c5ab4
张志伟
|
27
|
import java.util.*;
|
abc1b038
张志伟
|
28
|
import java.util.stream.Collectors;
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
29
30
|
import static cn.fw.common.businessvalidator.Validator.BV;
|
d1659148
张志伟
✨ 战败池 100%
|
31
32
33
34
35
36
37
38
39
|
/**
* @author : kurisu
* @className : FollowPoolBizService
* @description : 跟进池服务
* @date: 2020-09-23 15:30
*/
@Slf4j
@Service
|
7c9f5c47
张志伟
|
40
41
|
@RequiredArgsConstructor
public class PoolBizService {
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
42
|
private final PublicPoolService publicPoolService;
|
39e85d50
张志伟
|
43
|
private final StammkundePoolService stammkundePoolService;
|
b27b4375
张志伟
|
44
|
private final PublicCluePoolService publicCluePoolService;
|
d1659148
张志伟
✨ 战败池 100%
|
45
|
private final OopService oopService;
|
3fc19e59
张志伟
升级erpsdk
|
46
|
private final EhrRpcService ehrRpcService;
|
abc1b038
张志伟
|
47
|
private final AffiliationRecordService affiliationRecordService;
|
886c770a
张志伟
|
48
|
private final OrderRpcService orderRpcService;
|
d4e6d3ec
张志伟
feature(*): 跟进池接口调整
|
49
|
private final ClueTaskService clueTaskService;
|
bd5cb2d8
张志伟
feature(*): 修复成交池查询
|
50
|
private final PubCluePoolService pubCluePoolService;
|
d4e6d3ec
张志伟
feature(*): 跟进池接口调整
|
51
|
private final FollowClueService followClueService;
|
d1659148
张志伟
✨ 战败池 100%
|
52
|
|
d1659148
张志伟
✨ 战败池 100%
|
53
|
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
54
|
/**
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
55
56
|
* 跟进池
*
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
57
58
59
|
* @param queryVO
* @return
*/
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
60
61
|
public AppPage<FollowPoolListVO> followList(LoginAuthBean user, FollowPoolQueryVO queryVO) {
prepareParams(user, queryVO);
|
cc14a87c
张志伟
|
62
|
AppPageVO<FollowPoolListVO> page = AppPageVO.init(queryVO);
|
bd5cb2d8
张志伟
feature(*): 修复成交池查询
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
List<FollowPoolDTO> list;
if (FollowTypeEnum.PL.getValue().equals(queryVO.getType())) {
final long total = pubCluePoolService.followListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
list = pubCluePoolService.followList(queryVO);
} else {
final long total = clueTaskService.followListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
list = clueTaskService.followList(queryVO);
|
cc14a87c
张志伟
|
78
|
}
|
bd5cb2d8
张志伟
feature(*): 修复成交池查询
|
79
|
|
2c93da14
张志伟
✨ 战败池 100%
|
80
81
|
List<FollowPoolListVO> followList = new ArrayList<>();
for (FollowPoolDTO followPoolDTO : list) {
|
abc1b038
张志伟
|
82
|
FollowPoolListVO vo = trans2FollowPool(followPoolDTO);
|
2c93da14
张志伟
✨ 战败池 100%
|
83
84
|
followList.add(vo);
}
|
2c93da14
张志伟
✨ 战败池 100%
|
85
86
87
88
|
page.setData(followList);
return page;
}
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
89
90
91
92
93
94
|
/**
* 公共池
*
* @param queryVO
* @return
*/
|
41a2b42a
张志伟
|
95
|
public AppPage<PublicPoolVO> publicList(LoginAuthBean currentUser, PublicPoolQueryVO queryVO) {
|
652ffd0e
张志伟
|
96
97
98
99
100
101
102
103
104
105
|
if (!Boolean.TRUE.equals(queryVO.getFromReport())) {
List<AffiliationRecord> affiliationRecordList = Optional.ofNullable(affiliationRecordService.list(Wrappers.<AffiliationRecord>lambdaQuery()
.eq(AffiliationRecord::getType, CustomerChangeTypeEnum.DEFEAT)
.eq(AffiliationRecord::getOriginUserId, currentUser.getUserId())
.ge(AffiliationRecord::getDefeatTime, DateUtil.getNowExpiredMonth(-6))
)).orElse(new ArrayList<>());
List<Long> custIds = affiliationRecordList.stream().map(AffiliationRecord::getCustomerId).distinct().collect(Collectors.toList());
if (custIds.size() > 0) {
queryVO.setIgnoreCustIds(custIds);
}
|
b6b3ea86
张志伟
|
106
107
|
}
|
cc14a87c
张志伟
|
108
|
AppPageVO<PublicPoolVO> page = AppPageVO.init(queryVO);
|
1d36107f
张志伟
|
109
110
|
Long count = publicPoolService.publicListCount(queryVO);
if (count <= 0) {
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
111
112
|
return page;
}
|
1d36107f
张志伟
|
113
114
115
|
List<PublicPoolVO> appList = new ArrayList<>();
List<PublicPoolDTO> list = publicPoolService.publicList(queryVO);
for (PublicPoolDTO dto : list) {
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
116
|
PublicPoolVO vo = new PublicPoolVO();
|
1d36107f
张志伟
|
117
118
119
120
121
122
123
124
125
126
127
128
129
|
BeanUtils.copyProperties(dto, vo);
PublicPoolTypeEnum typeEnum = PublicPoolTypeEnum.ofValue(dto.getType());
if (Objects.nonNull(typeEnum)) {
vo.setTypeDesc(typeEnum.getName());
}
if (StringUtils.isEmpty(dto.getTags())) {
vo.setMaintainCard(Boolean.FALSE);
vo.setWarrantyCard(Boolean.FALSE);
} else {
vo.setMaintainCard(dto.getTags().contains(CusTagEnum.MAINTAIN_CARD.getValue()));
vo.setWarrantyCard(dto.getTags().contains(CusTagEnum.QUA_ASS_CARD.getValue()));
}
appList.add(vo);
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
130
|
}
|
88ddf741
张志伟
|
131
|
page.setTotal(count);
|
1d36107f
张志伟
|
132
|
page.setData(appList);
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
133
134
135
|
return page;
}
|
39e85d50
张志伟
|
136
137
|
/**
* 保有客池
|
cc14a87c
张志伟
|
138
|
*
|
39e85d50
张志伟
|
139
140
141
142
143
144
|
* @param user
* @param queryVO
* @return
*/
public AppPage<StammkundePoolVO> stammkundeList(LoginAuthBean user, StammkundePoolQueryVO queryVO) {
prepareParams(user, queryVO);
|
cc14a87c
张志伟
|
145
146
147
148
149
150
|
AppPageVO<StammkundePoolVO> page = AppPageVO.init(queryVO);
long total = stammkundePoolService.stammkundeListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
|
39e85d50
张志伟
|
151
152
153
154
155
156
|
List<StammkundePoolDTO> list = stammkundePoolService.stammkundeList(queryVO);
List<StammkundePoolVO> appList = new ArrayList<>();
for (StammkundePoolDTO dto : list) {
StammkundePoolVO vo = trans2StaPool(dto);
appList.add(vo);
}
|
39e85d50
张志伟
|
157
158
159
|
page.setData(appList);
return page;
}
|
2c93da14
张志伟
✨ 战败池 100%
|
160
|
|
cacb1a42
张志伟
|
161
162
|
/**
* 客户线索池
|
cc14a87c
张志伟
|
163
|
*
|
cacb1a42
张志伟
|
164
165
166
167
168
169
|
* @param queryVO
* @return
*/
public AppPage<CustomerCluePoolVO> clueList(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
|
14a1148d
张志伟
|
170
171
172
|
if (ClueStatusEnum.ONGOING.getValue().equals(queryVO.getStatus())) {
queryVO.setCloseTime(null);
}
|
fdf7fb2f
张志伟
|
173
|
AppPageVO<CustomerCluePoolVO> page = AppPageVO.init(queryVO);
|
1943d0bc
张志伟
feature(*): 公共线索池
|
174
|
long total = followClueService.clueListCount(queryVO);
|
fdf7fb2f
张志伟
|
175
176
177
178
|
if (total <= 0) {
return page;
}
page.setTotal(total);
|
ee7c5ab4
张志伟
|
179
|
final HashSet<Long> scope = new HashSet<>(queryVO.getScope());
|
34b20e3a
张志伟
|
180
|
List<FollowClueDTO> list = followClueService.clueList(queryVO);
|
cacb1a42
张志伟
|
181
|
List<CustomerCluePoolVO> appList = new ArrayList<>();
|
34b20e3a
张志伟
|
182
|
for (FollowClueDTO dto : list) {
|
ee7c5ab4
张志伟
|
183
|
CustomerCluePoolVO vo = trans2CluePool(dto, scope);
|
cacb1a42
张志伟
|
184
185
|
appList.add(vo);
}
|
cacb1a42
张志伟
|
186
|
page.setData(appList);
|
ebdbea07
张志伟
|
187
|
return page;
|
cacb1a42
张志伟
|
188
189
|
}
|
fdf7fb2f
张志伟
|
190
191
|
/**
* 线索池概况
|
ee7c5ab4
张志伟
|
192
|
*
|
fdf7fb2f
张志伟
|
193
194
195
196
197
198
199
200
|
* @param queryVO
* @return
*/
public CustomerClueSummaryVO summary(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
CustomerClueSummaryVO vo = new CustomerClueSummaryVO();
|
1943d0bc
张志伟
feature(*): 公共线索池
|
201
202
203
|
vo.setCompleteNum(followClueService.completeNum(queryVO));
vo.setDefeatNum(followClueService.defeatNum(queryVO));
vo.setOnGoingNum(followClueService.onGoingNum(queryVO));
|
3015fc0c
张志伟
|
204
|
vo.setClosedNum(vo.getCompleteNum() + vo.getDefeatNum());
|
fdf7fb2f
张志伟
|
205
206
207
|
return vo;
}
|
b27b4375
张志伟
|
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
/**
* 公共客户线索池
*
* @param queryVO
* @return
*/
public AppPage<PublicCluePoolVO> publicClueList(PublicCluePoolQueryVO queryVO, LoginAuthBean user) {
prepareParams(user, queryVO);
AppPageVO<PublicCluePoolVO> page = AppPageVO.init(queryVO);
long total = publicCluePoolService.publicCluePoolListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
List<PublicCluePoolDTO> list = publicCluePoolService.publicCluePoolList(queryVO);
List<PublicCluePoolVO> appList = new ArrayList<>();
for (PublicCluePoolDTO dto : list) {
PublicCluePoolVO vo = new PublicCluePoolVO();
BeanUtils.copyProperties(dto, vo);
if (StringUtils.isEmpty(dto.getTags())) {
vo.setMaintainCard(Boolean.FALSE);
vo.setWarrantyCard(Boolean.FALSE);
} else {
vo.setMaintainCard(dto.getTags().contains(CusTagEnum.MAINTAIN_CARD.getValue()));
vo.setWarrantyCard(dto.getTags().contains(CusTagEnum.QUA_ASS_CARD.getValue()));
}
if (Objects.nonNull(dto.getBuyDate())) {
LocalDate buyDate = DateUtil.date2LocalDate(dto.getBuyDate());
long days = LocalDate.now().toEpochDay() - buyDate.toEpochDay();
double years = Math.ceil(days / 365.0);
vo.setAgeLimit(Math.round(years));
}
appList.add(vo);
}
page.setData(appList);
return page;
}
|
d4e6d3ec
张志伟
feature(*): 跟进池接口调整
|
247
248
|
/**
* 跟进池数据转换
|
1943d0bc
张志伟
feature(*): 公共线索池
|
249
|
*
|
d4e6d3ec
张志伟
feature(*): 跟进池接口调整
|
250
251
252
|
* @param poolDTO
* @return
*/
|
abc1b038
张志伟
|
253
|
private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) {
|
d1659148
张志伟
✨ 战败池 100%
|
254
|
FollowPoolListVO vo = new FollowPoolListVO();
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
255
|
BeanUtils.copyProperties(poolDTO, vo);
|
e746dba1
张志伟
|
256
|
vo.setFollower(poolDTO.getFollowUserName());
|
e0dd8097
张志伟
|
257
|
if (StringUtils.isEmpty(poolDTO.getFollowUserName()) && Objects.nonNull(poolDTO.getUserId())) {
|
3fc19e59
张志伟
升级erpsdk
|
258
|
UserInfoDTO user = ehrRpcService.user(poolDTO.getUserId());
|
e0dd8097
张志伟
|
259
260
261
|
if (Objects.nonNull(user)) {
vo.setFollower(user.getUserName());
}
|
d1659148
张志伟
✨ 战败池 100%
|
262
|
}
|
e0dd8097
张志伟
|
263
264
265
266
267
268
269
270
271
272
273
|
if (Objects.nonNull(poolDTO.getShopId())) {
ShopDTO shop = oopService.shop(poolDTO.getShopId());
if (Objects.nonNull(shop)) {
vo.setShopName(shop.getShortName());
}
}
if (Objects.nonNull(poolDTO.getFinishShop())) {
ShopDTO fshop = oopService.shop(poolDTO.getFinishShop());
if (Objects.nonNull(fshop)) {
vo.setFinishShopName(fshop.getShortName());
}
|
d1659148
张志伟
✨ 战败池 100%
|
274
|
}
|
e7aefdc4
张志伟
|
275
276
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
|
20d2dfca
张志伟
feature(*): 新增一个展示字段
|
277
|
vo.setLoanDate(poolDTO.getLoanExpires());
|
e7aefdc4
张志伟
|
278
|
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
279
|
TaskDefeatTypeEnum defeatTypeEnum = TaskDefeatTypeEnum.ofValue(poolDTO.getInitiative());
|
e7aefdc4
张志伟
|
280
|
if (Objects.nonNull(defeatTypeEnum)) {
|
e001d1e4
张志伟
|
281
|
vo.setDefeatType(defeatTypeEnum.getName());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
282
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
283
284
|
return vo;
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
285
|
|
39e85d50
张志伟
|
286
287
288
289
290
|
private StammkundePoolVO trans2StaPool(StammkundePoolDTO dto) {
StammkundePoolVO vo = new StammkundePoolVO();
BeanUtils.copyProperties(dto, vo);
ShopDTO shop = oopService.shop(dto.getShopId());
if (Objects.nonNull(shop)) {
|
ae766fec
张志伟
|
291
|
vo.setShopName(shop.getShortName());
|
39e85d50
张志伟
|
292
293
294
295
296
297
298
299
300
301
302
303
|
}
if (Objects.nonNull(dto.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(dto.getLoanExpires()).isAfter(LocalDate.now()));
}
String tags = dto.getTags();
if (StringUtils.isEmpty(tags)) {
vo.setMaintainCard(Boolean.FALSE);
vo.setWarrantyCard(Boolean.FALSE);
} else {
vo.setMaintainCard(tags.contains(CusTagEnum.MAINTAIN_CARD.getValue()));
vo.setWarrantyCard(tags.contains(CusTagEnum.QUA_ASS_CARD.getValue()));
}
|
eae2ecd8
张志伟
|
304
305
306
307
|
if (Objects.nonNull(dto.getReason())) {
DefeatReasonEnum reasonEnum = DefeatReasonEnum.ofValue(dto.getReason());
vo.setReason(Objects.nonNull(reasonEnum) ? reasonEnum.getName() : null);
}
|
b27b4375
张志伟
|
308
309
310
311
312
313
|
if (Objects.nonNull(dto.getBuyDate())) {
LocalDate buyDate = DateUtil.date2LocalDate(dto.getBuyDate());
long days = LocalDate.now().toEpochDay() - buyDate.toEpochDay();
double years = Math.ceil(days / 365.0);
vo.setAgeLimit(Math.round(years));
}
|
39e85d50
张志伟
|
314
315
316
|
return vo;
}
|
34b20e3a
张志伟
|
317
|
private CustomerCluePoolVO trans2CluePool(FollowClueDTO poolDTO, Set<Long> scope) {
|
cacb1a42
张志伟
|
318
319
|
CustomerCluePoolVO vo = new CustomerCluePoolVO();
BeanUtils.copyProperties(poolDTO, vo);
|
fdf7fb2f
张志伟
|
320
|
vo.setStatus(poolDTO.getClueStatus());
|
6af1f4a8
张志伟
|
321
322
323
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
}
|
1943d0bc
张志伟
feature(*): 公共线索池
|
324
|
if (ClueStatusEnum.COMPLETE.getValue().equals(poolDTO.getClueStatus())) {
|
ee7c5ab4
张志伟
|
325
326
|
vo.setStatus(ClueStatusEnum.COMPLETE.getValue());
}
|
1943d0bc
张志伟
feature(*): 公共线索池
|
327
|
if (ClueStatusEnum.FAILURE.getValue().equals(poolDTO.getClueStatus())) {
|
ee7c5ab4
张志伟
|
328
329
|
vo.setStatus(ClueStatusEnum.FAILURE.getValue());
}
|
886c770a
张志伟
|
330
331
332
333
334
|
//首保
if (FollowTypeEnum.FM.getValue().equals(poolDTO.getType())) {
NewCarOrderInfo orderInfo = orderRpcService.getOrderInfo(poolDTO.getFrameNo());
if (Objects.nonNull(orderInfo)) {
ShopDTO shop = oopService.shop(orderInfo.getShopId());
|
1943d0bc
张志伟
feature(*): 公共线索池
|
335
|
vo.setSaleShop(Objects.nonNull(shop) ? shop.getShortName() : "-");
|
886c770a
张志伟
|
336
337
|
}
}
|
cacb1a42
张志伟
|
338
339
340
|
return vo;
}
|
39e85d50
张志伟
|
341
|
private void prepareParams(LoginAuthBean user, PoolQuery queryVO) {
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
342
343
344
|
if (Objects.nonNull(user)) {
queryVO.setUserId(user.getUserId());
queryVO.setGroupId(user.getGroupId());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
345
|
}
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
346
347
|
if (Objects.nonNull(queryVO.getOrder()) && StringUtils.isValid(queryVO.getOrderAtt())) {
StringBuilder sb = new StringBuilder(" order by ");
|
41b33b12
张志伟
|
348
|
sb.append(StringUtils.toColumnName(queryVO.getOrderAtt()).toLowerCase());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
349
350
351
352
353
354
355
|
if (queryVO.getOrder() == 1) {
sb.append(" asc ");
} else {
sb.append(" desc ");
}
queryVO.setOrderString(sb.toString());
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
356
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
357
|
}
|