Commit 80a1f50cc89973510033f803ed8e9e9565a42f97

Authored by 芋道源码
Committed by Gitee
2 parents 866b3853 60c473a3

!1001 MALL-KEFU: 完善管理端接口

Merge pull request !1001 from puhui999/develop
Showing 12 changed files with 97 additions and 64 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java
... ... @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.promotion.controller.admin.kefu;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
  6 +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
5 7 import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.conversation.KeFuConversationRespVO;
6 8 import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.conversation.KeFuConversationUpdatePinnedReqVO;
7 9 import cn.iocoder.yudao.module.promotion.service.kefu.KeFuConversationService;
... ... @@ -15,8 +17,11 @@ import org.springframework.validation.annotation.Validated;
15 17 import org.springframework.web.bind.annotation.*;
16 18  
17 19 import java.util.List;
  20 +import java.util.Map;
18 21  
19 22 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  23 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  24 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
20 25  
21 26 @Tag(name = "管理后台 - 客服会话")
22 27 @RestController
... ... @@ -26,6 +31,8 @@ public class KeFuConversationController {
26 31  
27 32 @Resource
28 33 private KeFuConversationService conversationService;
  34 + @Resource
  35 + private MemberUserApi memberUserApi;
29 36  
30 37 @PostMapping("/update-conversation-pinned")
31 38 @Operation(summary = "置顶客服会话")
... ... @@ -39,7 +46,7 @@ public class KeFuConversationController {
39 46 @Operation(summary = "删除客服会话")
40 47 @Parameter(name = "id", description = "编号", required = true)
41 48 @PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:delete')")
42   - public CommonResult<Boolean> deleteKefuConversation(@RequestParam("id") Long id) {
  49 + public CommonResult<Boolean> deleteConversation(@RequestParam("id") Long id) {
43 50 conversationService.deleteKefuConversation(id);
44 51 return success(true);
45 52 }
... ... @@ -47,8 +54,18 @@ public class KeFuConversationController {
47 54 @GetMapping("/list")
48 55 @Operation(summary = "获得客服会话列表")
49 56 @PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:query')")
50   - public CommonResult<List<KeFuConversationRespVO>> getKefuConversationPage() {
51   - return success(BeanUtils.toBean(conversationService.getKefuConversationList(), KeFuConversationRespVO.class));
  57 + public CommonResult<List<KeFuConversationRespVO>> getConversationList() {
  58 + // 查询会话列表
  59 + List<KeFuConversationRespVO> respList = BeanUtils.toBean(conversationService.getKefuConversationList(),
  60 + KeFuConversationRespVO.class);
  61 +
  62 + // 拼接数据
  63 + Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(respList, KeFuConversationRespVO::getUserId));
  64 + respList.forEach(item->{
  65 + findAndThen(userMap, item.getUserId(), memberUser-> item.setUserAvatar(memberUser.getAvatar())
  66 + .setUserNickname(memberUser.getNickname()));
  67 + });
  68 + return success(respList);
52 69 }
53 70  
54 71 }
55 72 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java
1 1 package cn.iocoder.yudao.module.promotion.controller.admin.kefu;
2 2  
  3 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
3 4 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 6 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
... ... @@ -8,6 +9,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMe
8 9 import cn.iocoder.yudao.module.promotion.controller.admin.kefu.vo.message.KeFuMessageSendReqVO;
9 10 import cn.iocoder.yudao.module.promotion.dal.dataobject.kefu.KeFuMessageDO;
10 11 import cn.iocoder.yudao.module.promotion.service.kefu.KeFuMessageService;
  12 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  13 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
11 14 import io.swagger.v3.oas.annotations.Operation;
12 15 import io.swagger.v3.oas.annotations.Parameter;
13 16 import io.swagger.v3.oas.annotations.tags.Tag;
... ... @@ -17,7 +20,13 @@ import org.springframework.security.access.prepost.PreAuthorize;
17 20 import org.springframework.validation.annotation.Validated;
18 21 import org.springframework.web.bind.annotation.*;
19 22  
  23 +import java.util.Map;
  24 +
20 25 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  26 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  27 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
  28 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
  29 +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
21 30  
22 31 @Tag(name = "管理后台 - 客服消息")
23 32 @RestController
... ... @@ -27,11 +36,14 @@ public class KeFuMessageController {
27 36  
28 37 @Resource
29 38 private KeFuMessageService messageService;
  39 + @Resource
  40 + private AdminUserApi adminUserApi;
30 41  
31 42 @PostMapping("/send")
32 43 @Operation(summary = "发送客服消息")
33 44 @PreAuthorize("@ss.hasPermission('promotion:kefu-message:send')")
34   - public CommonResult<Long> createKefuMessage(@Valid @RequestBody KeFuMessageSendReqVO sendReqVO) {
  45 + public CommonResult<Long> sendKeFuMessage(@Valid @RequestBody KeFuMessageSendReqVO sendReqVO) {
  46 + sendReqVO.setSenderId(getLoginUserId()).setSenderType(UserTypeEnum.ADMIN.getValue()); // 设置用户编号和类型
35 47 return success(messageService.sendKefuMessage(sendReqVO));
36 48 }
37 49  
... ... @@ -39,18 +51,26 @@ public class KeFuMessageController {
39 51 @Operation(summary = "更新客服消息已读状态")
40 52 @Parameter(name = "conversationId", description = "会话编号", required = true)
41 53 @PreAuthorize("@ss.hasPermission('promotion:kefu-message:update')")
42   - public CommonResult<Boolean> updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) {
43   - messageService.updateKefuMessageReadStatus(conversationId);
  54 + public CommonResult<Boolean> updateKeFuMessageReadStatus(@RequestParam("conversationId") Long conversationId) {
  55 + messageService.updateKeFuMessageReadStatus(conversationId, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
44 56 return success(true);
45 57 }
46 58  
47   - // TODO @puhui999:这个应该是某个会话,上翻、下翻;不是传统的分页哈;
48 59 @GetMapping("/page")
49 60 @Operation(summary = "获得客服消息分页")
50 61 @PreAuthorize("@ss.hasPermission('promotion:kefu-message:query')")
51   - public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid KeFuMessagePageReqVO pageReqVO) {
52   - PageResult<KeFuMessageDO> pageResult = messageService.getKefuMessagePage(pageReqVO);
53   - return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
  62 + public CommonResult<PageResult<KeFuMessageRespVO>> getKeFuMessagePage(@Valid KeFuMessagePageReqVO pageReqVO) {
  63 + // 获得数据
  64 + PageResult<KeFuMessageDO> pageResult = messageService.getKeFuMessagePage(pageReqVO);
  65 +
  66 + // 拼接数据
  67 + PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class);
  68 + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(),
  69 + item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId));
  70 + result.getList().forEach(item->{
  71 + findAndThen(userMap, item.getSenderId(), adminUser -> item.setSenderAvatar(adminUser.getAvatar()));
  72 + });
  73 + return success(result);
54 74 }
55 75  
56 76 }
57 77 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/conversation/KeFuConversationRespVO.java
... ... @@ -14,6 +14,10 @@ public class KeFuConversationRespVO {
14 14  
15 15 @Schema(description = "会话所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "8300")
16 16 private Long userId;
  17 + @Schema(description = "会话所属用户头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://yudao.com/images/avatar.jpg")
  18 + private String userAvatar;
  19 + @Schema(description = "会话所属用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
  20 + private String userNickname;
17 21  
18 22 @Schema(description = "最后聊天时间", requiredMode = Schema.RequiredMode.REQUIRED)
19 23 private LocalDateTime lastMessageTime;
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageRespVO.java
... ... @@ -18,6 +18,8 @@ public class KeFuMessageRespVO {
18 18  
19 19 @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571")
20 20 private Long senderId;
  21 + @Schema(description = "发送人头像", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://yudao.com/images/avatar.jpg")
  22 + private String senderAvatar;
21 23  
22 24 @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
23 25 private Integer senderType;
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageSendReqVO.java
... ... @@ -9,31 +9,10 @@ import lombok.Data;
9 9 @Data
10 10 public class KeFuMessageSendReqVO {
11 11  
12   - // TODO @puhui999:貌似字段多了;1)id 不用;2)senderId、senderType 不用;3)receiverId、receiverType 也不用;原因可以想下哈
13   -
14   - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23202")
15   - private Long id;
16   -
17 12 @Schema(description = "会话编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12580")
18 13 @NotNull(message = "会话编号不能为空")
19 14 private Long conversationId;
20 15  
21   - @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571")
22   - @NotNull(message = "发送人编号不能为空")
23   - private Long senderId;
24   -
25   - @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
26   - @NotNull(message = "发送人类型不能为空")
27   - private Integer senderType;
28   -
29   - @Schema(description = "接收人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29124")
30   - @NotNull(message = "接收人编号不能为空")
31   - private Long receiverId;
32   -
33   - @Schema(description = "接收人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
34   - @NotNull(message = "接收人类型不能为空")
35   - private Integer receiverType;
36   -
37 16 @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
38 17 @NotNull(message = "消息类型不能为空")
39 18 private Integer contentType;
... ... @@ -42,4 +21,11 @@ public class KeFuMessageSendReqVO {
42 21 @NotEmpty(message = "消息不能为空")
43 22 private String content;
44 23  
  24 + // ========== 后端设置的参数,前端无需传递 ==========
  25 +
  26 + @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571", hidden = true)
  27 + private Long senderId;
  28 + @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1", hidden = true)
  29 + private Integer senderType;
  30 +
45 31 }
46 32 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java
... ... @@ -43,8 +43,7 @@ public class AppKeFuMessageController {
43 43 @Parameter(name = "conversationId", description = "会话编号", required = true)
44 44 @PreAuthenticated
45 45 public CommonResult<Boolean> updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) {
46   - // TODO @puhui999:需要传递 userId;万一用户模拟一个 conversationId
47   - kefuMessageService.updateKefuMessageReadStatus(conversationId);
  46 + kefuMessageService.updateKeFuMessageReadStatus(conversationId, getLoginUserId(), UserTypeEnum.MEMBER.getValue());
48 47 return success(true);
49 48 }
50 49  
... ... @@ -52,7 +51,7 @@ public class AppKeFuMessageController {
52 51 @Operation(summary = "获得客服消息分页")
53 52 @PreAuthenticated
54 53 public CommonResult<PageResult<KeFuMessageRespVO>> getKefuMessagePage(@Valid AppKeFuMessagePageReqVO pageReqVO) {
55   - PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKefuMessagePage(pageReqVO, getLoginUserId());
  54 + PageResult<KeFuMessageDO> pageResult = kefuMessageService.getKeFuMessagePage(pageReqVO, getLoginUserId());
56 55 return success(BeanUtils.toBean(pageResult, KeFuMessageRespVO.class));
57 56 }
58 57  
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessageSendReqVO.java
... ... @@ -9,10 +9,6 @@ import lombok.Data;
9 9 @Data
10 10 public class AppKeFuMessageSendReqVO {
11 11  
12   - // TODO @puhui999:应该没有传递编号哈
13   - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23202")
14   - private Long id;
15   -
16 12 @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
17 13 @NotNull(message = "消息类型不能为空")
18 14 private Integer contentType;
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java
... ... @@ -22,18 +22,14 @@ public interface KeFuConversationMapper extends BaseMapperX&lt;KeFuConversationDO&gt;
22 22 .orderByDesc(KeFuConversationDO::getCreateTime));
23 23 }
24 24  
25   - // TODO @puhui999:这个不用单独搞个方法哈。Service 直接 new 一个对象,然后调用 update 方法。
26   - default void updateAdminUnreadMessageCountWithZero(Long id) {
  25 + default void updateAdminUnreadMessageCountIncrement(Long id) {
27 26 update(new LambdaUpdateWrapper<KeFuConversationDO>()
28 27 .eq(KeFuConversationDO::getId, id)
29   - .set(KeFuConversationDO::getAdminUnreadMessageCount, 0));
  28 + .setSql("admin_unread_message_count = admin_unread_message_count + 1"));
30 29 }
31 30  
32   - // TODO @puhui999:改成 updateAdminUnreadMessageCountIncrement 增加
33   - default void updateAdminUnreadMessageCount(Long id) {
34   - update(new LambdaUpdateWrapper<KeFuConversationDO>()
35   - .eq(KeFuConversationDO::getId, id)
36   - .setSql("admin_unread_message_count = admin_unread_message_count + 1"));
  31 + default KeFuConversationDO selectByUserId(Long userId){
  32 + return selectOne(KeFuConversationDO::getUserId, userId);
37 33 }
38 34  
39 35 }
40 36 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java
... ... @@ -56,20 +56,21 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
56 56  
57 57 // 2.1 更新管理员未读消息数
58 58 if (UserTypeEnum.MEMBER.getValue().equals(kefuMessage.getSenderType())) {
59   - conversationMapper.updateAdminUnreadMessageCount(kefuMessage.getConversationId());
  59 + conversationMapper.updateAdminUnreadMessageCountIncrement(kefuMessage.getConversationId());
60 60 }
61 61 // 2.2 会员用户发送消息时,如果管理员删除过会话则进行恢复
62   - // TODO @puhui999:其实不用判断用户类型;只要be已删除,就恢复!
63   - if (UserTypeEnum.MEMBER.getValue().equals(kefuMessage.getSenderType())
64   - && Boolean.TRUE.equals(conversation.getAdminDeleted())) {
  62 + if (Boolean.TRUE.equals(conversation.getAdminDeleted())) {
65 63 updateConversationAdminDeleted(kefuMessage.getConversationId(), Boolean.FALSE);
66 64 }
67 65 }
68 66  
69 67 @Override
70 68 public void updateAdminUnreadMessageCountWithZero(Long id) {
  69 + // 校验存在
71 70 validateKefuConversationExists(id);
72   - conversationMapper.updateAdminUnreadMessageCountWithZero(id);
  71 +
  72 + // 管理员未读消息数归零
  73 + conversationMapper.updateById(new KeFuConversationDO().setId(id).setAdminUnreadMessageCount(0));
73 74 }
74 75  
75 76 @Override
... ... @@ -107,8 +108,7 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
107 108  
108 109 @Override
109 110 public KeFuConversationDO getConversationByUserId(Long userId) {
110   - // TODO @puhui999:service 不写 dao 的逻辑哈
111   - return conversationMapper.selectOne(KeFuConversationDO::getUserId, userId);
  111 + return conversationMapper.selectByUserId(userId);
112 112 }
113 113  
114 114 }
115 115 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageService.java
... ... @@ -35,8 +35,10 @@ public interface KeFuMessageService {
35 35 * 【管理员】更新消息已读状态
36 36 *
37 37 * @param conversationId 会话编号
  38 + * @param userId 用户编号
  39 + * @param userType 用户类型
38 40 */
39   - void updateKefuMessageReadStatus(Long conversationId);
  41 + void updateKeFuMessageReadStatus(Long conversationId, Long userId, Integer userType);
40 42  
41 43 /**
42 44 * 获得客服消息分页
... ... @@ -44,7 +46,7 @@ public interface KeFuMessageService {
44 46 * @param pageReqVO 分页查询
45 47 * @return 客服消息分页
46 48 */
47   - PageResult<KeFuMessageDO> getKefuMessagePage(KeFuMessagePageReqVO pageReqVO);
  49 + PageResult<KeFuMessageDO> getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO);
48 50  
49 51 /**
50 52 * 【会员】获得客服消息分页
... ... @@ -53,6 +55,6 @@ public interface KeFuMessageService {
53 55 * @param userId 用户编号
54 56 * @return 客服消息分页
55 57 */
56   - PageResult<KeFuMessageDO> getKefuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId);
  58 + PageResult<KeFuMessageDO> getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId);
57 59  
58 60 }
59 61 \ No newline at end of file
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java
1 1 package cn.iocoder.yudao.module.promotion.service.kefu;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
  4 +import cn.hutool.core.util.ObjUtil;
4 5 import cn.hutool.core.util.StrUtil;
5 6 import cn.hutool.extra.spring.SpringUtil;
6 7 import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
... ... @@ -22,10 +23,11 @@ import org.springframework.stereotype.Service;
22 23 import org.springframework.transaction.annotation.Transactional;
23 24 import org.springframework.validation.annotation.Validated;
24 25  
25   -import java.util.Collections;
26 26 import java.util.List;
27 27  
  28 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
28 29 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
  30 +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.KEFU_CONVERSATION_NOT_EXISTS;
29 31 import static cn.iocoder.yudao.module.promotion.enums.WebSocketMessageTypeConstants.KEFU_MESSAGE_ADMIN_READ;
30 32 import static cn.iocoder.yudao.module.promotion.enums.WebSocketMessageTypeConstants.KEFU_MESSAGE_TYPE;
31 33  
... ... @@ -53,18 +55,19 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
53 55 @Transactional(rollbackFor = Exception.class)
54 56 public Long sendKefuMessage(KeFuMessageSendReqVO sendReqVO) {
55 57 // 1.1 校验会话是否存在
56   - conversationService.validateKefuConversationExists(sendReqVO.getConversationId());
  58 + KeFuConversationDO conversation = conversationService.validateKefuConversationExists(sendReqVO.getConversationId());
57 59 // 1.2 校验接收人是否存在
58   - validateReceiverExist(sendReqVO.getReceiverId(), sendReqVO.getReceiverType());
  60 + validateReceiverExist(conversation.getUserId(), UserTypeEnum.MEMBER.getValue());
59 61  
60 62 // 2.1 保存消息
61 63 KeFuMessageDO kefuMessage = BeanUtils.toBean(sendReqVO, KeFuMessageDO.class);
  64 + kefuMessage.setReceiverId(conversation.getUserId()).setReceiverType(UserTypeEnum.MEMBER.getValue()); // 设置接收人
62 65 keFuMessageMapper.insert(kefuMessage);
63 66 // 2.2 更新会话消息冗余
64 67 conversationService.updateConversationLastMessage(kefuMessage);
65 68  
66 69 // 3. 发送消息
67   - getSelf().sendAsyncMessage(sendReqVO.getReceiverType(), sendReqVO.getReceiverId(), kefuMessage);
  70 + getSelf().sendAsyncMessage(UserTypeEnum.MEMBER.getValue(), conversation.getUserId(), kefuMessage);
68 71 return kefuMessage.getId();
69 72 }
70 73  
... ... @@ -86,9 +89,13 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
86 89  
87 90 @Override
88 91 @Transactional(rollbackFor = Exception.class)
89   - public void updateKefuMessageReadStatus(Long conversationId) {
  92 + public void updateKeFuMessageReadStatus(Long conversationId, Long userId, Integer userType) {
90 93 // 1.1 校验会话是否存在
91   - conversationService.validateKefuConversationExists(conversationId);
  94 + KeFuConversationDO conversation = conversationService.validateKefuConversationExists(conversationId);
  95 + // 1.2 如果是会员端处理已读,需要传递 userId;万一用户模拟一个 conversationId
  96 + if (UserTypeEnum.MEMBER.getValue().equals(userType) && ObjUtil.notEqual(conversation.getUserId(), userId)) {
  97 + throw exception(KEFU_CONVERSATION_NOT_EXISTS);
  98 + }
92 99 // 1.2 查询会话所有的未读消息 (tips: 多个客服,一个人点了,就都点了)
93 100 List<KeFuMessageDO> messageList = keFuMessageMapper.selectListByConversationIdAndReadStatus(conversationId, Boolean.FALSE);
94 101 // 1.3 情况一:没有未读消息
... ... @@ -129,12 +136,12 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
129 136 }
130 137  
131 138 @Override
132   - public PageResult<KeFuMessageDO> getKefuMessagePage(KeFuMessagePageReqVO pageReqVO) {
  139 + public PageResult<KeFuMessageDO> getKeFuMessagePage(KeFuMessagePageReqVO pageReqVO) {
133 140 return keFuMessageMapper.selectPage(pageReqVO);
134 141 }
135 142  
136 143 @Override
137   - public PageResult<KeFuMessageDO> getKefuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId) {
  144 + public PageResult<KeFuMessageDO> getKeFuMessagePage(AppKeFuMessagePageReqVO pageReqVO, Long userId) {
138 145 // 1. 获得客服会话
139 146 KeFuConversationDO conversation = conversationService.getConversationByUserId(userId);
140 147 if (conversation == null) {
... ...
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/dto/AdminUserRespDTO.java
... ... @@ -40,5 +40,9 @@ public class AdminUserRespDTO {
40 40 * 手机号码
41 41 */
42 42 private String mobile;
  43 + /**
  44 + * 用户头像
  45 + */
  46 + private String avatar;
43 47  
44 48 }
... ...