65610b54
张志伟
|
1
2
|
package cn.fw.valhalla.service.bus.follow.strategy.impl;
|
b2f969bd
张志伟
|
3
|
import cn.fw.valhalla.common.utils.MobileUtil;
|
ad395b9c
张志伟
|
4
|
import cn.fw.valhalla.domain.db.OriginalData;
|
23b952c1
张志伟
|
5
|
import cn.fw.valhalla.domain.db.customer.Customer;
|
65610b54
张志伟
|
6
7
|
import cn.fw.valhalla.domain.db.follow.FollowRecord;
import cn.fw.valhalla.domain.db.follow.FollowTask;
|
8587e21d
张志伟
|
8
|
import cn.fw.valhalla.domain.db.pool.CustomerCluePool;
|
65610b54
张志伟
|
9
|
import cn.fw.valhalla.domain.dto.CustomerDetailDto;
|
b2f969bd
张志伟
|
10
|
import cn.fw.valhalla.domain.dto.FollowAttachmentDTO;
|
8587e21d
张志伟
|
11
|
import cn.fw.valhalla.domain.enums.ClueStatusEnum;
|
65610b54
张志伟
|
12
|
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
|
ad395b9c
张志伟
|
13
|
import cn.fw.valhalla.domain.enums.SettingTypeEnum;
|
b2f969bd
张志伟
|
14
|
import cn.fw.valhalla.domain.vo.follow.*;
|
08704989
张志伟
|
15
|
import cn.fw.valhalla.domain.vo.setting.SettingVO;
|
8bf24bfd
张志伟
✨ 调整流失客户跟进、事故车跟进逻辑
|
16
|
import cn.fw.valhalla.sdk.enums.DataTypeEnum;
|
65610b54
张志伟
|
17
|
import cn.fw.valhalla.service.bus.follow.strategy.AbstractFollowStrategy;
|
08704989
张志伟
|
18
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
65610b54
张志伟
|
19
20
|
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
|
08704989
张志伟
|
21
|
import org.springframework.transaction.annotation.Transactional;
|
65610b54
张志伟
|
22
23
|
import org.springframework.util.CollectionUtils;
|
08704989
张志伟
|
24
|
import java.util.*;
|
65610b54
张志伟
|
25
|
|
b2f969bd
张志伟
|
26
27
|
import static cn.fw.common.businessvalidator.Validator.BV;
|
65610b54
张志伟
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/**
* @author : kurisu
* @className : FMFollowStrategy
* @description : 首保策略
* @date: 2020-08-17 10:46
*/
@Slf4j
@Component
public class FMFollowStrategy extends AbstractFollowStrategy {
@Override
public FollowTypeEnum getFollowType() {
return FollowTypeEnum.FM;
}
@Override
public List<FollowTodoListVO> getList(Integer startIndex, Integer pageSize, Long userId) {
|
23b952c1
张志伟
|
44
|
List<FollowRecord> list = list(startIndex, pageSize, userId, getFollowType());
|
65610b54
张志伟
|
45
46
47
48
49
50
51
52
53
54
|
if (CollectionUtils.isEmpty(list)) {
return new ArrayList<>();
}
List<FollowTodoListVO> voList = new ArrayList<>();
for (FollowRecord followRecord : list) {
FMTodoListVO vo = new FMTodoListVO();
vo.setId(followRecord.getId());
vo.setTaskId(followRecord.getTaskId());
vo.setCustomerId(followRecord.getCustomerId());
vo.setDeadline(followRecord.getDeadline());
|
8587e21d
张志伟
|
55
56
57
58
59
60
61
|
CustomerDetailDto customerDetailDto = customerBizService.queryById(followRecord.getCustomerId());
if (Objects.nonNull(customerDetailDto)) {
vo.setName(customerDetailDto.getName());
vo.setPlateNo(customerDetailDto.getPlateNo());
vo.setCarImage(customerDetailDto.getCarImage());
vo.setBuyDate(customerDetailDto.getBuyDate());
}
|
65610b54
张志伟
|
62
63
64
65
66
67
|
Optional<FollowTask> followTask = Optional.ofNullable(followTaskService.getById(followRecord.getTaskId()));
followTask.ifPresent(task -> vo.setFMExpiration(task.getDeadline()));
voList.add(vo);
}
return voList;
}
|
b2f969bd
张志伟
|
68
69
|
@Override
|
376d3231
张志伟
✨ 主动放弃跟进 100%
|
70
|
public FollowDetailVO getDetail(Long id) {
|
b2f969bd
张志伟
|
71
72
|
FollowRecord followRecord = followRecordService.getById(id);
BV.notNull(followRecord, "跟进记录不存在");
|
b2f969bd
张志伟
|
73
74
|
FollowTask followTask = followTaskService.getById(followRecord.getTaskId());
BV.notNull(followTask, "跟进信息不存在");
|
fa966283
张志伟
📝 v1.0.1调整
|
75
|
FMDetailVO vo = assemble(followRecord.getCustomerId());
|
f3b07d75
张志伟
|
76
|
vo.setId(followRecord.getId());
|
fa966283
张志伟
📝 v1.0.1调整
|
77
|
vo.setTaskId(followRecord.getTaskId());
|
b2f969bd
张志伟
|
78
79
80
81
82
83
84
85
86
87
|
vo.setFMExpiration(followTask.getDeadline());
return vo;
}
@Override
public List<FollowRecordVO> getRecordList(Long taskId) {
return super.getRecordList(taskId);
}
@Override
|
b2f969bd
张志伟
|
88
89
90
|
public void uploadAtt(FollowAttachmentDTO dto, Long userId) {
super.uploadAtt(dto, userId);
}
|
08704989
张志伟
|
91
92
93
94
|
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelFollowTask(Long customerId, Date time, Long groupId) {
|
8587e21d
张志伟
|
95
96
|
CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customerId, groupId, getFollowType());
if (Objects.isNull(cluePool)) {
|
08704989
张志伟
|
97
98
|
return;
}
|
8587e21d
张志伟
|
99
100
101
|
if (ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) {
customerCluePoolService.removeById(cluePool.getId());
followNoticeRecordService.removeByClueId(cluePool.getId());
|
08704989
张志伟
|
102
|
}
|
8587e21d
张志伟
|
103
104
105
106
|
if (ClueStatusEnum.ONGOING.equals(cluePool.getClueStatus())) {
customerCluePoolService.removeById(cluePool.getId());
followNoticeRecordService.removeByClueId(cluePool.getId());
cancelFollowTodo(cluePool.getRefererId(), getFollowType());
|
08704989
张志伟
|
107
108
109
110
111
112
|
}
//在首保后退车这种情况不考虑
}
@Override
@Transactional(rollbackFor = Exception.class)
|
ad395b9c
张志伟
|
113
|
public void settingChanged(List<SettingVO> setting, Long groupId) {
|
8587e21d
张志伟
|
114
115
116
117
|
List<CustomerCluePool> poolList = customerCluePoolService.list(Wrappers.<CustomerCluePool>lambdaQuery()
.eq(CustomerCluePool::getClueType, getFollowType())
.eq(CustomerCluePool::getGroupId, groupId)
.eq(CustomerCluePool::getClueStatus, ClueStatusEnum.WAITING)
|
08704989
张志伟
|
118
|
);
|
8587e21d
张志伟
|
119
120
|
if (CollectionUtils.isEmpty(poolList)) {
|
08704989
张志伟
|
121
122
|
return;
}
|
8587e21d
张志伟
|
123
|
updateClue(poolList, setting);
|
ad395b9c
张志伟
|
124
125
|
SettingVO noticeSetting = setting.stream().filter(r -> SettingTypeEnum.FIRST_NOTICE_TIME.getValue().equals(r.getType())).findFirst().orElse(new SettingVO());
|
8587e21d
张志伟
|
126
|
updateNoticeRecord(poolList, noticeSetting);
|
23b952c1
张志伟
|
127
128
129
130
|
}
@Override
@Transactional(rollbackFor = Exception.class)
|
612d25d9
张志伟
|
131
132
133
134
135
|
public void overdueProcessing(FollowRecord record) {
super.overdueProcessing(record);
}
@Override
|
fa966283
张志伟
📝 v1.0.1调整
|
136
137
138
139
140
141
142
143
|
public FollowDetailVO followPoolDetail(FollowTask task) {
FMDetailVO vo = assemble(task.getCustomerId());
vo.setTaskId(task.getId());
vo.setFMExpiration(task.getDeadline());
return vo;
}
@Override
|
612d25d9
张志伟
|
144
|
@Transactional(rollbackFor = Exception.class)
|
dac2e8b1
张志伟
|
145
|
public boolean origin2task(OriginalData originalData) throws Exception {
|
23b952c1
张志伟
|
146
|
Customer customer = customerService.queryById(originalData.getCustomerId());
|
dac2e8b1
张志伟
|
147
|
BV.notNull(customer, () -> "档案不存在");
|
81ad74fd
张志伟
|
148
149
150
|
boolean bool = Objects.isNull(customer.getAdviserId()) || Objects.isNull(customer.getShopId());
BV.isFalse(bool, () -> "档案信息不完整");
CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customer.getId(), customer.getGroupId(), getFollowType());
|
6b850c74
张志伟
|
151
|
if (DataTypeEnum.FM.equals(originalData.getType())) {
|
8587e21d
张志伟
|
152
|
completeClue(cluePool, originalData);
|
224954b2
张志伟
|
153
154
|
return true;
}
|
81ad74fd
张志伟
|
155
156
157
|
if (DataTypeEnum.OD.equals(originalData.getType()) && Objects.nonNull(cluePool) && ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) {
customerCluePoolService.removeById(cluePool.getId());
}
|
8587e21d
张志伟
|
158
159
160
161
|
CustomerCluePool clue = createClueInfo(originalData, getFollowType(), customer);
customerCluePoolService.save(clue);
createFirstNotice(clue, originalData.getGenerateTime());
return true;
|
08704989
张志伟
|
162
|
}
|
8bf24bfd
张志伟
✨ 调整流失客户跟进、事故车跟进逻辑
|
163
|
|
8587e21d
张志伟
|
164
165
166
167
168
|
@Override
@Transactional(rollbackFor = Exception.class)
public void updateTask(Long customerId) {
Customer customer = customerService.queryById(customerId);
if (Objects.isNull(customer) || Objects.isNull(customer.getAdviserId()) || Objects.isNull(customer.getShopId())) {
|
8bf24bfd
张志伟
✨ 调整流失客户跟进、事故车跟进逻辑
|
169
170
|
return;
}
|
8587e21d
张志伟
|
171
172
|
CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customerId, customer.getGroupId(), getFollowType());
super.renewalTask(customer, cluePool);
|
8bf24bfd
张志伟
✨ 调整流失客户跟进、事故车跟进逻辑
|
173
|
}
|
fa966283
张志伟
📝 v1.0.1调整
|
174
175
176
|
@Override
public FMDetailVO assemble(Long customerId) {
|
8587e21d
张志伟
|
177
|
CustomerDetailDto customerDetailDto = customerBizService.queryById(customerId);
|
fa966283
张志伟
📝 v1.0.1调整
|
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
FMDetailVO vo = new FMDetailVO();
vo.setVin(customerDetailDto.getFrameNo());
vo.setCustomerId(customerId);
vo.setName(customerDetailDto.getName());
vo.setMobile(customerDetailDto.getMobile());
vo.setRegion(MobileUtil.attribution(customerDetailDto.getMobile()));
vo.setRealMobile(customerDetailDto.getMobile());
vo.setPlateNo(customerDetailDto.getPlateNo());
vo.setAdviserId(customerDetailDto.getAdviserId());
vo.setAdviserName(customerDetailDto.getAdviserName());
vo.setCarModel(customerDetailDto.getBrandName() + " " + customerDetailDto.getSeriesName());
vo.setBuyDate(customerDetailDto.getBuyDate());
return vo;
}
|
65610b54
张志伟
|
192
|
}
|