65610b54
张志伟
|
1
2
|
package cn.fw.valhalla.service.bus.follow.strategy.impl;
|
403016ba
张志伟
|
3
|
import cn.fw.common.exception.BusinessException;
|
f424423f
张志伟
|
4
|
import cn.fw.common.util.ValidationUtils;
|
fe7014b6
张志伟
|
5
|
import cn.fw.valhalla.common.utils.DateUtil;
|
b2f969bd
张志伟
|
6
|
import cn.fw.valhalla.common.utils.MobileUtil;
|
ad395b9c
张志伟
|
7
8
|
import cn.fw.valhalla.common.utils.StringUtils;
import cn.fw.valhalla.domain.db.OriginalData;
|
65610b54
张志伟
|
9
|
import cn.fw.valhalla.domain.db.customer.AccidentPool;
|
ad395b9c
张志伟
|
10
|
import cn.fw.valhalla.domain.db.customer.Customer;
|
65610b54
张志伟
|
11
|
import cn.fw.valhalla.domain.db.follow.FollowRecord;
|
fb44222c
张志伟
事故车跟进逻辑调整
|
12
|
import cn.fw.valhalla.domain.db.follow.FollowRecordLog;
|
ad395b9c
张志伟
|
13
|
import cn.fw.valhalla.domain.db.follow.FollowTask;
|
fb44222c
张志伟
事故车跟进逻辑调整
|
14
|
import cn.fw.valhalla.domain.db.pool.CustomerCluePool;
|
09c7be2a
张志伟
|
15
|
import cn.fw.valhalla.domain.dto.CustomerDetailDto;
|
b2f969bd
张志伟
|
16
|
import cn.fw.valhalla.domain.dto.FollowAttachmentDTO;
|
403016ba
张志伟
|
17
|
import cn.fw.valhalla.domain.enums.*;
|
b2f969bd
张志伟
|
18
|
import cn.fw.valhalla.domain.vo.follow.*;
|
ad395b9c
张志伟
|
19
|
import cn.fw.valhalla.domain.vo.setting.SettingVO;
|
09c7be2a
张志伟
|
20
|
import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO;
|
9091e42f
张志伟
|
21
|
import cn.fw.valhalla.rpc.erp.dto.BackLogItemDTO;
|
488da455
张志伟
|
22
23
|
import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
|
65610b54
张志伟
|
24
25
|
import cn.fw.valhalla.service.bus.follow.strategy.AbstractFollowStrategy;
import cn.fw.valhalla.service.data.AccidentPoolService;
|
fa966283
张志伟
📝 v1.0.1调整
|
26
|
import cn.fw.valhalla.service.event.CancelApproveEvent;
|
ad395b9c
张志伟
|
27
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
65610b54
张志伟
|
28
29
30
|
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
|
08704989
张志伟
|
31
|
import org.springframework.transaction.annotation.Transactional;
|
65610b54
张志伟
|
32
33
|
import org.springframework.util.CollectionUtils;
|
fe7014b6
张志伟
|
34
|
import java.time.LocalDateTime;
|
7254a847
张志伟
|
35
|
import java.util.*;
|
65610b54
张志伟
|
36
|
|
b2f969bd
张志伟
|
37
|
import static cn.fw.common.businessvalidator.Validator.BV;
|
fb44222c
张志伟
事故车跟进逻辑调整
|
38
|
import static cn.fw.valhalla.common.utils.DateUtil.date2LocalDateTime;
|
3d3c242a
张志伟
|
39
|
import static cn.fw.valhalla.common.utils.StringUtils.getStrWithDefault;
|
b2f969bd
张志伟
|
40
|
|
65610b54
张志伟
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/**
* @author : kurisu
* @className : ACFollowStrategy
* @description : 事故车策略
* @date: 2020-08-17 10:48
*/
@Slf4j
@Component
public class ACFollowStrategy extends AbstractFollowStrategy {
private final AccidentPoolService accidentPoolService;
@Autowired
public ACFollowStrategy(final AccidentPoolService accidentPoolService) {
this.accidentPoolService = accidentPoolService;
}
@Override
public FollowTypeEnum getFollowType() {
return FollowTypeEnum.AC;
}
@Override
public List<FollowTodoListVO> getList(Integer startIndex, Integer pageSize, Long userId) {
|
58d889cc
张志伟
新增重复提交校验和事故车跟进逾期时间查询
|
64
|
List<FollowRecord> list = list(startIndex, pageSize, userId, getFollowType());
|
65610b54
张志伟
|
65
66
67
68
69
70
71
72
73
|
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
List<FollowTodoListVO> voList = new ArrayList<>();
for (FollowRecord followRecord : list) {
ACTodoListVO vo = new ACTodoListVO();
vo.setId(followRecord.getId());
vo.setTaskId(followRecord.getTaskId());
vo.setCustomerId(followRecord.getCustomerId());
|
7c457605
张志伟
|
74
|
vo.setDeadline(followRecord.getDeadline());
|
65610b54
张志伟
|
75
76
77
78
79
80
81
82
83
84
|
AccidentPool accidentPool = accidentPoolService.getById(followRecord.getCustomerId());
if (Objects.nonNull(accidentPool)) {
vo.setName(accidentPool.getName());
vo.setInsComName(accidentPool.getInsurerName());
vo.setPlateNo(accidentPool.getPlateNo());
}
voList.add(vo);
}
return voList;
}
|
b2f969bd
张志伟
|
85
86
|
@Override
|
376d3231
张志伟
✨ 主动放弃跟进 100%
|
87
|
public FollowDetailVO getDetail(Long id) {
|
b2f969bd
张志伟
|
88
89
|
FollowRecord followRecord = followRecordService.getById(id);
BV.notNull(followRecord, "跟进记录不存在");
|
3ac8e84c
张志伟
|
90
91
92
93
|
int count = followRecordLogService.count(Wrappers.<FollowRecordLog>lambdaQuery()
.eq(FollowRecordLog::getRecordId, followRecord.getId())
.eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE)
);
|
fa966283
张志伟
📝 v1.0.1调整
|
94
|
ACDetailVO vo = assemble(followRecord.getCustomerId());
|
b2f969bd
张志伟
|
95
|
vo.setId(followRecord.getId());
|
b2f969bd
张志伟
|
96
|
vo.setTaskId(followRecord.getTaskId());
|
f424423f
张志伟
|
97
|
vo.setHadCall(count > 0 || !ValidationUtils.checkMobile(vo.getReportMobile()));
|
51a118ce
张志伟
|
98
|
vo.setDeadline(followRecord.getDeadline());
|
b2f969bd
张志伟
|
99
100
101
102
103
104
105
106
107
|
return vo;
}
@Override
public List<FollowRecordVO> getRecordList(Long taskId) {
return super.getRecordList(taskId);
}
@Override
|
ee39ce19
张志伟
|
108
|
public void completeRecordAndEnd(FollowRecord record) {
|
93dbde02
张志伟
|
109
|
final Date followTime = DateUtil.localDateTime2Date(LocalDateTime.now());
|
2332c49d
张志伟
|
110
|
BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), followTime, record.getShopId());
|
dac2e8b1
张志伟
|
111
|
if (Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime())) {
|
fd45b634
张志伟
|
112
|
record.setFollowTime(followTime);
|
93dbde02
张志伟
|
113
|
followRecordService.updateById(record);
|
fd45b634
张志伟
|
114
115
116
117
|
todoRpcService.complete(dto);
return;
}
if (record.getLimitTime().after(followTime)) {
|
fd45b634
张志伟
|
118
|
todoRpcService.cancel(dto);
|
93dbde02
张志伟
|
119
|
}
|
b2f969bd
张志伟
|
120
121
122
123
|
}
@Override
public void uploadAtt(FollowAttachmentDTO dto, Long userId) {
|
18b1ac66
张志伟
|
124
125
126
127
128
|
FollowRecord record = followRecordService.getById(dto.getRecordId());
if (Objects.isNull(record)) {
return;
}
BV.isTrue(record.getUserId().equals(userId), () -> "无法跟进非本人待办任务");
|
fb44222c
张志伟
事故车跟进逻辑调整
|
129
|
FollowRecordLog recordLog = new FollowRecordLog();
|
a98480b0
张志伟
|
130
|
recordLog.setId(dto.getId());
|
cbc29a25
张志伟
|
131
|
recordLog.setTaskId(record.getTaskId());
|
fb44222c
张志伟
事故车跟进逻辑调整
|
132
|
recordLog.setAttachments(dto.getAttachments());
|
bff962f1
张志伟
|
133
|
recordLog.setAttType(dto.getAttTypeEnum());
|
ffc9b4e2
张志伟
|
134
|
recordLog.setFeedbackType(dto.getFeedbackTypeEnum());
|
fb44222c
张志伟
事故车跟进逻辑调整
|
135
136
|
recordLog.setDescribes(dto.getDescribes());
recordLog.setRecordId(dto.getRecordId());
|
a98480b0
张志伟
|
137
138
139
|
if (Objects.isNull(dto.getId())) {
recordLog.setUploadTime(new Date());
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
140
|
followRecordLogService.save(recordLog);
|
ffc9b4e2
张志伟
|
141
|
feedbackTask(record.getTaskId(), dto.getFeedbackTypeEnum());
|
18b1ac66
张志伟
|
142
143
144
|
if (Boolean.FALSE.equals(record.getOutTime()) && Objects.isNull(record.getFollowTime())) {
record.setFollowTime(DateUtil.localDateTime2Date(LocalDateTime.now()));
|
a62ccd41
张志伟
|
145
146
147
|
BackLogItemDTO backLogItemDTO = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()),
String.valueOf(record.getId()), DateUtil.localDateTime2Date(LocalDateTime.now()), record.getShopId());
todoRpcService.complete(backLogItemDTO);
|
18b1ac66
张志伟
|
148
149
|
followRecordService.updateById(record);
}
|
b2f969bd
张志伟
|
150
|
}
|
08704989
张志伟
|
151
152
153
154
155
156
|
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelFollowTask(Long customerId, Date time, Long groupId) {
//事故车进站取消的情况暂时不考虑
}
|
ad395b9c
张志伟
|
157
158
|
@Override
|
ad395b9c
张志伟
|
159
|
public void settingChanged(List<SettingVO> setting, Long groupId) {
|
fb44222c
张志伟
事故车跟进逻辑调整
|
160
|
//更改设置不影响事故车跟进
|
ad395b9c
张志伟
|
161
162
163
|
}
@Override
|
612d25d9
张志伟
|
164
|
public boolean origin2task(OriginalData originalData) {
|
dac2e8b1
张志伟
|
165
166
|
finishClue(originalData);
return true;
|
23b952c1
张志伟
|
167
|
}
|
ad395b9c
张志伟
|
168
|
|
23b952c1
张志伟
|
169
|
@Override
|
8587e21d
张志伟
|
170
171
172
173
174
|
public void updateTask(Long customerId) {
//事故车无二次跟进
}
@Override
|
23b952c1
张志伟
|
175
|
@Transactional(rollbackFor = Exception.class)
|
612d25d9
张志伟
|
176
|
public void overdueProcessing(FollowRecord record) {
|
612d25d9
张志伟
|
177
|
followRecordService.overdue(record.getId());
|
23b952c1
张志伟
|
178
179
|
}
|
fa966283
张志伟
📝 v1.0.1调整
|
180
181
182
183
|
@Override
public FollowDetailVO followPoolDetail(FollowTask task) {
ACDetailVO vo = assemble(task.getCustomerId());
vo.setTaskId(task.getId());
|
5b0b8a14
张志伟
|
184
|
queryTimes(task.getClueId(), vo);
|
fa966283
张志伟
📝 v1.0.1调整
|
185
186
187
|
return vo;
}
|
18b1ac66
张志伟
|
188
|
|
403016ba
张志伟
|
189
190
191
192
193
194
195
|
@Override
@Transactional(rollbackFor = Exception.class)
public void closeTask(FollowTask task) throws BusinessException {
task.setState(TaskStateEnum.DEFEAT);
task.setCloseTime(new Date());
task.setReason(TaskDefeatTypeEnum.C);
followTaskService.updateById(task);
|
51df64c4
张志伟
|
196
|
customerBizService.abandon(task, false);
|
403016ba
张志伟
|
197
198
199
200
|
CancelApproveEvent event = new CancelApproveEvent(task.getId(), ApproveTypeEnum.FOLLOW_DEFEAT);
eventPublisher.publishEvent(event);
}
|
23b952c1
张志伟
|
201
|
/**
|
fb44222c
张志伟
事故车跟进逻辑调整
|
202
|
* 处理线索
|
23b952c1
张志伟
|
203
204
|
*
* @param originalData
|
fb44222c
张志伟
事故车跟进逻辑调整
|
205
|
* @return 完成的线索id
|
23b952c1
张志伟
|
206
|
*/
|
fb44222c
张志伟
事故车跟进逻辑调整
|
207
208
209
|
@Transactional(rollbackFor = Exception.class)
public void finishClue(OriginalData originalData) {
final String plateNo = originalData.getPlateNo();
|
23b952c1
张志伟
|
210
|
if (StringUtils.isEmpty(plateNo)) {
|
fb44222c
张志伟
事故车跟进逻辑调整
|
211
|
return;
|
23b952c1
张志伟
|
212
|
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
213
214
215
|
CustomerCluePool cluePool = customerCluePoolService.queryByPlateNo(plateNo, originalData.getGroupId(), getFollowType());
if (Objects.isNull(cluePool) || !ClueStatusEnum.ONGOING.equals(cluePool.getClueStatus())) {
return;
|
23b952c1
张志伟
|
216
|
}
|
fb44222c
张志伟
事故车跟进逻辑调整
|
217
218
219
220
221
|
if (date2LocalDateTime(cluePool.getDeadline()).isAfter(date2LocalDateTime(originalData.getGenerateTime()))) {
cluePool.setFinishShopId(cluePool.getOriginalShopId());
cluePool.setFinishShopName(cluePool.getOriginalShopName());
cluePool.setFinishUserId(cluePool.getOriginalUserId());
cluePool.setFinishUserName(cluePool.getOriginalUserName());
|
b688a252
张志伟
|
222
|
cluePool.setCloseTime(originalData.getGenerateTime());
|
fb44222c
张志伟
事故车跟进逻辑调整
|
223
224
|
cluePool.setClueStatus(ClueStatusEnum.COMPLETE);
customerCluePoolService.updateById(cluePool);
|
488da455
张志伟
|
225
|
completeTask(cluePool, originalData);
|
fb44222c
张志伟
事故车跟进逻辑调整
|
226
227
228
229
|
}
}
/**
|
403016ba
张志伟
|
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
* 完成生成的跟进待办
*
* @param taskId
*/
@Override
@Transactional(rollbackFor = Exception.class)
protected void completeTodo(Long taskId) {
followRecordService.remove(Wrappers.<FollowRecord>lambdaQuery()
.eq(FollowRecord::getTaskId, taskId)
.eq(FollowRecord::getOutTime, Boolean.FALSE)
.eq(FollowRecord::getAddTodo, Boolean.FALSE)
.isNull(FollowRecord::getFollowTime)
.ge(FollowRecord::getDeadline, new Date())
);
List<FollowRecord> list = Optional.ofNullable(followRecordService.list(Wrappers.<FollowRecord>lambdaQuery()
.eq(FollowRecord::getTaskId, taskId)
.eq(FollowRecord::getType, getFollowType())
.eq(FollowRecord::getAddTodo, Boolean.TRUE)
.ge(FollowRecord::getLimitTime, new Date())
)).orElse(new ArrayList<>());
if (CollectionUtils.isEmpty(list)) {
return;
}
for (FollowRecord record : list) {
|
2332c49d
张志伟
|
254
|
BackLogItemDTO dto = new BackLogItemDTO(record.getUserId(), getItemCode(record.getType()), String.valueOf(record.getId()), record.getPlanTime(), record.getShopId());
|
403016ba
张志伟
|
255
256
257
258
259
260
261
262
|
todoRpcService.complete(dto);
record.setFollowTime(new Date());
record.setOutTime(Boolean.FALSE);
}
followRecordService.updateBatchById(list);
}
/**
|
fb44222c
张志伟
事故车跟进逻辑调整
|
263
264
|
* 处理进行中的跟进任务
*
|
bf3704cc
张志伟
|
265
|
* @param cluePool
|
fb44222c
张志伟
事故车跟进逻辑调整
|
266
267
|
* @return
*/
|
fb44222c
张志伟
事故车跟进逻辑调整
|
268
|
@Transactional(rollbackFor = Exception.class)
|
488da455
张志伟
|
269
|
public void completeTask(CustomerCluePool cluePool, OriginalData originalData) {
|
bf3704cc
张志伟
|
270
|
FollowTask task = followTaskService.queryOngoingTaskByClueId(cluePool.getId());
|
23b952c1
张志伟
|
271
|
if (Objects.isNull(task)) {
|
fb44222c
张志伟
事故车跟进逻辑调整
|
272
|
return;
|
ad395b9c
张志伟
|
273
|
}
|
172cb4a3
张志伟
|
274
|
task.setState(TaskStateEnum.COMPLETE);
|
bf3704cc
张志伟
|
275
276
277
278
|
task.setFinishUser(cluePool.getFinishUserId());
task.setFinishUserName(cluePool.getFinishUserName());
task.setFinishShop(cluePool.getFinishShopId());
task.setCloseTime(cluePool.getCloseTime());
|
488da455
张志伟
|
279
280
281
282
283
284
285
286
287
288
289
|
UserInfoDTO user = userService.user(originalData.getUserId());
if (Objects.nonNull(user)) {
task.setReceptionUserId(originalData.getUserId());
task.setReceptionUserName(user.getUserName());
}
ShopDTO shop = oopService.shop(originalData.getShopId());
if (Objects.nonNull(shop)) {
task.setReceptionShopId(originalData.getShopId());
task.setReceptionShopName(shop.getShortName());
}
task.setCloseTime(cluePool.getCloseTime());
|
fb44222c
张志伟
事故车跟进逻辑调整
|
290
291
292
293
294
|
boolean succeed = followTaskService.updateById(task);
if (succeed) {
completeTodo(task.getId());
CancelApproveEvent event = new CancelApproveEvent(task.getId(), ApproveTypeEnum.FOLLOW_DEFEAT);
eventPublisher.publishEvent(event);
|
ad395b9c
张志伟
|
295
|
}
|
ad395b9c
张志伟
|
296
|
}
|
fa966283
张志伟
📝 v1.0.1调整
|
297
298
299
300
301
302
303
|
@Override
public ACDetailVO assemble(Long customerId) {
AccidentPool accidentPool = accidentPoolService.getById(customerId);
BV.notNull(accidentPool, "事故车信息不存在");
Customer customer = customerService.queryByPlateNo(accidentPool.getPlateNo(), accidentPool.getGroupId());
ACDetailVO vo = new ACDetailVO();
|
bff962f1
张志伟
|
304
|
vo.setAccidentId(customerId);
|
fa966283
张志伟
📝 v1.0.1调整
|
305
306
307
308
309
310
311
312
313
314
|
vo.setName(accidentPool.getName());
vo.setMobile(accidentPool.getMobile());
vo.setRegion(MobileUtil.attribution(accidentPool.getMobile()));
vo.setRealMobile(accidentPool.getReportMobile());
vo.setReportMobile(accidentPool.getReportMobile());
vo.setAddress(accidentPool.getAddress());
vo.setShopId(accidentPool.getShopId());
vo.setShopName(accidentPool.getShopName());
vo.setSms(accidentPool.getSms());
vo.setPlateNo(accidentPool.getPlateNo());
|
bff962f1
张志伟
|
315
|
vo.setCarModel(getStrWithDefault(accidentPool.getBrandName(), "") + " " + getStrWithDefault(accidentPool.getSeriesName(), ""));
|
fa966283
张志伟
📝 v1.0.1调整
|
316
|
if (Objects.nonNull(customer)) {
|
91c29e23
张志伟
|
317
|
CustomerDetailDto customerDetailDto = customerBizService.queryById(customer.getId());
|
fa966283
张志伟
📝 v1.0.1调整
|
318
319
320
|
vo.setCustomerId(customer.getId());
vo.setAdviserId(customerDetailDto.getAdviserId());
vo.setAdviserName(customerDetailDto.getAdviserName());
|
c115219a
张志伟
|
321
322
|
vo.setCusLevel(customerDetailDto.getCusLevel());
vo.setArrivalCount(customerDetailDto.getArrivalCount());
|
fa966283
张志伟
📝 v1.0.1调整
|
323
324
325
326
327
328
|
vo.setVin(customerDetailDto.getFrameNo());
Optional<InsuranceDTO> insuranceDTO = queryInsuInfo(customer.getId());
insuranceDTO.ifPresent(ins -> vo.setInsComName(ins.getTciInsurerName()));
}
return vo;
}
|
65610b54
张志伟
|
329
|
}
|