Blame view

fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/IRFollowStrategy.java 18.7 KB
65610b54   张志伟   :art:
1
2
  package cn.fw.valhalla.service.bus.follow.strategy.impl;
  
dac2e8b1   张志伟   :art:
3
  import cn.fw.common.exception.BusinessException;
725fb553   张志伟   :bug:
4
  import cn.fw.valhalla.common.constant.RoleCode;
ad395b9c   张志伟   :art:
5
  import cn.fw.valhalla.common.utils.DateUtil;
b2f969bd   张志伟   :art:
6
  import cn.fw.valhalla.common.utils.MobileUtil;
ad395b9c   张志伟   :art:
7
  import cn.fw.valhalla.domain.db.OriginalData;
23b952c1   张志伟   :art:
8
  import cn.fw.valhalla.domain.db.customer.Customer;
ad395b9c   张志伟   :art:
9
  import cn.fw.valhalla.domain.db.follow.FollowNoticeRecord;
65610b54   张志伟   :art:
10
  import cn.fw.valhalla.domain.db.follow.FollowRecord;
3ac8e84c   张志伟   :fire:
11
  import cn.fw.valhalla.domain.db.follow.FollowRecordLog;
08704989   张志伟   :art:
12
  import cn.fw.valhalla.domain.db.follow.FollowTask;
8587e21d   张志伟   :art:
13
  import cn.fw.valhalla.domain.db.pool.CustomerCluePool;
65610b54   张志伟   :art:
14
  import cn.fw.valhalla.domain.dto.CustomerDetailDto;
b2f969bd   张志伟   :art:
15
  import cn.fw.valhalla.domain.dto.FollowAttachmentDTO;
ad395b9c   张志伟   :art:
16
  import cn.fw.valhalla.domain.enums.*;
b2f969bd   张志伟   :art:
17
  import cn.fw.valhalla.domain.vo.follow.*;
ad395b9c   张志伟   :art:
18
  import cn.fw.valhalla.domain.vo.setting.SettingVO;
65610b54   张志伟   :art:
19
  import cn.fw.valhalla.rpc.angel.dto.InsuranceDTO;
725fb553   张志伟   :bug:
20
  import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
68cd8666   张志伟   :bug:
21
  import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO;
23b952c1   张志伟   :art:
22
  import cn.fw.valhalla.rpc.oop.dto.ShopDTO;
65610b54   张志伟   :art:
23
  import cn.fw.valhalla.service.bus.follow.strategy.AbstractFollowStrategy;
fa966283   张志伟   📝 v1.0.1调整
24
  import cn.fw.valhalla.service.event.CancelApproveEvent;
08704989   张志伟   :art:
25
  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
65610b54   张志伟   :art:
26
27
  import lombok.extern.slf4j.Slf4j;
  import org.springframework.stereotype.Component;
08704989   张志伟   :art:
28
  import org.springframework.transaction.annotation.Transactional;
65610b54   张志伟   :art:
29
30
  import org.springframework.util.CollectionUtils;
  
ad395b9c   张志伟   :art:
31
  import java.sql.Timestamp;
3a2863b4   张志伟   :art:
32
  import java.time.LocalDateTime;
ad395b9c   张志伟   :art:
33
34
  import java.util.*;
  import java.util.stream.Collectors;
65610b54   张志伟   :art:
35
  
b2f969bd   张志伟   :art:
36
37
  import static cn.fw.common.businessvalidator.Validator.BV;
  
65610b54   张志伟   :art:
38
39
40
41
42
43
44
45
  /**
   * @author : kurisu
   * @className : IRFollowStrategy
   * @description : 续保策略
   * @date: 2020-08-17 10:48
   */
  @Slf4j
  @Component
f36f3da7   张志伟   :construction:
46
  @SuppressWarnings("Duplicates")
