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
|
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 {
|
1ec4380a
张志伟
|
72
|
queryVO.setIgnoreChangeRole(Boolean.TRUE);
|
bd5cb2d8
张志伟
feature(*): 修复成交池查询
|
73
74
75
76
77
78
|
final long total = clueTaskService.followListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
list = clueTaskService.followList(queryVO);
|
cc14a87c
张志伟
|
79
|
}
|
bd5cb2d8
张志伟
feature(*): 修复成交池查询
|
80
|
|
2c93da14
张志伟
✨ 战败池 100%
|
81
82
|
List<FollowPoolListVO> followList = new ArrayList<>();
for (FollowPoolDTO followPoolDTO : list) {
|
abc1b038
张志伟
|
83
|
FollowPoolListVO vo = trans2FollowPool(followPoolDTO);
|
2c93da14
张志伟
✨ 战败池 100%
|
84
85
|
followList.add(vo);
}
|
2c93da14
张志伟
✨ 战败池 100%
|
86
87
88
89
|
page.setData(followList);
return page;
}
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
90
91
92
93
94
95
|
/**
* 公共池
*
* @param queryVO
* @return
*/
|
41a2b42a
张志伟
|
96
|
public AppPage<PublicPoolVO> publicList(LoginAuthBean currentUser, PublicPoolQueryVO queryVO) {
|
652ffd0e
张志伟
|
97
98
99
100
101
102
103
104
105
106
|
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
张志伟
|
107
108
|
}
|
cc14a87c
张志伟
|
109
|
AppPageVO<PublicPoolVO> page = AppPageVO.init(queryVO);
|
1d36107f
张志伟
|
110
111
|
Long count = publicPoolService.publicListCount(queryVO);
if (count <= 0) {
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
112
113
|
return page;
}
|
1d36107f
张志伟
|
114
115
116
|
List<PublicPoolVO> appList = new ArrayList<>();
List<PublicPoolDTO> list = publicPoolService.publicList(queryVO);
for (PublicPoolDTO dto : list) {
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
117
|
PublicPoolVO vo = new PublicPoolVO();
|
1d36107f
张志伟
|
118
119
120
121
122
123
124
125
126
127
128
129
130
|
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% 缺文档
|
131
|
}
|
88ddf741
张志伟
|
132
|
page.setTotal(count);
|
1d36107f
张志伟
|
133
|
page.setData(appList);
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
134
135
136
|
return page;
}
|
39e85d50
张志伟
|
137
138
|
/**
* 保有客池
|
cc14a87c
张志伟
|
139
|
*
|
39e85d50
张志伟
|
140
141
142
143
144
145
|
* @param user
* @param queryVO
* @return
*/
public AppPage<StammkundePoolVO> stammkundeList(LoginAuthBean user, StammkundePoolQueryVO queryVO) {
prepareParams(user, queryVO);
|
cc14a87c
张志伟
|
146
147
148
149
150
151
|
AppPageVO<StammkundePoolVO> page = AppPageVO.init(queryVO);
long total = stammkundePoolService.stammkundeListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
|
39e85d50
张志伟
|
152
153
154
155
156
157
|
List<StammkundePoolDTO> list = stammkundePoolService.stammkundeList(queryVO);
List<StammkundePoolVO> appList = new ArrayList<>();
for (StammkundePoolDTO dto : list) {
StammkundePoolVO vo = trans2StaPool(dto);
appList.add(vo);
}
|
39e85d50
张志伟
|
158
159
160
|
page.setData(appList);
return page;
}
|
2c93da14
张志伟
✨ 战败池 100%
|
161
|
|
cacb1a42
张志伟
|
162
163
|
/**
* 客户线索池
|
cc14a87c
张志伟
|
164
|
*
|
cacb1a42
张志伟
|
165
166
167
168
169
170
|
* @param queryVO
* @return
*/
public AppPage<CustomerCluePoolVO> clueList(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
|
14a1148d
张志伟
|
171
172
173
|
if (ClueStatusEnum.ONGOING.getValue().equals(queryVO.getStatus())) {
queryVO.setCloseTime(null);
}
|
fdf7fb2f
张志伟
|
174
|
AppPageVO<CustomerCluePoolVO> page = AppPageVO.init(queryVO);
|
1943d0bc
张志伟
feature(*): 公共线索池
|
175
|
long total = followClueService.clueListCount(queryVO);
|
fdf7fb2f
张志伟
|
176
177
178
179
|
if (total <= 0) {
return page;
}
page.setTotal(total);
|
ee7c5ab4
张志伟
|
180
|
final HashSet<Long> scope = new HashSet<>(queryVO.getScope());
|
34b20e3a
张志伟
|
181
|
List<FollowClueDTO> list = followClueService.clueList(queryVO);
|
cacb1a42
张志伟
|
182
|
List<CustomerCluePoolVO> appList = new ArrayList<>();
|
34b20e3a
张志伟
|
183
|
for (FollowClueDTO dto : list) {
|
ee7c5ab4
张志伟
|
184
|
CustomerCluePoolVO vo = trans2CluePool(dto, scope);
|
cacb1a42
张志伟
|
185
186
|
appList.add(vo);
}
|
cacb1a42
张志伟
|
187
|
page.setData(appList);
|
ebdbea07
张志伟
|
188
|
return page;
|
cacb1a42
张志伟
|
189
190
|
}
|
fdf7fb2f
张志伟
|
191
192
|
/**
* 线索池概况
|
ee7c5ab4
张志伟
|
193
|
*
|
fdf7fb2f
张志伟
|
194
195
196
197
198
199
200
201
|
* @param queryVO
* @return
*/
public CustomerClueSummaryVO summary(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
CustomerClueSummaryVO vo = new CustomerClueSummaryVO();
|
1943d0bc
张志伟
feature(*): 公共线索池
|
202
203
204
|
vo.setCompleteNum(followClueService.completeNum(queryVO));
vo.setDefeatNum(followClueService.defeatNum(queryVO));
vo.setOnGoingNum(followClueService.onGoingNum(queryVO));
|
3015fc0c
张志伟
|
205
|
vo.setClosedNum(vo.getCompleteNum() + vo.getDefeatNum());
|
fdf7fb2f
张志伟
|
206
207
208
|
return vo;
}
|
b27b4375
张志伟
|
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
247
|
/**
* 公共客户线索池
*
* @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(*): 跟进池接口调整
|
248
249
|
/**
* 跟进池数据转换
|
1943d0bc
张志伟
feature(*): 公共线索池
|
250
|
*
|
d4e6d3ec
张志伟
feature(*): 跟进池接口调整
|
251
252
253
|
* @param poolDTO
* @return
*/
|
abc1b038
张志伟
|
254
|
private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) {
|
d1659148
张志伟
✨ 战败池 100%
|
255
|
FollowPoolListVO vo = new FollowPoolListVO();
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
256
|
BeanUtils.copyProperties(poolDTO, vo);
|
e746dba1
张志伟
|
257
|
vo.setFollower(poolDTO.getFollowUserName());
|
e0dd8097
张志伟
|
258
|
if (StringUtils.isEmpty(poolDTO.getFollowUserName()) && Objects.nonNull(poolDTO.getUserId())) {
|
3fc19e59
张志伟
升级erpsdk
|
259
|
UserInfoDTO user = ehrRpcService.user(poolDTO.getUserId());
|
e0dd8097
张志伟
|
260
261
262
|
if (Objects.nonNull(user)) {
vo.setFollower(user.getUserName());
}
|
d1659148
张志伟
✨ 战败池 100%
|
263
|
}
|
e0dd8097
张志伟
|
264
265
266
267
268
269
270
271
272
273
274
|
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%
|
275
|
}
|
e7aefdc4
张志伟
|
276
277
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
|
20d2dfca
张志伟
feature(*): 新增一个展示字段
|
278
|
vo.setLoanDate(poolDTO.getLoanExpires());
|
e7aefdc4
张志伟
|
279
|
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
280
|
TaskDefeatTypeEnum defeatTypeEnum = TaskDefeatTypeEnum.ofValue(poolDTO.getInitiative());
|
e7aefdc4
张志伟
|
281
|
if (Objects.nonNull(defeatTypeEnum)) {
|
e001d1e4
张志伟
|
282
|
vo.setDefeatType(defeatTypeEnum.getName());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
283
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
284
285
|
return vo;
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
286
|
|
39e85d50
张志伟
|
287
288
289
290
291
|
private StammkundePoolVO trans2StaPool(StammkundePoolDTO dto) {
StammkundePoolVO vo = new StammkundePoolVO();
BeanUtils.copyProperties(dto, vo);
ShopDTO shop = oopService.shop(dto.getShopId());
if (Objects.nonNull(shop)) {
|
ae766fec
张志伟
|
292
|
vo.setShopName(shop.getShortName());
|
39e85d50
张志伟
|
293
294
295
296
297
298
299
300
301
302
303
304
|
}
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
张志伟
|
305
306
307
308
|
if (Objects.nonNull(dto.getReason())) {
DefeatReasonEnum reasonEnum = DefeatReasonEnum.ofValue(dto.getReason());
vo.setReason(Objects.nonNull(reasonEnum) ? reasonEnum.getName() : null);
}
|
b27b4375
张志伟
|
309
310
311
312
313
314
|
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
张志伟
|
315
316
317
|
return vo;
}
|
34b20e3a
张志伟
|
318
|
private CustomerCluePoolVO trans2CluePool(FollowClueDTO poolDTO, Set<Long> scope) {
|
cacb1a42
张志伟
|
319
320
|
CustomerCluePoolVO vo = new CustomerCluePoolVO();
BeanUtils.copyProperties(poolDTO, vo);
|
fdf7fb2f
张志伟
|
321
|
vo.setStatus(poolDTO.getClueStatus());
|
6af1f4a8
张志伟
|
322
323
324
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
}
|
1943d0bc
张志伟
feature(*): 公共线索池
|
325
|
if (ClueStatusEnum.COMPLETE.getValue().equals(poolDTO.getClueStatus())) {
|
ee7c5ab4
张志伟
|
326
327
|
vo.setStatus(ClueStatusEnum.COMPLETE.getValue());
}
|
1943d0bc
张志伟
feature(*): 公共线索池
|
328
|
if (ClueStatusEnum.FAILURE.getValue().equals(poolDTO.getClueStatus())) {
|
ee7c5ab4
张志伟
|
329
330
|
vo.setStatus(ClueStatusEnum.FAILURE.getValue());
}
|
886c770a
张志伟
|
331
332
333
334
335
|
//首保
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(*): 公共线索池
|
336
|
vo.setSaleShop(Objects.nonNull(shop) ? shop.getShortName() : "-");
|
886c770a
张志伟
|
337
338
|
}
}
|
cacb1a42
张志伟
|
339
340
341
|
return vo;
}
|
39e85d50
张志伟
|
342
|
private void prepareParams(LoginAuthBean user, PoolQuery queryVO) {
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
343
344
345
|
if (Objects.nonNull(user)) {
queryVO.setUserId(user.getUserId());
queryVO.setGroupId(user.getGroupId());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
346
|
}
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
347
348
|
if (Objects.nonNull(queryVO.getOrder()) && StringUtils.isValid(queryVO.getOrderAtt())) {
StringBuilder sb = new StringBuilder(" order by ");
|
41b33b12
张志伟
|
349
|
sb.append(StringUtils.toColumnName(queryVO.getOrderAtt()).toLowerCase());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
350
351
352
353
354
355
356
|
if (queryVO.getOrder() == 1) {
sb.append(" asc ");
} else {
sb.append(" desc ");
}
queryVO.setOrderString(sb.toString());
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
357
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
358
|
}
|