CommonService.java
4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package cn.fw.valhalla.service.bus;
import cn.fw.valhalla.common.constant.RoleCode;
import cn.fw.valhalla.domain.db.customer.AccidentPool;
import cn.fw.valhalla.domain.db.customer.Customer;
import cn.fw.valhalla.domain.db.customer.CustomerBaseInfo;
import cn.fw.valhalla.domain.enums.FollowTypeEnum;
import cn.fw.valhalla.domain.vo.PostUserVO;
import cn.fw.valhalla.rpc.ehr.EhrRpcService;
import cn.fw.valhalla.rpc.ehr.dto.StaffInfoDTO;
import cn.fw.valhalla.rpc.erp.UserService;
import cn.fw.valhalla.rpc.erp.dto.PostUserDTO;
import cn.fw.valhalla.rpc.order.OrderRpcService;
import cn.fw.valhalla.rpc.pstn.PstnService;
import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService;
import cn.fw.valhalla.service.data.AccidentPoolService;
import cn.fw.valhalla.service.data.CustomerBaseInfoService;
import cn.fw.valhalla.service.data.CustomerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
import static cn.fw.common.businessvalidator.Validator.BV;
/**
* @author : kurisu
* @className : CommonService
* @description : 公共服务
* @date: 2020-10-22 11:07
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class CommonService {
private final UserService userService;
private final CustomerService customerService;
private final CustomerBaseInfoService customerBaseInfoService;
private final OrderRpcService orderRpcService;
private final PstnService pstnService;
private final EhrRpcService ehrRpcService;
private final AccidentPoolService accidentPoolService;
private final CustomerChangeBizService customerChangeBizService;
public List<PostUserVO> getUsers(final Long shopId, final Integer type) {
FollowTypeEnum typeEnum = FollowTypeEnum.ofValue(type);
BV.notNull(typeEnum, () -> "跟进类型错误");
List<PostUserDTO> userByRole = userService.getUserByRole(shopId, getRoleCode(typeEnum));
return userByRole.stream().map(user -> new PostUserVO(user.getUserId(), user.getUserName())).collect(Collectors.toList());
}
public void rollBack(String vin, Long groupId) {
rollBack(vin);
customerChangeBizService.rollBack(vin, groupId);
}
public void rollBack(String vin) {
//todo 去订单系统校验vin是否是退换车
}
/**
* 通过智能通话系统获取所拨打的电话号码
*
* @param userId
* @param cusId
* @param accidentCar
* @return
*/
public String call(Long userId, Long cusId, Boolean accidentCar) {
StaffInfoDTO staffInfo = ehrRpcService.queryStaffInfo(userId);
BV.notNull(staffInfo, () -> "用户身份验证异常,请重试");
String becallNo;
if (Boolean.TRUE.equals(accidentCar)) {
AccidentPool accidentPool = accidentPoolService.getById(cusId);
BV.notNull(accidentPool, () -> "用户不存在");
becallNo = accidentPool.getReportMobile();
} else {
Customer customer = customerService.queryByIdWithInvalid(cusId);
BV.notNull(customer, () -> "用户不存在");
BV.isTrue(customer.getYn(), () -> "此档案已经作废,请主动放弃本次跟进");
CustomerBaseInfo baseInfo = customerBaseInfoService.getById(customer.getBaseId());
BV.notNull(baseInfo, () -> "用户不存在");
becallNo = baseInfo.getMobile();
}
BV.isNotBlank(becallNo, () -> "客户电话号码不正确,无法拨打");
assert staffInfo != null;
BV.isNotBlank(staffInfo.getMobile(), () -> "用户电话号码不正确,无法拨打");
String virtualNumber = pstnService.virtualNumber(staffInfo.getMobile(), becallNo, staffInfo.getGroupId());
BV.isNotBlank(virtualNumber, () -> "号码不正确,无法拨号");
return virtualNumber;
}
private String getRoleCode(FollowTypeEnum followTypeEnum) {
switch (followTypeEnum) {
case AC:
return RoleCode.SGCGJ;
case IR:
return RoleCode.XBGJ;
case FM:
case RM:
default:
return RoleCode.FWGW;
}
}
}