65610b54   张志伟   :art:
47
48
49
50
51
52
53
54
  public class IRFollowStrategy extends AbstractFollowStrategy {
      @Override
      public FollowTypeEnum getFollowType() {
          return FollowTypeEnum.IR;
      }
  
      @Override
      public List<FollowTodoListVO> getList(Integer startIndex, Integer pageSize, Long userId) {
23b952c1   张志伟   :art:
55
          List<FollowRecord> list = list(startIndex, pageSize, userId, getFollowType());
65610b54   张志伟   :art:
56
57
58
59
60
61
62
63
64
65
          if (CollectionUtils.isEmpty(list)) {
              return new ArrayList<>();
          }
          List<FollowTodoListVO> voList = new ArrayList<>();
          for (FollowRecord followRecord : list) {
              IRTodoListVO vo = new IRTodoListVO();
              vo.setId(followRecord.getId());
              vo.setTaskId(followRecord.getTaskId());
              vo.setCustomerId(followRecord.getCustomerId());
              vo.setDeadline(followRecord.getDeadline());
91c29e23   张志伟   :fire:
66
              CustomerDetailDto customerDetailDto = customerBizService.queryById(followRecord.getCustomerId());
65610b54   张志伟   :art:
67
68
              vo.setName(customerDetailDto.getName());
              vo.setCarImage(customerDetailDto.getCarImage());
6d5a775e   张志伟   :construction:
69
              vo.setPlateNo(customerDetailDto.getPlateNo());
65610b54   张志伟   :art:
70
71
72
73
74
75
76
77
78
              Optional<InsuranceDTO> insuranceDTO = queryInsuInfo(followRecord.getCustomerId());
              insuranceDTO.ifPresent(ins -> {
                  vo.setInsComName(ins.getInsurerName());
                  vo.setInsExpiration(ins.getExpiryDate());
              });
              voList.add(vo);
          }
          return voList;
      }
b2f969bd   张志伟   :art:
79
80
  
      @Override
376d3231   张志伟   ✨ 主动放弃跟进 100%
81
      public FollowDetailVO getDetail(Long id) {
b2f969bd   张志伟   :art:
82
83
          FollowRecord followRecord = followRecordService.getById(id);
          BV.notNull(followRecord, "跟进记录不存在");
fa966283   张志伟   📝 v1.0.1调整
84
          IRDetailVO vo = assemble(followRecord.getCustomerId());
3ac8e84c   张志伟   :fire:
85
86
87
88
89
          int count = followRecordLogService.count(Wrappers.<FollowRecordLog>lambdaQuery()
                  .eq(FollowRecordLog::getRecordId, followRecord.getId())
                  .eq(FollowRecordLog::getAttType, AttTypeEnum.SMART_PHONE)
          );
          vo.setHadCall(count > 0);
b2f969bd   张志伟   :art:
90
          vo.setId(followRecord.getId());
b2f969bd   张志伟   :art:
91
92
          vo.setTaskId(followRecord.getTaskId());
          vo.setDeadline(followRecord.getDeadline());
b2f969bd   张志伟   :art:
93
94
95
96
97
98
99
100
101
          return vo;
      }
  
      @Override
      public List<FollowRecordVO> getRecordList(Long taskId) {
          return super.getRecordList(taskId);
      }
  
      @Override
b2f969bd   张志伟   :art:
102
103
104
      public void uploadAtt(FollowAttachmentDTO dto, Long userId) {
          super.uploadAtt(dto, userId);
      }
08704989   张志伟   :art:
105
106
107
108
  
      @Override
      @Transactional(rollbackFor = Exception.class)
      public void cancelFollowTask(Long customerId, Date time, Long groupId) {
8587e21d   张志伟   :art:
109
110
111
112
113
114
115
          CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customerId, groupId, getFollowType());
          if (Objects.isNull(cluePool)) {
              return;
          }
          if (ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) {
              customerCluePoolService.removeById(cluePool.getId());
              followNoticeRecordService.removeByClueId(cluePool.getId());
08704989   张志伟   :art:
116
          }
8587e21d   张志伟   :art:
117
118
119
120
121
122
          if (ClueStatusEnum.ONGOING.equals(cluePool.getClueStatus())) {
              customerCluePoolService.removeById(cluePool.getId());
              followNoticeRecordService.removeByClueId(cluePool.getId());
              cancelFollowTodo(cluePool.getRefererId(), getFollowType());
          }
          //暂不考虑退单回滚的情况
08704989   张志伟   :art:
123
      }
