Commit 6f401c2d76d721be1046f6ab26db30c517e78477
1 parent
2fcb1932
feature(*): 公共池完成逻辑
- 公共池完成逻辑
Showing
5 changed files
with
139 additions
and
4 deletions
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/PubFollowTask.java
... | ... | @@ -11,6 +11,7 @@ import lombok.Getter; |
11 | 11 | import lombok.extern.slf4j.Slf4j; |
12 | 12 | import org.springframework.beans.factory.annotation.Value; |
13 | 13 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
14 | +import org.springframework.data.redis.core.BoundListOperations; | |
14 | 15 | import org.springframework.data.redis.core.BoundSetOperations; |
15 | 16 | import org.springframework.data.redis.core.StringRedisTemplate; |
16 | 17 | import org.springframework.scheduling.annotation.Scheduled; |
... | ... | @@ -40,6 +41,10 @@ public class PubFollowTask { |
40 | 41 | @Getter(AccessLevel.PRIVATE) |
41 | 42 | private String roleChangeNeedCloseClueKey; |
42 | 43 | |
44 | + @Value("${spring.cache.custom.global-prefix}:pub-clue:complete") | |
45 | + @Getter(AccessLevel.PRIVATE) | |
46 | + private String pubClueCompleteKey; | |
47 | + | |
43 | 48 | public PubFollowTask(final StringRedisTemplate stringRedisTemplate, |
44 | 49 | final PubFollowBizService pubFollowBizService, |
45 | 50 | final PubCluePoolService pubCluePoolService) { |
... | ... | @@ -67,6 +72,33 @@ public class PubFollowTask { |
67 | 72 | } |
68 | 73 | |
69 | 74 | /** |
75 | + * 关闭线索 | |
76 | + */ | |
77 | + @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 10) | |
78 | + public void closeClue() { | |
79 | + BoundListOperations<String, String> listOps = stringRedisTemplate.boundListOps(getPubClueCompleteKey()); | |
80 | + List<String> failList = new ArrayList<>(); | |
81 | + String idStr; | |
82 | + while ((idStr = listOps.leftPop()) != null) { | |
83 | + if (!StringUtils.isEmpty(idStr)) { | |
84 | + continue; | |
85 | + } | |
86 | + try { | |
87 | + pubFollowBizService.closeClue(idStr); | |
88 | + } catch (Exception e) { | |
89 | + if (StringUtils.isValid(idStr)) { | |
90 | + failList.add(idStr); | |
91 | + } | |
92 | + log.error("处理关闭公共池线索失败", e); | |
93 | + } | |
94 | + } | |
95 | + if (!CollectionUtils.isEmpty(failList)) { | |
96 | + String[] idArr = failList.toArray(new String[0]); | |
97 | + listOps.rightPushAll(idArr); | |
98 | + } | |
99 | + } | |
100 | + | |
101 | + /** | |
70 | 102 | * 处理角色变动战败公共池跟进线索 |
71 | 103 | */ |
72 | 104 | @Scheduled(cron = "0/20 * * * * *") | ... | ... |
fw-valhalla-server/src/main/java/cn/fw/valhalla/controller/task/PubStandTask.java
... | ... | @@ -61,7 +61,7 @@ public class PubStandTask { |
61 | 61 | /** |
62 | 62 | * 执行分配 |
63 | 63 | */ |
64 | - @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 5) | |
64 | + @Scheduled(initialDelay = 1000 * 10, fixedRate = 1000 * 8) | |
65 | 65 | public void distributeBatch() { |
66 | 66 | List<GroupDTO> groups = oopService.allGroup(); |
67 | 67 | for (GroupDTO group : groups) { | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java
1 | 1 | package cn.fw.valhalla.service.bus.cust; |
2 | 2 | |
3 | 3 | import cn.fw.common.cache.locker.DistributedLocker; |
4 | +import cn.fw.common.constant.CommonConstant; | |
4 | 5 | import cn.fw.common.web.annotation.DisLock; |
5 | 6 | import cn.fw.common.web.auth.LoginAuthBean; |
6 | 7 | import cn.fw.passport.sdk.api.param.WxBCodeParam; |
... | ... | @@ -37,11 +38,14 @@ import cn.fw.valhalla.service.data.FollowRecordService; |
37 | 38 | import cn.fw.valhalla.service.data.PublicPoolService; |
38 | 39 | import com.alibaba.fastjson.JSON; |
39 | 40 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
41 | +import lombok.AccessLevel; | |
42 | +import lombok.Getter; | |
40 | 43 | import lombok.RequiredArgsConstructor; |
41 | 44 | import lombok.extern.slf4j.Slf4j; |
42 | 45 | import org.apache.commons.lang3.tuple.Pair; |
43 | 46 | import org.redisson.api.RLock; |
44 | 47 | import org.springframework.beans.BeanUtils; |
48 | +import org.springframework.beans.factory.annotation.Value; | |
45 | 49 | import org.springframework.data.redis.core.StringRedisTemplate; |
46 | 50 | import org.springframework.stereotype.Service; |
47 | 51 | import org.springframework.transaction.annotation.Transactional; |
... | ... | @@ -78,6 +82,10 @@ public class CustomerChangeBizService extends AbstractCustomerService { |
78 | 82 | private final FollowRecordLogService followRecordLogService; |
79 | 83 | private final CommonService commonService; |
80 | 84 | |
85 | + @Value("${spring.cache.custom.global-prefix}:pub-clue:complete") | |
86 | + @Getter(AccessLevel.PRIVATE) | |
87 | + private String pubClueCompleteKey; | |
88 | + | |
81 | 89 | /** |
82 | 90 | * 生成档案变更二维码 |
83 | 91 | * |
... | ... | @@ -298,6 +306,15 @@ public class CustomerChangeBizService extends AbstractCustomerService { |
298 | 306 | if (CollectionUtils.isEmpty(dataRange) || Objects.isNull(dataRange.get(0).getRangeValue())) { |
299 | 307 | return true; |
300 | 308 | } |
309 | + String sb = customer.getFrameNo() + | |
310 | + CommonConstant.Symbol.AT + | |
311 | + adviserId + | |
312 | + CommonConstant.Symbol.AT + | |
313 | + customer.getGroupId() + | |
314 | + CommonConstant.Symbol.AT + | |
315 | + dataRange.get(0).getRangeValue(); | |
316 | + stringRedisTemplate.opsForList().rightPush(getPubClueCompleteKey(), sb); | |
317 | + | |
301 | 318 | if (adviserId.equals(customer.getAdviserId())) { |
302 | 319 | StammkundePool stammkundePool = stammkundePoolService.queryAktivAble(customer.getId(), customer.getGroupId(), customer.getShopId()); |
303 | 320 | if (Objects.nonNull(stammkundePool)) { |
... | ... | @@ -517,7 +534,7 @@ public class CustomerChangeBizService extends AbstractCustomerService { |
517 | 534 | customer.setSource(SourceTypeEnum.TO_SHOP); |
518 | 535 | customer.setYn(Boolean.TRUE); |
519 | 536 | customer.setGroupId(dto.getGroupId()); |
520 | - if(Objects.isNull(customer.getBuyDate())){ | |
537 | + if (Objects.isNull(customer.getBuyDate())) { | |
521 | 538 | customer.setBuyDate(dto.getRegDate()); |
522 | 539 | } |
523 | 540 | } | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/PubFollowStrategy.java
... | ... | @@ -10,6 +10,8 @@ import cn.fw.valhalla.domain.db.pub.PubCluePool; |
10 | 10 | import cn.fw.valhalla.domain.dto.CustomerDetailDto; |
11 | 11 | import cn.fw.valhalla.domain.enums.*; |
12 | 12 | import cn.fw.valhalla.domain.vo.setting.SettingVO; |
13 | +import cn.fw.valhalla.rpc.ehr.EhrRpcService; | |
14 | +import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO; | |
13 | 15 | import cn.fw.valhalla.rpc.oop.OopService; |
14 | 16 | import cn.fw.valhalla.rpc.oop.dto.ShopDTO; |
15 | 17 | import cn.fw.valhalla.rpc.shirasawa.ShirasawaRpcService; |
... | ... | @@ -50,6 +52,7 @@ public class PubFollowStrategy implements FollowStrategy { |
50 | 52 | private final ShirasawaRpcService shirasawaRpcService; |
51 | 53 | private final OopService oopService; |
52 | 54 | private final SettingBizService settingBizService; |
55 | + private final EhrRpcService ehrRpcService; | |
53 | 56 | |
54 | 57 | @Autowired |
55 | 58 | public PubFollowStrategy(final PubCluePoolService pubCluePoolService, |
... | ... | @@ -57,13 +60,15 @@ public class PubFollowStrategy implements FollowStrategy { |
57 | 60 | final CustomerBizService customerBizService, |
58 | 61 | final ShirasawaRpcService shirasawaRpcService, |
59 | 62 | final OopService oopService, |
60 | - final SettingBizService settingBizService) { | |
63 | + final SettingBizService settingBizService, | |
64 | + final EhrRpcService ehrRpcService) { | |
61 | 65 | this.pubCluePoolService = pubCluePoolService; |
62 | 66 | this.clueTaskService = clueTaskService; |
63 | 67 | this.customerBizService = customerBizService; |
64 | 68 | this.shirasawaRpcService = shirasawaRpcService; |
65 | 69 | this.oopService = oopService; |
66 | 70 | this.settingBizService = settingBizService; |
71 | + this.ehrRpcService = ehrRpcService; | |
67 | 72 | } |
68 | 73 | |
69 | 74 | @Override |
... | ... | @@ -103,7 +108,7 @@ public class PubFollowStrategy implements FollowStrategy { |
103 | 108 | // 公共池线索不存在这种场景 |
104 | 109 | } |
105 | 110 | |
106 | - | |
111 | + @Transactional(rollbackFor = Exception.class) | |
107 | 112 | public void startClue(final PubCluePool pubClue) { |
108 | 113 | ClueTask clueTask = new ClueTask(); |
109 | 114 | clueTask.setClueId(pubClue.getId()); |
... | ... | @@ -121,6 +126,51 @@ public class PubFollowStrategy implements FollowStrategy { |
121 | 126 | shirasawaRpcService.createFollowData(followInitDTO); |
122 | 127 | } |
123 | 128 | |
129 | + @Transactional(rollbackFor = Exception.class) | |
130 | + public void clueConvertSuccess(final PubCluePool pubClue) { | |
131 | + pubClue.setState(PublicClueStateEnum.COMPLETE); | |
132 | + pubClue.setCloseTime(LocalDateTime.now()); | |
133 | + | |
134 | + ClueTask clueTask = clueTaskService.queryOngoingTaskByClueId(pubClue.getId()); | |
135 | + if (Objects.nonNull(clueTask)) { | |
136 | + clueTask.setCloseTime(LocalDateTime.now()); | |
137 | + clueTask.setFinishUser(pubClue.getAdviserId()); | |
138 | + StaffInfoDTO infoDTO = ehrRpcService.queryStaffInfo(pubClue.getAdviserId()); | |
139 | + if (Objects.nonNull(infoDTO)) { | |
140 | + clueTask.setFinishUserName(infoDTO.getName()); | |
141 | + } | |
142 | + clueTask.setState(TaskStateEnum.COMPLETE); | |
143 | + clueTask.setFinishShop(pubClue.getShopId()); | |
144 | + boolean rpcSucess = rpcStopTask(clueTask); | |
145 | + clueTask.setRpcSuccess(rpcSucess); | |
146 | + clueTaskService.updateById(clueTask); | |
147 | + } | |
148 | + pubCluePoolService.updateById(pubClue); | |
149 | + } | |
150 | + | |
151 | + @Transactional(rollbackFor = Exception.class) | |
152 | + public void clueConvertFailed(final PubCluePool pubClue, Long userId, Long shopId) { | |
153 | + pubClue.setState(PublicClueStateEnum.DEFEAT); | |
154 | + pubClue.setCloseTime(LocalDateTime.now()); | |
155 | + | |
156 | + ClueTask clueTask = clueTaskService.queryOngoingTaskByClueId(pubClue.getId()); | |
157 | + if (Objects.nonNull(clueTask)) { | |
158 | + clueTask.setCloseTime(LocalDateTime.now()); | |
159 | + clueTask.setFinishUser(pubClue.getAdviserId()); | |
160 | + StaffInfoDTO infoDTO = ehrRpcService.queryStaffInfo(userId); | |
161 | + if (Objects.nonNull(infoDTO)) { | |
162 | + clueTask.setFinishUserName(infoDTO.getName()); | |
163 | + } | |
164 | + clueTask.setState(TaskStateEnum.DEFEAT); | |
165 | + clueTask.setReason(TaskDefeatTypeEnum.F); | |
166 | + clueTask.setFinishShop(shopId); | |
167 | + boolean rpcSucess = rpcStopTask(clueTask); | |
168 | + clueTask.setRpcSuccess(rpcSucess); | |
169 | + clueTaskService.updateById(clueTask); | |
170 | + } | |
171 | + pubCluePoolService.updateById(pubClue); | |
172 | + } | |
173 | + | |
124 | 174 | @Override |
125 | 175 | @Transactional(rollbackFor = Exception.class) |
126 | 176 | public void onRoleChangeCloseTask(final ClueTask task) { | ... | ... |
fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/pub/PubFollowBizService.java
1 | 1 | package cn.fw.valhalla.service.bus.pub; |
2 | 2 | |
3 | +import cn.fw.common.constant.CommonConstant; | |
3 | 4 | import cn.fw.valhalla.common.utils.StringUtils; |
4 | 5 | import cn.fw.valhalla.domain.db.customer.Customer; |
5 | 6 | import cn.fw.valhalla.domain.db.customer.CustomerBaseInfo; |
... | ... | @@ -117,6 +118,41 @@ public class PubFollowBizService { |
117 | 118 | } |
118 | 119 | |
119 | 120 | /** |
121 | + * 关闭线索 | |
122 | + * | |
123 | + * @param str | |
124 | + */ | |
125 | + @Transactional(rollbackFor = Exception.class) | |
126 | + public void closeClue(String str) { | |
127 | + String[] dataArr = str.split(CommonConstant.Symbol.AT); | |
128 | + if (dataArr.length < 4) { | |
129 | + log.info("关闭公共池线索失败:{}", str); | |
130 | + return; | |
131 | + } | |
132 | + String vin = dataArr[0]; | |
133 | + Long adviserId = Long.parseLong(dataArr[1]); | |
134 | + Long groupId = Long.parseLong(dataArr[2]); | |
135 | + Long shopId = Long.parseLong(dataArr[3]); | |
136 | + | |
137 | + PubCluePool pool = pubCluePoolService.getOne(Wrappers.<PubCluePool>lambdaQuery() | |
138 | + .eq(PubCluePool::getVin, vin) | |
139 | + .eq(PubCluePool::getGroupId, groupId) | |
140 | + .eq(PubCluePool::getState, PublicClueStateEnum.ONGOING) | |
141 | + , Boolean.FALSE | |
142 | + ); | |
143 | + | |
144 | + if (Objects.isNull(pool)) { | |
145 | + return; | |
146 | + } | |
147 | + if (pool.getAdviserId().equals(adviserId)) { | |
148 | + pubFollowStrategy.clueConvertSuccess(pool); | |
149 | + return; | |
150 | + } | |
151 | + pubFollowStrategy.clueConvertFailed(pool, adviserId, shopId); | |
152 | + | |
153 | + } | |
154 | + | |
155 | + /** | |
120 | 156 | * 查询最近分配的20条线索 |
121 | 157 | * |
122 | 158 | * @param userId | ... | ... |