|
|
@@ -724,18 +724,35 @@ public class CorpServiceImpl implements CorpService {
|
|
|
String msgCode = wxCpKfMsgItem.getEvent().getMsgCode();
|
|
|
//1-从接待池接入会话 4-重新接入已结束/已转接会话
|
|
|
if (changeType == 1 || changeType == 4) {
|
|
|
- CorpKfServicerSessionRecord newSession = new CorpKfServicerSessionRecord();
|
|
|
- newSession.setOpenKfId(openKfId);
|
|
|
- newSession.setServicerUserid(newServicerUserId);
|
|
|
- newSession.setExternalUserid(externalUserId);
|
|
|
- newSession.setChangeType(changeType);
|
|
|
- newSession.setServiceState(0);
|
|
|
- newSession.setStartTime(sendDate);
|
|
|
- newSession.setMsgid(msgId);
|
|
|
- corpKfServicerSessionRecordMapper.insert(newSession);
|
|
|
- //等待用户删除
|
|
|
- delQueueUser(openKfId, externalUserId, sendDate);
|
|
|
- syncUserChatSession(newSession.getId(), externalUserId);
|
|
|
+ CorpKfServicerSessionRecord beforeRecord = null;
|
|
|
+ //重新接入会话 看之前是否有自动关闭的会话 保持上下文聊天记录
|
|
|
+ if (changeType == 4 && StrUtil.isNotBlank(newServicerUserId)) {
|
|
|
+ beforeRecord = corpKfServicerSessionRecordMapper.selectOne(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServicerUserid, newServicerUserId)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getExternalUserid, externalUserId)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServiceState, 1)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getIsAutoClose, 1)
|
|
|
+ .orderByDesc(CorpKfServicerSessionRecord::getId)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (beforeRecord != null) {
|
|
|
+ beforeRecord.setServiceState(0);
|
|
|
+ corpKfServicerSessionRecordMapper.updateById(beforeRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (beforeRecord == null) {
|
|
|
+ CorpKfServicerSessionRecord newSession = new CorpKfServicerSessionRecord();
|
|
|
+ newSession.setOpenKfId(openKfId);
|
|
|
+ newSession.setServicerUserid(newServicerUserId);
|
|
|
+ newSession.setExternalUserid(externalUserId);
|
|
|
+ newSession.setChangeType(changeType);
|
|
|
+ newSession.setServiceState(0);
|
|
|
+ newSession.setStartTime(sendDate);
|
|
|
+ newSession.setMsgid(msgId);
|
|
|
+ corpKfServicerSessionRecordMapper.insert(newSession);
|
|
|
+ //等待用户删除
|
|
|
+ delQueueUser(openKfId, externalUserId, sendDate);
|
|
|
+ syncUserChatSession(newSession.getId(), externalUserId);
|
|
|
+ }
|
|
|
}
|
|
|
//2-转接会话
|
|
|
if (changeType == 2) {
|