ad395b9c   张志伟   :art:
124
125
126
127
  
      @Override
      @Transactional(rollbackFor = Exception.class)
      public void settingChanged(List<SettingVO> setting, Long groupId) {
8587e21d   张志伟   :art:
128
129
130
131
          List<CustomerCluePool> poolList = customerCluePoolService.list(Wrappers.<CustomerCluePool>lambdaQuery()
                  .eq(CustomerCluePool::getClueType, getFollowType())
                  .eq(CustomerCluePool::getGroupId, groupId)
                  .eq(CustomerCluePool::getClueStatus, ClueStatusEnum.WAITING)
ad395b9c   张志伟   :art:
132
          );
8587e21d   张志伟   :art:
133
134
  
          if (CollectionUtils.isEmpty(poolList)) {
ad395b9c   张志伟   :art:
135
136
              return;
          }
8587e21d   张志伟   :art:
137
          this.updateClue(poolList, setting);
ad395b9c   张志伟   :art:
138
139
  
          SettingVO noticeSetting = setting.stream().filter(r -> SettingTypeEnum.FIRST_NOTICE_TIME.getValue().equals(r.getType())).findFirst().orElse(new SettingVO());
8587e21d   张志伟   :art:
140
          this.updateNoticeRecord(poolList, noticeSetting);
ad395b9c   张志伟   :art:
141
142
143
      }
  
      @Override
8587e21d   张志伟   :art:
144
      protected void updateClue(List<CustomerCluePool> list, List<SettingVO> setting) {
ad395b9c   张志伟   :art:
145
146
147
148
149
150
151
152
          for (SettingVO vo : setting) {
              final Integer unit = vo.getUnit();
              final int value = Optional.ofNullable(vo.getDetailValue()).orElse(0);
              SettingUnitEnum unitEnum = SettingUnitEnum.ofValue(unit);
  
              if (SettingTypeEnum.FIRST_TRIGGER_TIME.getValue().equals(vo.getType())) {
                  if (Objects.nonNull(unitEnum) && value > 0) {
                      final int calendarType = getCalendarType(unitEnum);
8587e21d   张志伟   :art:
153
154
                      list.forEach(clue -> {
                          Date originTime = clue.getAddTime();
23b952c1   张志伟   :art:
155
                          Timestamp timestamp = DateUtil.getExpired(originTime, -1 * value, calendarType);
8587e21d   张志伟   :art:
156
                          clue.setStartTime(timestamp);
ad395b9c   张志伟   :art:
157
158
159
                      });
                  }
              }
ad395b9c   张志伟   :art:
160
          }
8587e21d   张志伟   :art:
161
          customerCluePoolService.updateBatchById(list);
ad395b9c   张志伟   :art:
162
163
164
165
166
167
168
169
170
      }
  
      /**
       * 更新服务号消息记录
       *
       * @param list
       * @param vo
       */
      @Override
8587e21d   张志伟   :art:
171
172
      protected void updateNoticeRecord(List<CustomerCluePool> list, SettingVO vo) {
          List<Long> idList = list.stream().map(CustomerCluePool::getId).collect(Collectors.toList());
ad395b9c   张志伟   :art:
173
174
          List<FollowNoticeRecord> noticeList = followNoticeRecordService.list(Wrappers.<FollowNoticeRecord>lambdaQuery()
                  .eq(FollowNoticeRecord::getStatus, SendStatusEnum.NOT_SENT)
8587e21d   张志伟   :art:
175
                  .in(FollowNoticeRecord::getClueId, idList)
ad395b9c   张志伟   :art:
176
177
178
179
180
181
182
183
          );
          Integer unit = vo.getUnit();
          int value = Optional.ofNullable(vo.getDetailValue()).orElse(0);
          SettingUnitEnum unitEnum = SettingUnitEnum.ofValue(unit);
          if (Objects.isNull(unitEnum) || value <= 0) {
              return;
          }
          final int calendarType = getCalendarType(unitEnum);
8587e21d   张志伟   :art:
184
          for (CustomerCluePool clue : list) {
ad395b9c   张志伟   :art:
185
              for (FollowNoticeRecord noticeRecord : noticeList) {
8587e21d   张志伟   :art:
186
187
                  if (clue.getId().equals(noticeRecord.getClueId())) {
                      Date originTime = clue.getAddTime();
23b952c1   张志伟   :art:
188
                      Timestamp timestamp = DateUtil.getExpired(originTime, -1 * value, calendarType);
ad395b9c   张志伟   :art:
189
190
191
192
193
194
195
                      noticeRecord.setSendTime(timestamp);
                  }
              }
          }
          followNoticeRecordService.updateBatchById(noticeList);
      }
  
