|
|
@@ -112,52 +112,57 @@ public class WechatCustomerServiceImpl implements WechatCustomerService {
|
|
|
state1 = 4;
|
|
|
wxCpKfService.transServiceState(wxCpKfMsgItem.getOpenKfid(), wxCpKfMsgItem.getExternalUserId(), state1, sysWechatCustomer.getReceptionistId());
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
WxCpKfServiceStateResp serviceState = wxCpKfService.getServiceState(wxCpKfMsgItem.getOpenKfid(), wxCpKfMsgItem.getExternalUserId());
|
|
|
Integer state1 = serviceState.getServiceState();
|
|
|
- if (workScheduleConfigService.isWorkingHours() && (state1 == 0 || state1 == 1)) {
|
|
|
+ if (state1 == 0 || state1 == 1) {
|
|
|
state1 = 3;
|
|
|
wxCpKfService.transServiceState(wxCpKfMsgItem.getOpenKfid(), wxCpKfMsgItem.getExternalUserId(), state1, sysWechatCustomer.getReceptionistId());
|
|
|
}
|
|
|
}
|
|
|
+ } else if (wxCpKfMsgItem.getOrigin() == 4) {
|
|
|
+ // 发送欢迎语
|
|
|
+ WxCpKfEventMsg event = wxCpKfMsgItem.getEvent();
|
|
|
+ if (ObjectUtils.isEmpty(event)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String scene = event.getScene();
|
|
|
+ if (!StringUtils.isEmpty(scene)) {
|
|
|
+ SysUser sysUser = sysUserService.getById(scene);
|
|
|
+ sysUser.setExternalUserId(event.getExternalUserId());
|
|
|
+ sysUserService.updateById(sysUser);
|
|
|
+ CustomerSendMsgOnEventRequest customerSendMsgOnEventRequest = CustomerSendMsgOnEventRequest.sendMsgOnEvent(sysUser, event.getWelcomeCode(), workingHours);
|
|
|
+ wechatCustomerComponents.sendMsgOnEvent(customerSendMsgOnEventRequest);
|
|
|
+ }
|
|
|
+
|
|
|
+ WxCpKfServiceStateResp serviceState = wxCpKfService.getServiceState(event.getOpenKfid(), event.getExternalUserId());
|
|
|
+ Integer state = serviceState.getServiceState();
|
|
|
+ if (workingHours && (state == 0 || state == 1)) {
|
|
|
+ state = 3;
|
|
|
+ List<SysWechatCustomer> list = sysWechatCustomerService.lambdaQuery().eq(SysWechatCustomer::getOpenKfId, wxCpKfMsgItem.getEvent().getOpenKfid()).list();
|
|
|
+ String receptionistId = list.get(0).getReceptionistId();
|
|
|
+ wxCpKfService.transServiceState(wxCpKfMsgItem.getEvent().getOpenKfid(), wxCpKfMsgItem.getEvent().getExternalUserId(), state, receptionistId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<WxCpKfMsgListResp.WxCpKfMsgItem> msgListDTOList = msgList.stream().filter(x -> "event".equals(x.getMsgType())).collect(Collectors.toList());
|
|
|
+ msgListDTOList.forEach(x -> {
|
|
|
+ try {
|
|
|
+ WxCpKfEventMsg xEvent = x.getEvent();
|
|
|
+ WxCpKfServiceStateResp wxCpKfServiceStateResp = wxCpKfService.getServiceState(xEvent.getOpenKfid(), xEvent.getExternalUserId());
|
|
|
+ Integer state = wxCpKfServiceStateResp.getServiceState();
|
|
|
|
|
|
- List<WxCpKfMsgListResp.WxCpKfMsgItem> msgListDTOList = msgList.stream().filter(x -> "event".equals(x.getMsgType())).collect(Collectors.toList());
|
|
|
- msgListDTOList.forEach(x -> {
|
|
|
- try {
|
|
|
- WxCpKfEventMsg xEvent = x.getEvent();
|
|
|
- WxCpKfServiceStateResp wxCpKfServiceStateResp = wxCpKfService.getServiceState(xEvent.getOpenKfid(), xEvent.getExternalUserId());
|
|
|
- Integer state = wxCpKfServiceStateResp.getServiceState();
|
|
|
+ if (workingHours && (state == 0 || state == 1)) {
|
|
|
+ state = 3;
|
|
|
// 休息时间
|
|
|
List<SysWechatCustomer> list = sysWechatCustomerService.lambdaQuery().eq(SysWechatCustomer::getOpenKfId, xEvent.getOpenKfid()).list();
|
|
|
String receptionistId = list.get(0).getReceptionistId();
|
|
|
- if (workScheduleConfigService.isWorkingHours() && (state == 0 || state == 1)) {
|
|
|
- state = 3;
|
|
|
- wxCpKfService.transServiceState(xEvent.getOpenKfid(), xEvent.getExternalUserId(), state, receptionistId);
|
|
|
- }
|
|
|
- } catch (WxErrorException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
+ wxCpKfService.transServiceState(xEvent.getOpenKfid(), xEvent.getExternalUserId(), state, receptionistId);
|
|
|
}
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- WxCpKfEventMsg event = wxCpKfMsgItem.getEvent();
|
|
|
- if (ObjectUtils.isEmpty(event)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- String scene = event.getScene();
|
|
|
- if (StringUtils.isEmpty(scene)) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 发送欢迎语
|
|
|
- if (wxCpKfMsgItem.getOrigin() == 4) {
|
|
|
- SysUser sysUser = sysUserService.getById(scene);
|
|
|
- sysUser.setExternalUserId(event.getExternalUserId());
|
|
|
- sysUserService.updateById(sysUser);
|
|
|
- CustomerSendMsgOnEventRequest customerSendMsgOnEventRequest = CustomerSendMsgOnEventRequest.sendMsgOnEvent(sysUser, event.getWelcomeCode(), workingHours);
|
|
|
- wechatCustomerComponents.sendMsgOnEvent(customerSendMsgOnEventRequest);
|
|
|
- }
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|