|
|
@@ -708,30 +708,6 @@ public class CorpServiceImpl implements CorpService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void syncChatMsg(String openKfId, List<WxCorpChatMsg> mergedMsgs) {
|
|
|
- if (mergedMsgs == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- CorpKfAccountSessionChat corpKfAccountSessionChat = null;
|
|
|
- for (WxCorpChatMsg mergedMsg : mergedMsgs) {
|
|
|
- String servicerUserid = mergedMsg.getServicer_userid();
|
|
|
- String externalUserid = mergedMsg.getExternal_userid();
|
|
|
- for (WxCorpChatMsg.Item item : mergedMsg.getItem()) {
|
|
|
- corpKfAccountSessionChat = new CorpKfAccountSessionChat();
|
|
|
- corpKfAccountSessionChat.setExternalUserid(externalUserid);
|
|
|
- corpKfAccountSessionChat.setServicerUserid(servicerUserid);
|
|
|
- corpKfAccountSessionChat.setSenderName(item.getSender_name());
|
|
|
- corpKfAccountSessionChat.setSendTime(item.getSend_time());
|
|
|
- corpKfAccountSessionChat.setOpenKfId(openKfId);
|
|
|
- corpKfAccountSessionChat.setMsgType(item.getMsgtype());
|
|
|
- corpKfAccountSessionChat.setMsgContent(item.getMsg_content());
|
|
|
- corpKfAccountSessionChat.setMsgid(mergedMsg.getMsgid());
|
|
|
- corpKfAccountSessionChat.setOrign(mergedMsg.getOrigin());
|
|
|
- corpKfAccountSessionChatMapper.insert(corpKfAccountSessionChat);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void sessionStatusChange(String corpId, String openKfId, WxCpKfMsgListResp.WxCpKfMsgItem wxCpKfMsgItem, CorpKfAccountSessionConfig corpKfAccountSessionConfig) throws Exception {
|
|
|
WxCpKfEventMsg event = wxCpKfMsgItem.getEvent();
|
|
|
Integer changeType = event.getChangeType();
|
|
|
@@ -749,6 +725,8 @@ public class CorpServiceImpl implements CorpService {
|
|
|
newSession.setServiceState(0);
|
|
|
newSession.setMsgId(msgId);
|
|
|
corpKfServicerSessionRecordMapper.insert(newSession);
|
|
|
+ //等待用户删除
|
|
|
+ delQueueUser(openKfId, externalUserId);
|
|
|
}
|
|
|
//2-转接会话
|
|
|
if (changeType == 2) {
|
|
|
@@ -764,30 +742,6 @@ public class CorpServiceImpl implements CorpService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Throwable.class)
|
|
|
- public void assignWaitingQueueUser(String corpId, String openKfId, String servicerUserid, CorpKfAccountSessionConfig corpKfAccountSessionConfig) throws Exception {
|
|
|
- CorpKfWaitingQueueUser corpKfWaitingQueueUser = corpKfWaitingQueueUserMapper.selectOne(Wrappers.lambdaQuery(CorpKfWaitingQueueUser.class)
|
|
|
- .last("limit 1"));
|
|
|
- if (corpKfWaitingQueueUser == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- String externalUserid = corpKfWaitingQueueUser.getExternalUserid();
|
|
|
- Integer selectCount = corpKfServicerSessionRecordMapper.selectCount(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
- .eq(CorpKfServicerSessionRecord::getExternalUserid, corpKfWaitingQueueUser.getExternalUserid()));
|
|
|
- if (selectCount == 0) {
|
|
|
- if (corpKfAccountSessionConfig != null) {
|
|
|
- Integer maxNum = corpKfServicerSessionRecordMapper.selectCount(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
- .eq(CorpKfServicerSessionRecord::getServicerUserid, servicerUserid)
|
|
|
- .eq(CorpKfServicerSessionRecord::getServiceState, 0));
|
|
|
- if (maxNum < corpKfAccountSessionConfig.getMaxNum()) {
|
|
|
- //记录新的客服会话
|
|
|
- transCorpKfSessionToServicer(corpId, openKfId, servicerUserid, externalUserid, null, 3);
|
|
|
- corpKfWaitingQueueUserMapper.deleteById(corpKfWaitingQueueUser.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* enter_session 会话事件
|
|
|
*/
|
|
|
@@ -835,6 +789,8 @@ public class CorpServiceImpl implements CorpService {
|
|
|
corpKfServicerSessionRecordMapper.insert(corpKfServicerSessionRecord);
|
|
|
//调用微信客服接口 变更会话状态
|
|
|
wxCorpOps.transCorpKfSessionToServicer(corpId, openKfId, userid, externalUserId, serviceState);
|
|
|
+ //等待用户删除
|
|
|
+ delQueueUser(openKfId, externalUserId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -990,4 +946,17 @@ public class CorpServiceImpl implements CorpService {
|
|
|
corpKfServicerSessionRecordMapper.updateById(corpKfServicerSessionRecord);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除等待池中用户
|
|
|
+ * @param openKfId
|
|
|
+ * @param externalUserid
|
|
|
+ */
|
|
|
+ public void delQueueUser(String openKfId, String externalUserid) {
|
|
|
+ //等待用户删除
|
|
|
+ Optional.ofNullable(corpKfWaitingQueueUserMapper.selectOne(Wrappers.lambdaQuery(CorpKfWaitingQueueUser.class)
|
|
|
+ .eq(CorpKfWaitingQueueUser::getOpenKfId, openKfId)
|
|
|
+ .eq(CorpKfWaitingQueueUser::getExternalUserid, externalUserid)
|
|
|
+ .last("limit 1"))).ifPresent(queueUser -> corpKfWaitingQueueUserMapper.deleteById(queueUser.getId()));
|
|
|
+ }
|
|
|
}
|