23b952c1   张志伟   :art:
196
197
198
  
      @Override
      @Transactional(rollbackFor = Exception.class)
dac2e8b1   张志伟   :art:
199
      public boolean origin2task(OriginalData originalData) throws Exception {
23b952c1   张志伟   :art:
200
          Customer customer = customerService.queryById(originalData.getCustomerId());
dac2e8b1   张志伟   :art:
201
          BV.notNull(customer, () -> "档案不存在");
8587e21d   张志伟   :art:
202
203
204
          CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customer.getId(), customer.getGroupId(), getFollowType());
          completeClue(cluePool, originalData);
          CustomerCluePool clue = this.createClueInfo(originalData, getFollowType(), customer);
dac2e8b1   张志伟   :art:
205
          BV.notNull(clue, () -> "生成跟进线索失败");
8587e21d   张志伟   :art:
206
207
208
          customerCluePoolService.save(clue);
          this.createFirstNotice(clue, originalData.getGenerateTime());
          return true;
23b952c1   张志伟   :art:
209
210
      }
  
23b952c1   张志伟   :art:
211
      @Override
8587e21d   张志伟   :art:
212
213
214
      @Transactional(rollbackFor = Exception.class)
      public void updateTask(Long customerId) {
          //续保跟进与服务顾问无关
23b952c1   张志伟   :art:
215
216
      }
  
ad395b9c   张志伟   :art:
217
      @Override
23b952c1   张志伟   :art:
218
      @Transactional(rollbackFor = Exception.class)
dac2e8b1   张志伟   :art:
219
      public void closeTask(FollowTask task) throws BusinessException {
172cb4a3   张志伟   :art:
220
          task.setState(TaskStateEnum.DEFEAT);
9b497427   张志伟   :art:
221
222
223
          task.setCloseTime(new Date());
          if (Boolean.TRUE.equals(task.getRedistribution())) {
              task.setReason(TaskDefeatTypeEnum.C);
9b497427   张志伟   :art:
224
          } else {
24f07d55   张志伟   :bug:
225
              task.setReason(TaskDefeatTypeEnum.C);
9b497427   张志伟   :art:
226
227
              final Long clueId = task.getClueId();
              CustomerCluePool cluePool = customerCluePoolService.getById(clueId);
61dc3387   张志伟   :bug:
228
229
230
              if (Objects.nonNull(cluePool)) {
                  if (Boolean.FALSE.equals(cluePool.getRedistribution()) &&
                          LocalDateTime.now().isBefore((DateUtil.date2LocalDateTime(cluePool.getDeadline())))) {
24f07d55   张志伟   :bug:
231
                      task.setReason(TaskDefeatTypeEnum.B);
61dc3387   张志伟   :bug:
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
                      PostUserDTO followUser = customerChangeBizService.changeInsFollowUser(task);
                      if (Objects.isNull(followUser)) {
                          task.setReason(null);
                          task.setState(TaskStateEnum.ONGOING);
                          task.setCloseTime(null);
                          task.setDeadline(cluePool.getDeadline());
                          followTaskService.updateById(task);
                          return;
                      }
                      cluePool.setRedistribution(Boolean.TRUE);
                      customerCluePoolService.updateById(cluePool);
                      FollowTask followTask = createTask(cluePool, true);
                      followTask.setFollowUser(followUser.getUserId());
                      followTask.setFollowUserName(followUser.getUserName());
                      followTask.setFollowShop(task.getFollowShop());
                      followTaskService.save(followTask);
                      startTask(followTask, true);
                  } else {
                      cluePool.setCloseTime(new Date());
                      cluePool.setClueStatus(ClueStatusEnum.FAILURE);
                      customerCluePoolService.updateById(cluePool);
dac2e8b1   张志伟   :art:
253
                  }
9b497427   张志伟   :art:
254
255
              }
          }
a19dc9c5   张志伟   :art:
256
          followTaskService.updateById(task);
9b497427   张志伟   :art:
257
258
          CancelApproveEvent event = new CancelApproveEvent(task.getId(), ApproveTypeEnum.FOLLOW_DEFEAT);
          eventPublisher.publishEvent(event);
612d25d9   张志伟   :art:
259
260
261
262
263
264
      }
  
      @Override
      @Transactional(rollbackFor = Exception.class)
      public void overdueProcessing(FollowRecord record) {
          super.overdueProcessing(record);
23b952c1   张志伟   :art:
265
266
      }
  
