|
|
@@ -648,15 +648,14 @@ public class CorpServiceImpl implements CorpService {
|
|
|
corpKfAccountSessionChat.setOpenKfId(openKfid);
|
|
|
corpKfAccountSessionChat.setMsgid(msgId);
|
|
|
if (StrUtil.isEmpty(servicerUserId)) {
|
|
|
- //寻找产生最近的接待记录
|
|
|
+ //寻找接待记录
|
|
|
CorpKfServicerSessionRecord corpKfServicerSessionRecord = corpKfServicerSessionRecordMapper.selectOne(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
.eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|
|
|
.eq(CorpKfServicerSessionRecord::getExternalUserid, externalUserId)
|
|
|
- .and(qr -> qr.le(CorpKfServicerSessionRecord::getStartTime, sendTime).or().ge(CorpKfServicerSessionRecord::getCloseTime, sendTime))
|
|
|
- .orderByDesc(CorpKfServicerSessionRecord::getId)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServiceState, 0)
|
|
|
.last("limit 1"));
|
|
|
if (corpKfServicerSessionRecord != null) {
|
|
|
- servicerUserId = corpKfServicerSessionRecord.getServicerUserid();
|
|
|
+ corpKfAccountSessionChat.setSessionId(corpKfServicerSessionRecord.getMsgid());
|
|
|
}
|
|
|
}
|
|
|
corpKfAccountSessionChat.setServicerUserid(servicerUserId);
|
|
|
@@ -718,6 +717,15 @@ public class CorpServiceImpl implements CorpService {
|
|
|
String msgId = wxCpKfMsgItem.getMsgId();
|
|
|
String msgCode = wxCpKfMsgItem.getEvent().getMsgCode();
|
|
|
if (changeType == 1) {
|
|
|
+ CorpKfServicerSessionRecord corpKfServicerSessionRecord = corpKfServicerSessionRecordMapper.selectOne(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getExternalUserid, externalUserId)
|
|
|
+ .le(CorpKfServicerSessionRecord::getStartTime, sendDate)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServicerUserid, 0).last("limit 1"));
|
|
|
+ //存在上一个错误接待会话
|
|
|
+ if (corpKfServicerSessionRecord != null) {
|
|
|
+ corpKfServicerSessionRecordMapper.deleteById(corpKfServicerSessionRecord.getId());
|
|
|
+ }
|
|
|
CorpKfServicerSessionRecord newSession = new CorpKfServicerSessionRecord();
|
|
|
newSession.setOpenKfId(openKfId);
|
|
|
newSession.setServicerUserid(newServicerUserId);
|
|
|
@@ -772,6 +780,18 @@ public class CorpServiceImpl implements CorpService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ Integer selectCount = corpKfServicerSessionRecordMapper.selectCount(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getMsgid, msgid));
|
|
|
+ //新增接待记录
|
|
|
+ if (selectCount == 0) {
|
|
|
+ CorpKfServicerSessionRecord corpKfServicerSessionRecord = new CorpKfServicerSessionRecord();
|
|
|
+ corpKfServicerSessionRecord.setOpenKfId(openKfId);
|
|
|
+ corpKfServicerSessionRecord.setMsgid(msgid);
|
|
|
+ corpKfServicerSessionRecord.setExternalUserid(event.getExternalUserId());
|
|
|
+ corpKfServicerSessionRecord.setStartTime(sendDate);
|
|
|
+ corpKfServicerSessionRecord.setServiceState(0);
|
|
|
+ corpKfServicerSessionRecordMapper.insert(corpKfServicerSessionRecord);
|
|
|
+ }
|
|
|
//分配接待人员
|
|
|
assignKfSession(corpId, openKfId, event.getExternalUserId(), corpKfAccountSessionConfig, sendDate, msgid);
|
|
|
}
|
|
|
@@ -796,6 +816,15 @@ public class CorpServiceImpl implements CorpService {
|
|
|
wxCorpOps.transCorpKfSessionToServicer(corpId, openKfId, userid, externalUserId, serviceState);
|
|
|
//等待用户删除
|
|
|
delQueueUser(openKfId, externalUserId, sendTime);
|
|
|
+ //同步这一次接待记录
|
|
|
+ if (serviceState == 3) {
|
|
|
+ corpKfAccountSessionChatMapper.update(null, Wrappers.lambdaUpdate(CorpKfAccountSessionChat.class)
|
|
|
+ .set(CorpKfAccountSessionChat::getSessionId, msgid)
|
|
|
+ .eq(CorpKfAccountSessionChat::getOpenKfId, openKfId)
|
|
|
+ .eq(CorpKfAccountSessionChat::getExternalUserid, externalUserId)
|
|
|
+ .le(CorpKfAccountSessionChat::getSendDate, sendTime)
|
|
|
+ .isNull(CorpKfAccountSessionChat::getSessionId));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -833,15 +862,6 @@ public class CorpServiceImpl implements CorpService {
|
|
|
if (state != 0 && state != 1) {
|
|
|
return;
|
|
|
}
|
|
|
- //用户是否已有会话
|
|
|
- CorpKfServicerSessionRecord corpKfServicerSessionRecord = corpKfServicerSessionRecordMapper.selectOne(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
- .eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|
|
|
- .eq(CorpKfServicerSessionRecord::getExternalUserid, externalUserid)
|
|
|
- .eq(CorpKfServicerSessionRecord::getServiceState, 0));
|
|
|
- if (corpKfServicerSessionRecord != null) {
|
|
|
- corpKfServicerSessionRecord.setServiceState(1);
|
|
|
- corpKfServicerSessionRecordMapper.updateById(corpKfServicerSessionRecord);
|
|
|
- }
|
|
|
//当前时间段值班客服
|
|
|
Set<String> dutyFollowIds = getDutyFollowIds(openKfId);
|
|
|
//非值班
|
|
|
@@ -939,6 +959,8 @@ public class CorpServiceImpl implements CorpService {
|
|
|
.eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|
|
|
.eq(CorpKfServicerSessionRecord::getServicerUserid, servicerUserid)
|
|
|
.eq(CorpKfServicerSessionRecord::getExternalUserid, externalUserId)
|
|
|
+ .le(CorpKfServicerSessionRecord::getStartTime, sendDate)
|
|
|
+ .eq(CorpKfServicerSessionRecord::getServiceState, 0)
|
|
|
.last("limit 1"));
|
|
|
if (corpKfServicerSessionRecord != null) {
|
|
|
corpKfServicerSessionRecord.setCloseTime(sendDate);
|