|
@@ -1,12 +1,14 @@
|
|
|
package com.cyksj.web.controller.manage.corp.wxkf;
|
|
package com.cyksj.web.controller.manage.corp.wxkf;
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
import com.cyksj.common.annotation.Log;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
import com.cyksj.enums.BusinessType;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
|
|
+import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.corp.CorpFollowMapper;
|
|
import com.cyksj.mapper.corp.CorpFollowMapper;
|
|
|
import com.cyksj.mapper.corp.kf.CorpKfAccountUserChangeRecordMapper;
|
|
import com.cyksj.mapper.corp.kf.CorpKfAccountUserChangeRecordMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
@@ -18,6 +20,7 @@ import com.cyksj.model.views.CorpKfUserChatRecordView;
|
|
|
import com.cyksj.model.views.SysCorpFollowView;
|
|
import com.cyksj.model.views.SysCorpFollowView;
|
|
|
import com.cyksj.service.corp.kf.CorpKfService;
|
|
import com.cyksj.service.corp.kf.CorpKfService;
|
|
|
import com.cyksj.service.mange.cms.service.CmsUserService;
|
|
import com.cyksj.service.mange.cms.service.CmsUserService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.SearchResult;
|
|
import com.ejlchina.searcher.SearchResult;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
import com.ejlchina.searcher.param.Operator;
|
|
@@ -57,6 +60,10 @@ public class CorpKfController {
|
|
|
|
|
|
|
|
private final CorpKfAccountUserChangeRecordMapper corpKfAccountUserChangeRecordMapper;
|
|
private final CorpKfAccountUserChangeRecordMapper corpKfAccountUserChangeRecordMapper;
|
|
|
|
|
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加客服账号
|
|
* 添加客服账号
|
|
@@ -205,8 +212,12 @@ public class CorpKfController {
|
|
|
* 会话记录
|
|
* 会话记录
|
|
|
*/
|
|
*/
|
|
|
@GetMapping("/get/session")
|
|
@GetMapping("/get/session")
|
|
|
- public Result<SearchResult<CorpKfUserChatRecordView>> getSession(String keyword) {
|
|
|
|
|
|
|
+ public Result<SearchResult<CorpKfUserChatRecordView>> getSession(Long userId, String keyword) {
|
|
|
|
|
+ String unionId = getUnionid(userId);
|
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
|
|
|
|
|
+ if (unionId != null) {
|
|
|
|
|
+ builder.field(CorpKfUserChatRecordView::getUnionid, unionId);
|
|
|
|
|
+ }
|
|
|
if (StringUtils.isNotBlank(keyword)) {
|
|
if (StringUtils.isNotBlank(keyword)) {
|
|
|
builder.put("keyword", String.format(" and exist (select 1 from corp_kf_account_session_chat ct where ct.session_id = cr.id and ct.msg_content like '%s%%')", keyword));
|
|
builder.put("keyword", String.format(" and exist (select 1 from corp_kf_account_session_chat ct where ct.session_id = cr.id and ct.msg_content like '%s%%')", keyword));
|
|
|
}
|
|
}
|
|
@@ -291,4 +302,25 @@ public class CorpKfController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(corpKfAccountUserChangeRecord);
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(corpKfAccountUserChangeRecord);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String getUnionid(Long userId) {
|
|
|
|
|
+ String unionId = null;
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ unionId = StrUtil.EMPTY;
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(userIdList)) {
|
|
|
|
|
+ User user = userMapper.selectOne(Wrappers.lambdaQuery(User.class)
|
|
|
|
|
+ .in(User::getId, userIdList)
|
|
|
|
|
+ .ne(User::getUnionid, StrUtil.EMPTY)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ if (user != null) {
|
|
|
|
|
+ unionId = user.getUnionid();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return unionId;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|