fa966283   张志伟   📝 v1.0.1调整
267
268
269
270
271
272
273
      @Override
      public FollowDetailVO followPoolDetail(FollowTask task) {
          IRDetailVO vo = assemble(task.getCustomerId());
          vo.setTaskId(task.getId());
          return vo;
      }
  
23b952c1   张志伟   :art:
274
275
276
      /**
       * 生成消息推送
       *
8587e21d   张志伟   :art:
277
278
       * @param cluePool
       * @param time
23b952c1   张志伟   :art:
279
280
       */
      @Override
8587e21d   张志伟   :art:
281
      @Transactional(rollbackFor = Exception.class)
9b497427   张志伟   :art:
282
      protected void createFirstNotice(final CustomerCluePool cluePool, final Date time) {
8587e21d   张志伟   :art:
283
          if (!cluePool.getDeadline().after(cluePool.getStartTime()) || !cluePool.getDeadline().after(DateUtil.localDateTime2Date(LocalDateTime.now()))) {
9b497427   张志伟   :art:
284
              return;
3a2863b4   张志伟   :art:
285
          }
23b952c1   张志伟   :art:
286
          final FollowNoticeRecord record = new FollowNoticeRecord();
8587e21d   张志伟   :art:
287
288
          record.setClueId(cluePool.getId());
          record.setCustomerId(cluePool.getRefererId());
23b952c1   张志伟   :art:
289
          record.setStatus(SendStatusEnum.NOT_SENT);
8587e21d   张志伟   :art:
290
291
          settingBizService.querySettingByType(getFollowType(), SettingTypeEnum.FIRST_NOTICE_TIME, cluePool.getGroupId())
                  .ifPresent(r -> record.setSendTime(calDate(r, time, true)));
23b952c1   张志伟   :art:
292
          record.setCreateTime(new Date());
8587e21d   张志伟   :art:
293
          record.setFollowType(getFollowType());
9b497427   张志伟   :art:
294
          followNoticeRecordService.save(record);
23b952c1   张志伟   :art:
295
      }
ad395b9c   张志伟   :art:
296
  
8587e21d   张志伟   :art:
297
      @Override
