|
@@ -571,10 +571,8 @@ public class CorpServiceImpl implements CorpService {
|
|
|
String openKfId = corpKfAccount.getOpenKfId();
|
|
String openKfId = corpKfAccount.getOpenKfId();
|
|
|
WxCpKfMsgListResp wxCpKfMsgListResp = wxCorpOps.syncMsg(corpId, cursor, token, limit, openKfId);
|
|
WxCpKfMsgListResp wxCpKfMsgListResp = wxCorpOps.syncMsg(corpId, cursor, token, limit, openKfId);
|
|
|
List<WxCpKfMsgListResp.WxCpKfMsgItem> msgList = wxCpKfMsgListResp.getMsgList();
|
|
List<WxCpKfMsgListResp.WxCpKfMsgItem> msgList = wxCpKfMsgListResp.getMsgList();
|
|
|
- List<WxCpKfMsgListResp.WxCpKfMsgItem> enterSessionList = null;
|
|
|
|
|
- List<WxCpKfMsgListResp.WxCpKfMsgItem> sessionStatusChanges = null;
|
|
|
|
|
for (WxCpKfMsgListResp.WxCpKfMsgItem item : msgList) {
|
|
for (WxCpKfMsgListResp.WxCpKfMsgItem item : msgList) {
|
|
|
- if (item.getEvent() != null && item.getEvent().getEventType().equals("enter_session")) {
|
|
|
|
|
|
|
+ if (item.getEvent() != null) {
|
|
|
//会话事件
|
|
//会话事件
|
|
|
if (item.getEvent().getEventType().equals("enter_session")) {
|
|
if (item.getEvent().getEventType().equals("enter_session")) {
|
|
|
//进入会话事件
|
|
//进入会话事件
|
|
@@ -598,43 +596,29 @@ public class CorpServiceImpl implements CorpService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void syncKfChatMsg(WxCpKfMsgListResp.WxCpKfMsgItem item) throws Exception {
|
|
private void syncKfChatMsg(WxCpKfMsgListResp.WxCpKfMsgItem item) throws Exception {
|
|
|
- String openKfid = item.getOpenKfid();
|
|
|
|
|
- //客户id
|
|
|
|
|
- String externalUserId = item.getExternalUserId();
|
|
|
|
|
- //接待人员id
|
|
|
|
|
- String servicerUserId = item.getServicerUserId();
|
|
|
|
|
- //消息来源。3-微信客户发送的消息 4-系统推送的事件消息 5-接待人员在企业微信客户端发送的消息
|
|
|
|
|
- Integer origin = item.getOrigin();
|
|
|
|
|
- //发送时间
|
|
|
|
|
- Long sendTime = item.getSendTime();
|
|
|
|
|
- //消息id
|
|
|
|
|
- String msgId = item.getMsgId();
|
|
|
|
|
- //消息类型
|
|
|
|
|
- String msgType = item.getMsgType();
|
|
|
|
|
CorpKfAccountSessionChat corpKfAccountSessionChat = new CorpKfAccountSessionChat();
|
|
CorpKfAccountSessionChat corpKfAccountSessionChat = new CorpKfAccountSessionChat();
|
|
|
- corpKfAccountSessionChat.setOpenKfId(openKfid);
|
|
|
|
|
- corpKfAccountSessionChat.setMsgid(msgId);
|
|
|
|
|
- corpKfAccountSessionChat.setServicerUserid(servicerUserId);
|
|
|
|
|
- corpKfAccountSessionChat.setExternalUserid(externalUserId);
|
|
|
|
|
- corpKfAccountSessionChat.setOrign(origin);
|
|
|
|
|
- corpKfAccountSessionChat.setMsgType(msgType);
|
|
|
|
|
- corpKfAccountSessionChat.setSendTime(sendTime);
|
|
|
|
|
- corpKfAccountSessionChat.setSendDate(DateTime.of(sendTime * 1000));
|
|
|
|
|
|
|
+ Boolean record = false;
|
|
|
//文本
|
|
//文本
|
|
|
if (item.getText() != null) {
|
|
if (item.getText() != null) {
|
|
|
corpKfAccountSessionChat.setMsgContent(item.getText().getContent());
|
|
corpKfAccountSessionChat.setMsgContent(item.getText().getContent());
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getMergedMsg() != null) {
|
|
} else if (item.getMergedMsg() != null) {
|
|
|
//聊天记录 转发
|
|
//聊天记录 转发
|
|
|
|
|
+ corpKfAccountSessionChat.setLinkTitle(item.getMergedMsg().getTitle());
|
|
|
corpKfAccountSessionChat.setMsgContent(Jsons.toJson(item.getMergedMsg().getItem()));
|
|
corpKfAccountSessionChat.setMsgContent(Jsons.toJson(item.getMergedMsg().getItem()));
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getVideo() != null) {
|
|
} else if (item.getVideo() != null) {
|
|
|
//视频记录
|
|
//视频记录
|
|
|
setMediaUrl(corpKfAccountSessionChat, item.getVideo().getMedia_id());
|
|
setMediaUrl(corpKfAccountSessionChat, item.getVideo().getMedia_id());
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getFile() != null) {
|
|
} else if (item.getFile() != null) {
|
|
|
//文件
|
|
//文件
|
|
|
setMediaUrl(corpKfAccountSessionChat, item.getFile().getMedia_id());
|
|
setMediaUrl(corpKfAccountSessionChat, item.getFile().getMedia_id());
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getImage() != null) {
|
|
} else if (item.getImage() != null) {
|
|
|
//图片
|
|
//图片
|
|
|
setMediaUrl(corpKfAccountSessionChat, item.getImage().getMedia_id());
|
|
setMediaUrl(corpKfAccountSessionChat, item.getImage().getMedia_id());
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getLink() != null) {
|
|
} else if (item.getLink() != null) {
|
|
|
//链接
|
|
//链接
|
|
|
WxCorpLinkMsg link = item.getLink();
|
|
WxCorpLinkMsg link = item.getLink();
|
|
@@ -642,12 +626,37 @@ public class CorpServiceImpl implements CorpService {
|
|
|
corpKfAccountSessionChat.setLinkDesc(link.getDesc());
|
|
corpKfAccountSessionChat.setLinkDesc(link.getDesc());
|
|
|
corpKfAccountSessionChat.setLinkUrl(link.getUrl());
|
|
corpKfAccountSessionChat.setLinkUrl(link.getUrl());
|
|
|
corpKfAccountSessionChat.setLinkPicUrl(link.getPic_url());
|
|
corpKfAccountSessionChat.setLinkPicUrl(link.getPic_url());
|
|
|
|
|
+ record = true;
|
|
|
} else if (item.getMsgmenu() != null) {
|
|
} else if (item.getMsgmenu() != null) {
|
|
|
//菜单 结束语统计
|
|
//菜单 结束语统计
|
|
|
-
|
|
|
|
|
|
|
+ corpKfAccountSessionChat.setMsgContent(Jsons.toJson(item.getMsgmenu()));
|
|
|
|
|
+ record = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (record) {
|
|
|
|
|
+ //新增
|
|
|
|
|
+ String openKfid = item.getOpenKfid();
|
|
|
|
|
+ //客户id
|
|
|
|
|
+ String externalUserId = item.getExternalUserId();
|
|
|
|
|
+ //接待人员id
|
|
|
|
|
+ String servicerUserId = item.getServicerUserId();
|
|
|
|
|
+ //消息来源。3-微信客户发送的消息 4-系统推送的事件消息 5-接待人员在企业微信客户端发送的消息
|
|
|
|
|
+ Integer origin = item.getOrigin();
|
|
|
|
|
+ //发送时间
|
|
|
|
|
+ Long sendTime = item.getSendTime();
|
|
|
|
|
+ //消息id
|
|
|
|
|
+ String msgId = item.getMsgId();
|
|
|
|
|
+ //消息类型
|
|
|
|
|
+ String msgType = item.getMsgType();
|
|
|
|
|
+ corpKfAccountSessionChat.setOpenKfId(openKfid);
|
|
|
|
|
+ corpKfAccountSessionChat.setMsgid(msgId);
|
|
|
|
|
+ corpKfAccountSessionChat.setServicerUserid(servicerUserId);
|
|
|
|
|
+ corpKfAccountSessionChat.setExternalUserid(externalUserId);
|
|
|
|
|
+ corpKfAccountSessionChat.setOrign(origin);
|
|
|
|
|
+ corpKfAccountSessionChat.setMsgType(msgType);
|
|
|
|
|
+ corpKfAccountSessionChat.setSendTime(sendTime);
|
|
|
|
|
+ corpKfAccountSessionChat.setSendDate(DateTime.of(sendTime * 1000));
|
|
|
|
|
+ saveChatMsg(corpKfAccountSessionChat);
|
|
|
}
|
|
}
|
|
|
- //新增
|
|
|
|
|
- saveChatMsg(corpKfAccountSessionChat);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void syncSessionSatisfaction(String openKfId, List<WxCpKfMsgListResp.WxCpKfMsgItem> textList, String corpId, CorpKfAccountSessionConfig corpKfAccountSessionConfig) throws Exception {
|
|
private void syncSessionSatisfaction(String openKfId, List<WxCpKfMsgListResp.WxCpKfMsgItem> textList, String corpId, CorpKfAccountSessionConfig corpKfAccountSessionConfig) throws Exception {
|
|
@@ -798,6 +807,11 @@ public class CorpServiceImpl implements CorpService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ //查询用户会话状态 0待处理就进行处理
|
|
|
|
|
+ Integer sessionStatus = wxCorpOps.getCorpKfSessionStatus(corpId, openKfId, event.getExternalUserId());
|
|
|
|
|
+ if (sessionStatus != 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
//用户是否已有会话
|
|
//用户是否已有会话
|
|
|
Integer selectCount = corpKfServicerSessionRecordMapper.selectCount(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
Integer selectCount = corpKfServicerSessionRecordMapper.selectCount(Wrappers.lambdaQuery(CorpKfServicerSessionRecord.class)
|
|
|
.eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|
|
.eq(CorpKfServicerSessionRecord::getOpenKfId, openKfId)
|