Commit f6736d020d23b99b849a1ac447419615a20c87a1
1 parent
27de82a1
修复公共线索跟进失败的bug
Showing
1 changed file
with
21 additions
and
4 deletions
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/PublicClueTask.java
1 | 1 | package cn.fw.valhalla.controller.task; |
2 | 2 | |
3 | 3 | import cn.fw.valhalla.common.utils.DateUtil; |
4 | +import cn.fw.valhalla.domain.db.customer.AffiliationRecord; | |
4 | 5 | import cn.fw.valhalla.domain.db.pool.PublicCluePool; |
5 | 6 | import cn.fw.valhalla.domain.db.pool.PublicPool; |
6 | 7 | import cn.fw.valhalla.domain.dto.CustomerDetailDto; |
8 | +import cn.fw.valhalla.domain.enums.CustomerChangeTypeEnum; | |
7 | 9 | import cn.fw.valhalla.domain.enums.DefeatReasonEnum; |
8 | 10 | import cn.fw.valhalla.domain.enums.PublicClueStateEnum; |
9 | 11 | import cn.fw.valhalla.domain.enums.PublicPoolTypeEnum; |
10 | 12 | import cn.fw.valhalla.service.bus.cust.CustomerBizService; |
11 | 13 | import cn.fw.valhalla.service.bus.follow.PCFollowBizService; |
14 | +import cn.fw.valhalla.service.data.AffiliationRecordService; | |
12 | 15 | import cn.fw.valhalla.service.data.PublicCluePoolService; |
13 | 16 | import cn.fw.valhalla.service.data.PublicPoolService; |
14 | 17 | import cn.fw.valhalla.service.data.StammkundePoolService; |
... | ... | @@ -23,6 +26,7 @@ import org.springframework.stereotype.Component; |
23 | 26 | import org.springframework.transaction.annotation.Transactional; |
24 | 27 | import org.springframework.util.CollectionUtils; |
25 | 28 | |
29 | +import java.time.LocalDateTime; | |
26 | 30 | import java.util.Date; |
27 | 31 | import java.util.List; |
28 | 32 | import java.util.Objects; |
... | ... | @@ -43,6 +47,7 @@ public class PublicClueTask { |
43 | 47 | private final StammkundePoolService stammkundePoolService; |
44 | 48 | private final PCFollowBizService pcFollowBizService; |
45 | 49 | private final ApplicationEventPublisher eventPublisher; |
50 | + private final AffiliationRecordService affiliationRecordService; | |
46 | 51 | |
47 | 52 | @Autowired |
48 | 53 | public PublicClueTask(final PublicCluePoolService publicCluePoolService, |
... | ... | @@ -50,13 +55,15 @@ public class PublicClueTask { |
50 | 55 | final CustomerBizService customerBizService, |
51 | 56 | final StammkundePoolService stammkundePoolService, |
52 | 57 | final PCFollowBizService pcFollowBizService, |
53 | - final ApplicationEventPublisher eventPublisher) { | |
58 | + final ApplicationEventPublisher eventPublisher, | |
59 | + final AffiliationRecordService affiliationRecordService) { | |
54 | 60 | this.publicCluePoolService = publicCluePoolService; |
55 | 61 | this.publicPoolService = publicPoolService; |
56 | 62 | this.customerBizService = customerBizService; |
57 | 63 | this.stammkundePoolService = stammkundePoolService; |
58 | 64 | this.pcFollowBizService = pcFollowBizService; |
59 | 65 | this.eventPublisher = eventPublisher; |
66 | + this.affiliationRecordService = affiliationRecordService; | |
60 | 67 | } |
61 | 68 | |
62 | 69 | |
... | ... | @@ -91,11 +98,9 @@ public class PublicClueTask { |
91 | 98 | } |
92 | 99 | } |
93 | 100 | |
94 | - @Transactional(rollbackFor = Exception.class) | |
95 | 101 | public void doSomething(PublicCluePool cluePool) { |
96 | 102 | cluePool.setCloseTime(new Date()); |
97 | 103 | cluePool.setState(PublicClueStateEnum.DEFEAT); |
98 | - | |
99 | 104 | Long customerId = cluePool.getCustomerId(); |
100 | 105 | CustomerDetailDto detailDto = customerBizService.queryById(customerId); |
101 | 106 | if (Objects.isNull(detailDto)) { |
... | ... | @@ -104,13 +109,25 @@ public class PublicClueTask { |
104 | 109 | detailDto.setAdviserId(cluePool.getAdviserId()); |
105 | 110 | detailDto.setAdviserName(cluePool.getAdviserName()); |
106 | 111 | detailDto.setShopId(cluePool.getShopId()); |
112 | + AffiliationRecord record = new AffiliationRecord(); | |
113 | + record.setCustomerId(detailDto.getId()); | |
114 | + record.setType(CustomerChangeTypeEnum.DEFEAT); | |
115 | + record.setDefeatTime(DateUtil.localDateTime2Date(LocalDateTime.now())); | |
116 | + record.setOriginUserId(cluePool.getAdviserId()); | |
117 | + record.setOriginShopId(cluePool.getShopId()); | |
118 | + record.setCreateTime(DateUtil.localDateTime2Date(LocalDateTime.now())); | |
119 | + record.setReason("公共客户线索到期战败"); | |
120 | + saveData(cluePool, detailDto, record); | |
121 | + } | |
107 | 122 | |
123 | + @Transactional(rollbackFor = Exception.class) | |
124 | + public void saveData(PublicCluePool cluePool, CustomerDetailDto detailDto, AffiliationRecord record) { | |
108 | 125 | PublicPool publicPool = customerBizService.createPublicPool(detailDto, PublicPoolTypeEnum.PD, PublicPoolTypeEnum.PD.getName()); |
109 | 126 | stammkundePoolService.reject(cluePool.getCustomerId(), cluePool.getGroupId(), DefeatReasonEnum.LC); |
110 | 127 | customerBizService.move2PublicPool(detailDto.getId()); |
111 | 128 | publicPoolService.save(publicPool); |
112 | 129 | publicCluePoolService.updateById(cluePool); |
113 | - | |
130 | + affiliationRecordService.save(record); | |
114 | 131 | PublicPoolEvent poolEvent = new PublicPoolEvent(detailDto.getFrameNo(), detailDto.getGroupId()); |
115 | 132 | eventPublisher.publishEvent(poolEvent); |
116 | 133 | } | ... | ... |