|
|
@@ -734,9 +734,7 @@ public class CorpServiceImpl implements CorpService {
|
|
|
if (changeType == 2) {
|
|
|
//设置表中会话状态
|
|
|
setDbSessionState(openKfId, oldServicerUserId, externalUserId, sendDate, changeType, msgId, msgCode);
|
|
|
- //记录新的客服会话
|
|
|
- String newServicerUserid = wxCpKfMsgItem.getNewServicerUserid();
|
|
|
- transCorpKfSessionToServicer(corpId, openKfId, oldServicerUserId, newServicerUserid, externalUserId, changeType, 3, sendDate, msgId);
|
|
|
+ transCorpKfSessionToServicer(corpId, openKfId, oldServicerUserId, newServicerUserId, externalUserId, changeType, 3, sendDate, msgId);
|
|
|
}
|
|
|
//3-结束会话 4-重新接入已结束/已转接会话
|
|
|
if (changeType == 3 || changeType == 4) {
|
|
|
@@ -806,28 +804,32 @@ public class CorpServiceImpl implements CorpService {
|
|
|
* serviceState 0未处理 1由智能助手接待 2待接入池排队中 3由人工接待 4 已结束/未开始
|
|
|
*/
|
|
|
private void transCorpKfSessionToServicer(String corpId, String openKfId, String oldServicerUserId, String userid, String externalUserId, Integer changeType, Integer serviceState, Date sendTime, String msgid) throws Exception {
|
|
|
- //记录接待人员会话
|
|
|
- CorpKfServicerSessionRecord corpKfServicerSessionRecord = new CorpKfServicerSessionRecord();
|
|
|
- corpKfServicerSessionRecord.setOpenKfId(openKfId);
|
|
|
- corpKfServicerSessionRecord.setServiceState(0);
|
|
|
- corpKfServicerSessionRecord.setFromUserid(oldServicerUserId);
|
|
|
- corpKfServicerSessionRecord.setServicerUserid(userid);
|
|
|
- corpKfServicerSessionRecord.setExternalUserid(externalUserId);
|
|
|
- corpKfServicerSessionRecord.setChangeType(changeType);
|
|
|
- corpKfServicerSessionRecord.setStartTime(sendTime);
|
|
|
- corpKfServicerSessionRecord.setMsgid(msgid);
|
|
|
- corpKfServicerSessionRecordMapper.insert(corpKfServicerSessionRecord);
|
|
|
//调用微信客服接口 变更会话状态
|
|
|
- wxCorpOps.transCorpKfSessionToServicer(corpId, openKfId, userid, externalUserId, serviceState);
|
|
|
- //等待用户删除
|
|
|
- delQueueUser(openKfId, externalUserId, sendTime);
|
|
|
- //同步这一次接待记录
|
|
|
- if (serviceState == 3) {
|
|
|
- corpKfAccountSessionChatMapper.update(null, Wrappers.lambdaUpdate(CorpKfAccountSessionChat.class)
|
|
|
- .set(CorpKfAccountSessionChat::getSessionId, corpKfServicerSessionRecord.getId())
|
|
|
- .eq(CorpKfAccountSessionChat::getOpenKfId, openKfId)
|
|
|
- .eq(CorpKfAccountSessionChat::getExternalUserid, externalUserId)
|
|
|
- .isNull(CorpKfAccountSessionChat::getSessionId));
|
|
|
+ try {
|
|
|
+ wxCorpOps.transCorpKfSessionToServicer(corpId, openKfId, userid, externalUserId, serviceState);
|
|
|
+ //记录接待人员会话
|
|
|
+ CorpKfServicerSessionRecord corpKfServicerSessionRecord = new CorpKfServicerSessionRecord();
|
|
|
+ corpKfServicerSessionRecord.setOpenKfId(openKfId);
|
|
|
+ corpKfServicerSessionRecord.setServiceState(0);
|
|
|
+ corpKfServicerSessionRecord.setFromUserid(oldServicerUserId);
|
|
|
+ corpKfServicerSessionRecord.setServicerUserid(userid);
|
|
|
+ corpKfServicerSessionRecord.setExternalUserid(externalUserId);
|
|
|
+ corpKfServicerSessionRecord.setChangeType(changeType);
|
|
|
+ corpKfServicerSessionRecord.setStartTime(sendTime);
|
|
|
+ corpKfServicerSessionRecord.setMsgid(msgid);
|
|
|
+ corpKfServicerSessionRecordMapper.insert(corpKfServicerSessionRecord);
|
|
|
+ //等待用户删除
|
|
|
+ delQueueUser(openKfId, externalUserId, sendTime);
|
|
|
+ //同步这一次接待记录
|
|
|
+ if (serviceState == 3) {
|
|
|
+ corpKfAccountSessionChatMapper.update(null, Wrappers.lambdaUpdate(CorpKfAccountSessionChat.class)
|
|
|
+ .set(CorpKfAccountSessionChat::getSessionId, corpKfServicerSessionRecord.getId())
|
|
|
+ .eq(CorpKfAccountSessionChat::getOpenKfId, openKfId)
|
|
|
+ .eq(CorpKfAccountSessionChat::getExternalUserid, externalUserId)
|
|
|
+ .isNull(CorpKfAccountSessionChat::getSessionId));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建新的会话错误:{}", StringUtil.getErrorText(e));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -967,6 +969,7 @@ public class CorpServiceImpl implements CorpService {
|
|
|
CorpKfServicerSessionRecord corpKfServicerSessionRecord = corpKfServicerSessionRecordMapper.selectOne(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
.eq(CorpKfServicerSessionRecord::getOpenKfId, chat.getOpenKfId())
|
|
|
.eq(CorpKfServicerSessionRecord::getExternalUserid, chat.getExternalUserid())
|
|
|
+ .orderByDesc(CorpKfServicerSessionRecord::getId)
|
|
|
.eq(CorpKfServicerSessionRecord::getServiceState, 0)
|
|
|
.last("limit 1"));
|
|
|
if (corpKfServicerSessionRecord != null) chat.setSessionId(corpKfServicerSessionRecord.getId());
|