c4ac5c54   张志伟   :sparkles:
298
      protected CustomerCluePool createClueInfo(final OriginalData originalData, FollowTypeEnum followType, Customer customer) {
8587e21d   张志伟   :art:
299
300
301
302
303
304
305
306
          final CustomerCluePool pool = new CustomerCluePool();
          pool.setClueType(followType);
          pool.setAddTime(originalData.getGenerateTime());
          pool.setClueStatus(ClueStatusEnum.WAITING);
          pool.setRedistribution(Boolean.FALSE);
          pool.setGroupId(originalData.getGroupId());
          pool.setCreateTime(new Date());
          settingBizService.querySettingByType(followType, SettingTypeEnum.FIRST_TRIGGER_TIME, originalData.getGroupId())
788d0ffd   张志伟   :bug:
307
                  .ifPresent(r -> pool.setStartTime(calDate(r, originalData.getGenerateTime(), true)));
23b952c1   张志伟   :art:
308
  
c4ac5c54   张志伟   :sparkles:
309
          pool.setDeadline(originalData.getGenerateTime());
8587e21d   张志伟   :art:
310
311
312
          pool.setRefererId(customer.getId());
          pool.setFrameNo(customer.getFrameNo());
          pool.setPlateNo(customer.getPlateNo());
23b952c1   张志伟   :art:
313
  
aa3c5e29   张志伟   :bug:
314
          ShopDTO shop = oopService.shop(customer.getShopId());
8587e21d   张志伟   :art:
315
          if (Objects.nonNull(shop)) {
ae766fec   张志伟   :bug:
316
              pool.setOriginalShopName(shop.getShortName());
23b952c1   张志伟   :art:
317
          }
8587e21d   张志伟   :art:
318
          pool.setOriginalShopId(customer.getShopId());
d70c5e5d   张志伟   :bug:
319
          List<PostUserDTO> userByRole = userService.getUserByRole(customer.getShopId(), RoleCode.XBGJ);
8587e21d   张志伟   :art:
320
          BV.isFalse(CollectionUtils.isEmpty(userByRole), () -> "该门店没有续保跟进人员");
8587e21d   张志伟   :art:
321
322
323
324
325
326
327
328
329
330
          Collections.shuffle(userByRole);
          PostUserDTO userDTO = userByRole.get(0);
          pool.setOriginalUserId(userDTO.getUserId());
          pool.setOriginalUserName(userDTO.getUserName());
          if (shop.getId().equals(customer.getShopId())) {
              Optional<PostUserDTO> dto = userByRole.stream().filter(u -> u.getUserId().equals(customer.getAdviserId())).findFirst();
              dto.ifPresent(d -> {
                  pool.setOriginalUserId(d.getUserId());
                  pool.setOriginalUserName(d.getUserName());
              });
23b952c1   张志伟   :art:
331
          }
8587e21d   张志伟   :art:
332
          return pool;
ad395b9c   张志伟   :art:
333
      }
fa966283   张志伟   📝 v1.0.1调整
334
  
