Commit b7e4f8e4609934ca972f8db5cbe41377e7c61e7d
1 parent
80a1f50c
【代码评审】MALL:review 客服的实现
Showing
7 changed files
with
12 additions
and
16 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java
| @@ -61,10 +61,8 @@ public class KeFuConversationController { | @@ -61,10 +61,8 @@ public class KeFuConversationController { | ||
| 61 | 61 | ||
| 62 | // 拼接数据 | 62 | // 拼接数据 |
| 63 | Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(respList, KeFuConversationRespVO::getUserId)); | 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 | - }); | 64 | + respList.forEach(item-> findAndThen(userMap, item.getUserId(), |
| 65 | + memberUser-> item.setUserAvatar(memberUser.getAvatar()).setUserNickname(memberUser.getNickname()))); | ||
| 68 | return success(respList); | 66 | return success(respList); |
| 69 | } | 67 | } |
| 70 | 68 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java
| @@ -67,9 +67,8 @@ public class KeFuMessageController { | @@ -67,9 +67,8 @@ public class KeFuMessageController { | ||
| 67 | PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class); | 67 | PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class); |
| 68 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(), | 68 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(), |
| 69 | item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); | 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 | - }); | 70 | + result.getList().forEach(item-> findAndThen(userMap, item.getSenderId(), |
| 71 | + user -> item.setSenderAvatar(user.getAvatar()))); | ||
| 73 | return success(result); | 72 | return success(result); |
| 74 | } | 73 | } |
| 75 | 74 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/vo/message/KeFuMessageSendReqVO.java
| @@ -23,9 +23,9 @@ public class KeFuMessageSendReqVO { | @@ -23,9 +23,9 @@ public class KeFuMessageSendReqVO { | ||
| 23 | 23 | ||
| 24 | // ========== 后端设置的参数,前端无需传递 ========== | 24 | // ========== 后端设置的参数,前端无需传递 ========== |
| 25 | 25 | ||
| 26 | - @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571", hidden = true) | 26 | + @Schema(description = "发送人编号", example = "24571", hidden = true) |
| 27 | private Long senderId; | 27 | private Long senderId; |
| 28 | - @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1", hidden = true) | 28 | + @Schema(description = "发送人类型", example = "1", hidden = true) |
| 29 | private Integer senderType; | 29 | private Integer senderType; |
| 30 | 30 | ||
| 31 | } | 31 | } |
| 32 | \ No newline at end of file | 32 | \ No newline at end of file |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java
| @@ -28,7 +28,7 @@ public interface KeFuConversationMapper extends BaseMapperX<KeFuConversationDO> | @@ -28,7 +28,7 @@ public interface KeFuConversationMapper extends BaseMapperX<KeFuConversationDO> | ||
| 28 | .setSql("admin_unread_message_count = admin_unread_message_count + 1")); | 28 | .setSql("admin_unread_message_count = admin_unread_message_count + 1")); |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - default KeFuConversationDO selectByUserId(Long userId){ | 31 | + default KeFuConversationDO selectByUserId(Long userId) { |
| 32 | return selectOne(KeFuConversationDO::getUserId, userId); | 32 | return selectOne(KeFuConversationDO::getUserId, userId); |
| 33 | } | 33 | } |
| 34 | 34 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java
| @@ -39,7 +39,7 @@ public interface KeFuConversationService { | @@ -39,7 +39,7 @@ public interface KeFuConversationService { | ||
| 39 | * | 39 | * |
| 40 | * @param id 编号 | 40 | * @param id 编号 |
| 41 | */ | 41 | */ |
| 42 | - void updateAdminUnreadMessageCountWithZero(Long id); | 42 | + void updateAdminUnreadMessageCountToZero(Long id); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * 【管理员】更新会话对于管理员是否可见 | 45 | * 【管理员】更新会话对于管理员是否可见 |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java
| @@ -65,10 +65,10 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { | @@ -65,10 +65,10 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { | ||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | @Override | 67 | @Override |
| 68 | - public void updateAdminUnreadMessageCountWithZero(Long id) { | 68 | + public void updateAdminUnreadMessageCountToZero(Long id) { |
| 69 | // 校验存在 | 69 | // 校验存在 |
| 70 | validateKefuConversationExists(id); | 70 | validateKefuConversationExists(id); |
| 71 | - | 71 | + |
| 72 | // 管理员未读消息数归零 | 72 | // 管理员未读消息数归零 |
| 73 | conversationMapper.updateById(new KeFuConversationDO().setId(id).setAdminUnreadMessageCount(0)); | 73 | conversationMapper.updateById(new KeFuConversationDO().setId(id).setAdminUnreadMessageCount(0)); |
| 74 | } | 74 | } |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuMessageServiceImpl.java
| @@ -96,9 +96,8 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | @@ -96,9 +96,8 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | ||
| 96 | if (UserTypeEnum.MEMBER.getValue().equals(userType) && ObjUtil.notEqual(conversation.getUserId(), userId)) { | 96 | if (UserTypeEnum.MEMBER.getValue().equals(userType) && ObjUtil.notEqual(conversation.getUserId(), userId)) { |
| 97 | throw exception(KEFU_CONVERSATION_NOT_EXISTS); | 97 | throw exception(KEFU_CONVERSATION_NOT_EXISTS); |
| 98 | } | 98 | } |
| 99 | - // 1.2 查询会话所有的未读消息 (tips: 多个客服,一个人点了,就都点了) | 99 | + // 1.3 查询会话所有的未读消息 (tips: 多个客服,一个人点了,就都点了) |
| 100 | List<KeFuMessageDO> messageList = keFuMessageMapper.selectListByConversationIdAndReadStatus(conversationId, Boolean.FALSE); | 100 | List<KeFuMessageDO> messageList = keFuMessageMapper.selectListByConversationIdAndReadStatus(conversationId, Boolean.FALSE); |
| 101 | - // 1.3 情况一:没有未读消息 | ||
| 102 | if (CollUtil.isEmpty(messageList)) { | 101 | if (CollUtil.isEmpty(messageList)) { |
| 103 | return; | 102 | return; |
| 104 | } | 103 | } |
| @@ -107,7 +106,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | @@ -107,7 +106,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | ||
| 107 | keFuMessageMapper.updateReadStatusBatchByIds(convertSet(messageList, KeFuMessageDO::getId), | 106 | keFuMessageMapper.updateReadStatusBatchByIds(convertSet(messageList, KeFuMessageDO::getId), |
| 108 | new KeFuMessageDO().setReadStatus(Boolean.TRUE)); | 107 | new KeFuMessageDO().setReadStatus(Boolean.TRUE)); |
| 109 | // 2.2 将管理员未读消息计数更新为零 | 108 | // 2.2 将管理员未读消息计数更新为零 |
| 110 | - conversationService.updateAdminUnreadMessageCountWithZero(conversationId); | 109 | + conversationService.updateAdminUnreadMessageCountToZero(conversationId); |
| 111 | 110 | ||
| 112 | // 2.3 发送消息通知会员,管理员已读 -> 会员更新发送的消息状态 | 111 | // 2.3 发送消息通知会员,管理员已读 -> 会员更新发送的消息状态 |
| 113 | // TODO @puhui999:待定~ | 112 | // TODO @puhui999:待定~ |