|
|
@@ -119,6 +119,9 @@ public class CorpServiceImpl implements CorpService {
|
|
|
@Autowired
|
|
|
private CorpKfAccountSyncMsgProgressMapper corpKfAccountSyncMsgProgressMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CorpKfAccountSessionChatMapper corpKfAccountSessionChatMapper;
|
|
|
+
|
|
|
@PostConstruct
|
|
|
private void init() {
|
|
|
corpMessageRouter = new CorpMessageRouter(this)
|
|
|
@@ -590,7 +593,10 @@ public class CorpServiceImpl implements CorpService {
|
|
|
if (mergedMsgs == null) {
|
|
|
mergedMsgs = new ArrayList<>();
|
|
|
}
|
|
|
- mergedMsgs.add(item.getMergedMsg());
|
|
|
+ WxCorpChatMsg mergedMsg = item.getMergedMsg();
|
|
|
+ mergedMsg.setServicer_userid(item.getServicerUserId());
|
|
|
+ mergedMsg.setExternal_userid(item.getExternalUserId());
|
|
|
+ mergedMsgs.add(mergedMsg);
|
|
|
}
|
|
|
}
|
|
|
//进入会话事件
|
|
|
@@ -600,13 +606,32 @@ public class CorpServiceImpl implements CorpService {
|
|
|
//消息发送失败事件
|
|
|
//拒收客户消息变更事件
|
|
|
//同步客服聊天记录
|
|
|
- syncChatMsg(mergedMsgs);
|
|
|
+ syncChatMsg(openKfId, mergedMsgs);
|
|
|
corpKfAccountSyncMsgProgress.setCursor(cursor);
|
|
|
while (wxCpKfMsgListResp.getHasMore() == 1) {
|
|
|
syncCorpKfMsg(corpKfAccount, corpKfAccountSessionConfig, corpId, wxCpKfMsgListResp.getNextCursor(), token, limit, corpKfAccountSyncMsgProgress);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void syncChatMsg(String openKfId, List<WxCorpChatMsg> mergedMsgs) {
|
|
|
+ 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());
|
|
|
+ corpKfAccountSessionChatMapper.insert(corpKfAccountSessionChat);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sessionStatusChange(String corpId, String openKfId, List<WxCpKfMsgListResp.WxCpKfMsgItem> sessionStatusChanges) throws Exception {
|
|
|
if (CollUtil.isNotEmpty(sessionStatusChanges)) {
|
|
|
WxCpKfMsgListResp.WxCpKfMsgItem wxCpKfMsgItem = sessionStatusChanges.get(sessionStatusChanges.size() - 1);
|