|
@@ -1,6 +1,7 @@
|
|
|
package cn.iocoder.yudao.module.promotion.controller.app.kefu;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
@@ -141,6 +142,11 @@ public class AppKeFuConversationController {
|
|
|
sendReqVO.setContent("{\"text\":\"" + conteng + "\"}");
|
|
|
sendReqVO.setContentType(1);
|
|
|
sendReqVO.setRelUserId(id);
|
|
|
+ if (ObjUtil.isNull(sendReqVO.getConversationId())) {
|
|
|
+ KeFuConversationDO conversation =
|
|
|
+ conversationService.getOrCreateConversation(sendReqVO.getSenderId());
|
|
|
+ sendReqVO.setConversationId(conversation.getId());
|
|
|
+ }
|
|
|
kefuMessageService.sendMessage(sendReqVO);
|
|
|
}
|
|
|
|
|
@@ -149,6 +155,25 @@ public class AppKeFuConversationController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void initUser(String conteng, Long userId) {
|
|
|
+
|
|
|
+ AppKeFuMessageSendReqVO sendReqVO = new AppKeFuMessageSendReqVO();
|
|
|
+ sendReqVO.setSenderId(userId).setSenderType(UserTypeEnum.ADMIN.getValue()); //
|
|
|
+ // 设置用户编号和类型
|
|
|
+ sendReqVO.setContent("{\"text\":\"" + conteng + "\"}");
|
|
|
+ sendReqVO.setContentType(1);
|
|
|
+ sendReqVO.setRelUserId(SecurityFrameworkUtils.getLoginUserId());
|
|
|
+ if (ObjUtil.isNull(sendReqVO.getConversationId())) {
|
|
|
+ KeFuConversationDO conversation =
|
|
|
+ conversationService.getOrCreateConversation(sendReqVO.getSenderId(),
|
|
|
+ SecurityFrameworkUtils.getLoginUserId());
|
|
|
+ sendReqVO.setConversationId(conversation.getId());
|
|
|
+ }
|
|
|
+ kefuMessageService.sendMessage(sendReqVO);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/listNew")
|
|
|
@Operation(summary = "获得客服会话列表新")
|
|
|
public CommonResult<List<KeFuConversationRespVO>> getConversationListNew() {
|
|
@@ -156,7 +181,15 @@ public class AppKeFuConversationController {
|
|
|
Long me = SecurityFrameworkUtils.getLoginUserId();
|
|
|
List<KeFuConversationDO> list =
|
|
|
conversationService.getConversationList(me);
|
|
|
-
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ //初始化 1 2 3 4 发送消息
|
|
|
+ initUser("欢迎!", 1L);
|
|
|
+ initUser("欢迎1!", 2L);
|
|
|
+ initUser("欢迎2!", 3L);
|
|
|
+ initUser("欢迎3!", 4L);
|
|
|
+ list =
|
|
|
+ conversationService.getConversationList(me);
|
|
|
+ }
|
|
|
List<KeFuConversationRespVO> respList =
|
|
|
BeanUtils.toBean(list,
|
|
|
KeFuConversationRespVO.class);
|