68cd8666   张志伟   :bug:
335
336
337
338
339
340
341
342
343
      @Transactional(rollbackFor = Exception.class)
      @Override
      protected void completeClue(CustomerCluePool cluePool, OriginalData originalData) {
          if (Objects.isNull(cluePool)) {
              return;
          }
          if (ClueStatusEnum.COMPLETE.equals(cluePool.getClueStatus()) || ClueStatusEnum.FAILURE.equals(cluePool.getClueStatus())) {
              return;
          }
99e77aad   张志伟   :bug:
344
345
346
347
          if (ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) {
              customerCluePoolService.removeById(cluePool.getId());
              return;
          }
68cd8666   张志伟   :bug:
348
349
          LocalDateTime deadline = DateUtil.date2LocalDateTime(cluePool.getDeadline());
          if (deadline.isAfter(DateUtil.date2LocalDateTime(DateUtil.getExpiredYear(originalData.getGenerateTime(), -1)))) {
68cd8666   张志伟   :bug:
350
351
              if (cluePool.getOriginalShopId().equals(originalData.getShopId())) {
                  cluePool.setFinishUserId(cluePool.getOriginalUserId());
99e77aad   张志伟   :bug:
352
353
354
355
356
357
358
359
360
361
362
363
364
365
                  cluePool.setFinishUserName(cluePool.getOriginalUserName());
                  cluePool.setFinishShopId(cluePool.getOriginalShopId());
                  cluePool.setFinishShopName(cluePool.getOriginalShopName());
              } else {
                  UserInfoDTO user = userService.user(originalData.getUserId());
                  cluePool.setFinishUserId(originalData.getUserId());
                  if (Objects.nonNull(user)) {
                      cluePool.setFinishUserName(user.getUserName());
                  }
                  ShopDTO shop = oopService.shop(originalData.getShopId());
                  cluePool.setFinishShopId(originalData.getShopId());
                  if (Objects.nonNull(shop)) {
                      cluePool.setFinishShopName(shop.getShortName());
                  }
68cd8666   张志伟   :bug:
366
              }
135746d3   张志伟   :bug:
367
              cluePool.setCloseTime(DateUtil.getExpiredYear(originalData.getGenerateTime(), -1));
68cd8666   张志伟   :bug:
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
              cluePool.setClueStatus(ClueStatusEnum.COMPLETE);
              customerCluePoolService.updateById(cluePool);
              this.completeTask(cluePool);
          }
      }
  
      /**
       * 处理进行中的跟进任务
       *
       * @param cluePool
       * @return
       */
      @Override
      @Transactional(rollbackFor = Exception.class)
      public void completeTask(CustomerCluePool cluePool) {
          FollowTask followTask = followTaskService.queryOngoingTaskByClueId(cluePool.getId());
          if (Objects.isNull(followTask)) {
              return;
          }
          followTask.setFinishUser(cluePool.getFinishUserId());
          followTask.setFinishUserName(cluePool.getFinishUserName());
          followTask.setFinishShop(cluePool.getFinishShopId());
          followTask.setCloseTime(cluePool.getCloseTime());
          boolean equals = followTask.getFollowShop().equals(cluePool.getFinishShopId());
          followTask.setState(equals ? TaskStateEnum.COMPLETE : TaskStateEnum.DEFEAT);
          if (!equals) {
0e485f5d   张志伟   :construction_wor...
394
              followTask.setReason(TaskDefeatTypeEnum.F);
68cd8666   张志伟   :bug:
395
396
397
398
399
400
401
402
403
404
          }
          boolean succeed = followTaskService.updateById(followTask);
          if (succeed) {
              completeTodo(followTask.getId());
              followNoticeRecordService.removeByClueId(followTask.getId());
              CancelApproveEvent event = new CancelApproveEvent(followTask.getId(), ApproveTypeEnum.FOLLOW_DEFEAT);
              eventPublisher.publishEvent(event);
          }
      }
  
fa966283   张志伟   📝 v1.0.1调整
405
406
      @Override
      public IRDetailVO assemble(Long customerId) {
91c29e23   张志伟   :fire:
407
          CustomerDetailDto detailDto = customerBizService.queryById(customerId);
fa966283   张志伟   📝 v1.0.1调整
408
409
410
411
412
413
414
415
416
417
418
          IRDetailVO vo = new IRDetailVO();
          vo.setCustomerId(customerId);
          vo.setAdviserId(detailDto.getAdviserId());
          vo.setAdviserName(detailDto.getAdviserName());
          vo.setVin(detailDto.getFrameNo());
          vo.setName(detailDto.getName());
          vo.setMobile(detailDto.getMobile());
          vo.setRegion(MobileUtil.attribution(detailDto.getMobile()));
          vo.setRealMobile(detailDto.getMobile());
          vo.setPlateNo(detailDto.getPlateNo());
          vo.setCarModel(detailDto.getBrandName() + " " + detailDto.getSeriesName());
f7ea0ff7   张志伟   :construction:
419
420
421
          vo.setExpires(detailDto.getExpires());
          vo.setPeriods(detailDto.getPeriods());
          vo.setLoanCustomer(detailDto.isLoanCustomer());
fa966283   张志伟   📝 v1.0.1调整
422
423
424
425
426
427
428
429
430
          Optional<InsuranceDTO> insuranceDTO = queryInsuInfo(customerId);
          insuranceDTO.ifPresent(ins -> {
              vo.setTclInsComName(ins.getTciInsurerName());
              vo.setTclInsExpiration(ins.getTciExpiryDate());
              vo.setBusInsComName(ins.getInsurerName());
              vo.setBusInsExpiration(ins.getExpiryDate());
          });
          return vo;
      }
65610b54   张志伟   :art:
431
  }