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;
|
7c9f5c47
张志伟
|
8
|
import cn.fw.valhalla.domain.db.pool.PublicPool;
|
cacb1a42
张志伟
|
9
|
import cn.fw.valhalla.domain.dto.CustomerCluePoolDTO;
|
d1659148
张志伟
✨ 战败池 100%
|
10
|
import cn.fw.valhalla.domain.dto.FollowPoolDTO;
|
39e85d50
张志伟
|
11
|
import cn.fw.valhalla.domain.dto.StammkundePoolDTO;
|
886c770a
张志伟
|
12
|
import cn.fw.valhalla.domain.enums.*;
|
cacb1a42
张志伟
|
13
|
import cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO;
|
d1659148
张志伟
✨ 战败池 100%
|
14
|
import cn.fw.valhalla.domain.query.FollowPoolQueryVO;
|
39e85d50
张志伟
|
15
16
|
import cn.fw.valhalla.domain.query.PoolQuery;
import cn.fw.valhalla.domain.query.StammkundePoolQueryVO;
|
cc14a87c
张志伟
|
17
|
import cn.fw.valhalla.domain.vo.AppPageVO;
|
fdf7fb2f
张志伟
|
18
|
import cn.fw.valhalla.domain.vo.pool.*;
|
d1659148
张志伟
✨ 战败池 100%
|
19
20
|
import cn.fw.valhalla.rpc.erp.UserService;
import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
|
d1659148
张志伟
✨ 战败池 100%
|
21
22
|
import cn.fw.valhalla.rpc.oop.OopService;
import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
|
886c770a
张志伟
|
23
24
|
import cn.fw.valhalla.rpc.order.OrderRpcService;
import cn.fw.valhalla.rpc.order.dto.NewCarOrderInfo;
|
cacb1a42
张志伟
|
25
|
import cn.fw.valhalla.service.data.*;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
26
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
d1659148
张志伟
✨ 战败池 100%
|
27
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
28
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7c9f5c47
张志伟
|
29
|
import lombok.RequiredArgsConstructor;
|
d1659148
张志伟
✨ 战败池 100%
|
30
|
import lombok.extern.slf4j.Slf4j;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
31
|
import org.springframework.beans.BeanUtils;
|
d1659148
张志伟
✨ 战败池 100%
|
32
33
|
import org.springframework.stereotype.Service;
|
e7aefdc4
张志伟
|
34
|
import java.time.LocalDate;
|
ee7c5ab4
张志伟
|
35
|
import java.util.*;
|
abc1b038
张志伟
|
36
|
import java.util.stream.Collectors;
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
37
38
|
import static cn.fw.common.businessvalidator.Validator.BV;
|
d1659148
张志伟
✨ 战败池 100%
|
39
40
41
42
43
44
45
46
47
|
/**
* @author : kurisu
* @className : FollowPoolBizService
* @description : 跟进池服务
* @date: 2020-09-23 15:30
*/
@Slf4j
@Service
|
7c9f5c47
张志伟
|
48
49
|
@RequiredArgsConstructor
public class PoolBizService {
|
d1659148
张志伟
✨ 战败池 100%
|
50
|
private final FollowTaskService followTaskService;
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
51
|
private final PublicPoolService publicPoolService;
|
39e85d50
张志伟
|
52
|
private final StammkundePoolService stammkundePoolService;
|
cacb1a42
张志伟
|
53
|
private final CustomerCluePoolService cluePoolService;
|
d1659148
张志伟
✨ 战败池 100%
|
54
55
|
private final OopService oopService;
private final UserService userService;
|
abc1b038
张志伟
|
56
|
private final AffiliationRecordService affiliationRecordService;
|
886c770a
张志伟
|
57
|
private final OrderRpcService orderRpcService;
|
d1659148
张志伟
✨ 战败池 100%
|
58
|
|
d1659148
张志伟
✨ 战败池 100%
|
59
|
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
60
|
/**
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
61
62
|
* 跟进池
*
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
63
64
65
|
* @param queryVO
* @return
*/
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
66
67
|
public AppPage<FollowPoolListVO> followList(LoginAuthBean user, FollowPoolQueryVO queryVO) {
prepareParams(user, queryVO);
|
cc14a87c
张志伟
|
68
69
70
71
72
73
|
AppPageVO<FollowPoolListVO> page = AppPageVO.init(queryVO);
final long total = followTaskService.followListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
|
2c93da14
张志伟
✨ 战败池 100%
|
74
75
76
|
List<FollowPoolDTO> list = followTaskService.followList(queryVO);
List<FollowPoolListVO> followList = new ArrayList<>();
for (FollowPoolDTO followPoolDTO : list) {
|
abc1b038
张志伟
|
77
|
FollowPoolListVO vo = trans2FollowPool(followPoolDTO);
|
2c93da14
张志伟
✨ 战败池 100%
|
78
79
|
followList.add(vo);
}
|
2c93da14
张志伟
✨ 战败池 100%
|
80
81
82
83
|
page.setData(followList);
return page;
}
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
84
85
86
87
88
89
|
/**
* 公共池
*
* @param queryVO
* @return
*/
|
abc1b038
张志伟
|
90
91
92
93
94
95
96
97
|
public AppPage<PublicPoolVO> publicList(LoginAuthBean currentUser, FollowPoolQueryVO queryVO) {
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());
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
98
99
|
Page<PublicPool> opage = new Page<>(queryVO.getCurrent(), queryVO.getPageSize());
opage = publicPoolService.page(opage, Wrappers.<PublicPool>lambdaQuery()
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
100
|
.eq(StringUtils.isValid(queryVO.getPlateNo()), PublicPool::getPlateNo, "%" + queryVO.getPlateNo() + "%")
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
101
102
|
.eq(Objects.nonNull(queryVO.getType()), PublicPool::getType, queryVO.getType())
.eq(Objects.nonNull(queryVO.getGroupId()), PublicPool::getGroupId, queryVO.getGroupId())
|
abc1b038
张志伟
|
103
|
.notIn(CollectionUtils.isNotEmpty(custIds), PublicPool::getCustomerId, custIds)
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
104
|
);
|
cc14a87c
张志伟
|
105
|
AppPageVO<PublicPoolVO> page = AppPageVO.init(queryVO);
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
106
|
List<PublicPool> list = opage.getRecords();
|
cc14a87c
张志伟
|
107
|
page.setTotal(opage.getTotal());
|
f519f088
张志伟
✨ 公共池接口 90% 缺文档
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
if (CollectionUtils.isEmpty(list)) {
return page;
}
List<PublicPoolVO> publicList = new ArrayList<>();
for (PublicPool pool : list) {
PublicPoolVO vo = new PublicPoolVO();
BeanUtils.copyProperties(pool, vo);
vo.setTypeDesc(pool.getType().getName());
publicList.add(vo);
}
page.setData(publicList);
return page;
}
|
39e85d50
张志伟
|
122
123
|
/**
* 保有客池
|
cc14a87c
张志伟
|
124
|
*
|
39e85d50
张志伟
|
125
126
127
128
129
130
|
* @param user
* @param queryVO
* @return
*/
public AppPage<StammkundePoolVO> stammkundeList(LoginAuthBean user, StammkundePoolQueryVO queryVO) {
prepareParams(user, queryVO);
|
cc14a87c
张志伟
|
131
132
133
134
135
136
|
AppPageVO<StammkundePoolVO> page = AppPageVO.init(queryVO);
long total = stammkundePoolService.stammkundeListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
|
39e85d50
张志伟
|
137
138
139
140
141
142
|
List<StammkundePoolDTO> list = stammkundePoolService.stammkundeList(queryVO);
List<StammkundePoolVO> appList = new ArrayList<>();
for (StammkundePoolDTO dto : list) {
StammkundePoolVO vo = trans2StaPool(dto);
appList.add(vo);
}
|
39e85d50
张志伟
|
143
144
145
|
page.setData(appList);
return page;
}
|
2c93da14
张志伟
✨ 战败池 100%
|
146
|
|
cacb1a42
张志伟
|
147
148
|
/**
* 客户线索池
|
cc14a87c
张志伟
|
149
|
*
|
cacb1a42
张志伟
|
150
151
152
153
154
155
|
* @param queryVO
* @return
*/
public AppPage<CustomerCluePoolVO> clueList(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
|
fdf7fb2f
张志伟
|
156
157
158
159
160
161
|
AppPageVO<CustomerCluePoolVO> page = AppPageVO.init(queryVO);
long total = cluePoolService.clueListCount(queryVO);
if (total <= 0) {
return page;
}
page.setTotal(total);
|
ee7c5ab4
张志伟
|
162
|
final HashSet<Long> scope = new HashSet<>(queryVO.getScope());
|
cacb1a42
张志伟
|
163
164
165
|
List<CustomerCluePoolDTO> list = cluePoolService.clueList(queryVO);
List<CustomerCluePoolVO> appList = new ArrayList<>();
for (CustomerCluePoolDTO dto : list) {
|
ee7c5ab4
张志伟
|
166
|
CustomerCluePoolVO vo = trans2CluePool(dto, scope);
|
cacb1a42
张志伟
|
167
168
|
appList.add(vo);
}
|
cacb1a42
张志伟
|
169
|
page.setData(appList);
|
ebdbea07
张志伟
|
170
|
return page;
|
cacb1a42
张志伟
|
171
172
|
}
|
fdf7fb2f
张志伟
|
173
174
|
/**
* 线索池概况
|
ee7c5ab4
张志伟
|
175
|
*
|
fdf7fb2f
张志伟
|
176
177
178
179
180
181
182
183
|
* @param queryVO
* @return
*/
public CustomerClueSummaryVO summary(CustomerCluePoolQueryVO queryVO) {
prepareParams(null, queryVO);
BV.isNotEmpty(queryVO.getScope(), () -> "人员权限范围不正确,请确认是否有管理权限");
CustomerClueSummaryVO vo = new CustomerClueSummaryVO();
|
ee7c5ab4
张志伟
|
184
185
|
vo.setCompleteNum(cluePoolService.completeNum(queryVO));
vo.setDefeatNum(cluePoolService.defeatNum(queryVO));
|
3015fc0c
张志伟
|
186
187
|
vo.setOnGoingNum(cluePoolService.onGoingNum(queryVO));
vo.setClosedNum(vo.getCompleteNum() + vo.getDefeatNum());
|
fdf7fb2f
张志伟
|
188
189
190
|
return vo;
}
|
abc1b038
张志伟
|
191
|
private FollowPoolListVO trans2FollowPool(FollowPoolDTO poolDTO) {
|
d1659148
张志伟
✨ 战败池 100%
|
192
|
FollowPoolListVO vo = new FollowPoolListVO();
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
193
194
|
BeanUtils.copyProperties(poolDTO, vo);
UserInfoDTO user = userService.user(poolDTO.getUserId());
|
d1659148
张志伟
✨ 战败池 100%
|
195
196
197
|
if (Objects.nonNull(user)) {
vo.setFollower(user.getUserName());
}
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
198
|
ShopDTO shop = oopService.shop(poolDTO.getShopId());
|
d1659148
张志伟
✨ 战败池 100%
|
199
|
if (Objects.nonNull(shop)) {
|
ae766fec
张志伟
|
200
|
vo.setShopName(shop.getShortName());
|
d1659148
张志伟
✨ 战败池 100%
|
201
|
}
|
e7aefdc4
张志伟
|
202
203
204
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
205
|
TaskDefeatTypeEnum defeatTypeEnum = TaskDefeatTypeEnum.ofValue(poolDTO.getInitiative());
|
e7aefdc4
张志伟
|
206
|
if (Objects.nonNull(defeatTypeEnum)) {
|
e001d1e4
张志伟
|
207
|
vo.setDefeatType(defeatTypeEnum.getName());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
208
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
209
210
|
return vo;
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
211
|
|
39e85d50
张志伟
|
212
213
214
215
216
|
private StammkundePoolVO trans2StaPool(StammkundePoolDTO dto) {
StammkundePoolVO vo = new StammkundePoolVO();
BeanUtils.copyProperties(dto, vo);
ShopDTO shop = oopService.shop(dto.getShopId());
if (Objects.nonNull(shop)) {
|
ae766fec
张志伟
|
217
|
vo.setShopName(shop.getShortName());
|
39e85d50
张志伟
|
218
219
220
221
222
223
224
225
226
227
228
229
|
}
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
张志伟
|
230
231
232
233
|
if (Objects.nonNull(dto.getReason())) {
DefeatReasonEnum reasonEnum = DefeatReasonEnum.ofValue(dto.getReason());
vo.setReason(Objects.nonNull(reasonEnum) ? reasonEnum.getName() : null);
}
|
39e85d50
张志伟
|
234
235
236
|
return vo;
}
|
ee7c5ab4
张志伟
|
237
|
private CustomerCluePoolVO trans2CluePool(CustomerCluePoolDTO poolDTO, Set<Long> scope) {
|
cacb1a42
张志伟
|
238
239
|
CustomerCluePoolVO vo = new CustomerCluePoolVO();
BeanUtils.copyProperties(poolDTO, vo);
|
fdf7fb2f
张志伟
|
240
|
vo.setStatus(poolDTO.getClueStatus());
|
6af1f4a8
张志伟
|
241
242
243
|
if (Objects.nonNull(poolDTO.getLoanExpires())) {
vo.setLoanCustomer(DateUtil.date2LocalDate(poolDTO.getLoanExpires()).isAfter(LocalDate.now()));
}
|
ee7c5ab4
张志伟
|
244
245
246
|
if (ClueStatusEnum.COMPLETE.getValue().equals(poolDTO.getClueStatus()) && scope.contains(poolDTO.getFinishShopId())) {
vo.setStatus(ClueStatusEnum.COMPLETE.getValue());
}
|
77508697
张志伟
|
247
248
249
|
boolean bool = ClueStatusEnum.FAILURE.getValue().equals(poolDTO.getClueStatus()) ||
(Objects.nonNull(poolDTO.getFinishShopId()) && !scope.contains(poolDTO.getFinishShopId()));
if (bool) {
|
ee7c5ab4
张志伟
|
250
251
|
vo.setStatus(ClueStatusEnum.FAILURE.getValue());
}
|
886c770a
张志伟
|
252
253
254
255
256
257
258
259
|
//首保
if (FollowTypeEnum.FM.getValue().equals(poolDTO.getType())) {
NewCarOrderInfo orderInfo = orderRpcService.getOrderInfo(poolDTO.getFrameNo());
if (Objects.nonNull(orderInfo)) {
ShopDTO shop = oopService.shop(orderInfo.getShopId());
vo.setSaleShop(Objects.nonNull(shop) ? shop.getShortName() : "");
}
}
|
cacb1a42
张志伟
|
260
261
262
|
return vo;
}
|
39e85d50
张志伟
|
263
|
private void prepareParams(LoginAuthBean user, PoolQuery queryVO) {
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
264
265
266
|
if (Objects.nonNull(user)) {
queryVO.setUserId(user.getUserId());
queryVO.setGroupId(user.getGroupId());
|
27e74147
张志伟
|
267
|
} else {
|
354532ce
张志伟
|
268
269
|
boolean bool = CollectionUtils.isEmpty(queryVO.getShopIds()) && Objects.isNull(queryVO.getUserId()) && StringUtils.isEmpty(queryVO.getUserName());
BV.isFalse(bool, () -> "请选择服务站或者人员");
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
270
|
}
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
271
272
|
if (Objects.nonNull(queryVO.getOrder()) && StringUtils.isValid(queryVO.getOrderAtt())) {
StringBuilder sb = new StringBuilder(" order by ");
|
41b33b12
张志伟
|
273
|
sb.append(StringUtils.toColumnName(queryVO.getOrderAtt()).toLowerCase());
|
7b007468
张志伟
🚀 v1.0.1 跟进池
|
274
275
276
277
278
279
280
|
if (queryVO.getOrder() == 1) {
sb.append(" asc ");
} else {
sb.append(" desc ");
}
queryVO.setOrderString(sb.toString());
}
|
c4fb2fa5
张志伟
✨ 公共池接口 100%
|
281
|
}
|
d1659148
张志伟
✨ 战败池 100%
|
282
|
}
|