mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-01 02:38:43 +08:00 
			
		
		
		
	【代码评审】MALL:review 客服的实现
This commit is contained in:
		| @@ -61,10 +61,8 @@ public class KeFuConversationController { | ||||
|  | ||||
|         // 拼接数据 | ||||
|         Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(respList, KeFuConversationRespVO::getUserId)); | ||||
|         respList.forEach(item->{ | ||||
|             findAndThen(userMap, item.getUserId(), memberUser-> item.setUserAvatar(memberUser.getAvatar()) | ||||
|                     .setUserNickname(memberUser.getNickname())); | ||||
|         }); | ||||
|         respList.forEach(item-> findAndThen(userMap, item.getUserId(), | ||||
|                 memberUser-> item.setUserAvatar(memberUser.getAvatar()).setUserNickname(memberUser.getNickname()))); | ||||
|         return success(respList); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -67,9 +67,8 @@ public class KeFuMessageController { | ||||
|         PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class); | ||||
|         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(), | ||||
|                 item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId)); | ||||
|         result.getList().forEach(item->{ | ||||
|             findAndThen(userMap, item.getSenderId(), adminUser -> item.setSenderAvatar(adminUser.getAvatar())); | ||||
|         }); | ||||
|         result.getList().forEach(item-> findAndThen(userMap, item.getSenderId(), | ||||
|                 user -> item.setSenderAvatar(user.getAvatar()))); | ||||
|         return success(result); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -23,9 +23,9 @@ public class KeFuMessageSendReqVO { | ||||
|  | ||||
|     // ========== 后端设置的参数,前端无需传递 ========== | ||||
|  | ||||
|     @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571", hidden = true) | ||||
|     @Schema(description = "发送人编号", example = "24571", hidden = true) | ||||
|     private Long senderId; | ||||
|     @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1", hidden = true) | ||||
|     @Schema(description = "发送人类型", example = "1", hidden = true) | ||||
|     private Integer senderType; | ||||
|  | ||||
| } | ||||
| @@ -28,7 +28,7 @@ public interface KeFuConversationMapper extends BaseMapperX<KeFuConversationDO> | ||||
|                 .setSql("admin_unread_message_count = admin_unread_message_count + 1")); | ||||
|     } | ||||
|  | ||||
|     default KeFuConversationDO selectByUserId(Long userId){ | ||||
|     default KeFuConversationDO selectByUserId(Long userId) { | ||||
|         return selectOne(KeFuConversationDO::getUserId, userId); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -39,7 +39,7 @@ public interface KeFuConversationService { | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      */ | ||||
|     void updateAdminUnreadMessageCountWithZero(Long id); | ||||
|     void updateAdminUnreadMessageCountToZero(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 【管理员】更新会话对于管理员是否可见 | ||||
|   | ||||
| @@ -65,10 +65,10 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateAdminUnreadMessageCountWithZero(Long id) { | ||||
|     public void updateAdminUnreadMessageCountToZero(Long id) { | ||||
|         // 校验存在 | ||||
|         validateKefuConversationExists(id); | ||||
|          | ||||
|  | ||||
|         // 管理员未读消息数归零 | ||||
|         conversationMapper.updateById(new KeFuConversationDO().setId(id).setAdminUnreadMessageCount(0)); | ||||
|     } | ||||
|   | ||||
| @@ -96,9 +96,8 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | ||||
|         if (UserTypeEnum.MEMBER.getValue().equals(userType) && ObjUtil.notEqual(conversation.getUserId(), userId)) { | ||||
|             throw exception(KEFU_CONVERSATION_NOT_EXISTS); | ||||
|         } | ||||
|         // 1.2 查询会话所有的未读消息 (tips: 多个客服,一个人点了,就都点了) | ||||
|         // 1.3 查询会话所有的未读消息 (tips: 多个客服,一个人点了,就都点了) | ||||
|         List<KeFuMessageDO> messageList = keFuMessageMapper.selectListByConversationIdAndReadStatus(conversationId, Boolean.FALSE); | ||||
|         // 1.3 情况一:没有未读消息 | ||||
|         if (CollUtil.isEmpty(messageList)) { | ||||
|             return; | ||||
|         } | ||||
| @@ -107,7 +106,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService { | ||||
|         keFuMessageMapper.updateReadStatusBatchByIds(convertSet(messageList, KeFuMessageDO::getId), | ||||
|                 new KeFuMessageDO().setReadStatus(Boolean.TRUE)); | ||||
|         // 2.2 将管理员未读消息计数更新为零 | ||||
|         conversationService.updateAdminUnreadMessageCountWithZero(conversationId); | ||||
|         conversationService.updateAdminUnreadMessageCountToZero(conversationId); | ||||
|  | ||||
|         // 2.3 发送消息通知会员,管理员已读 -> 会员更新发送的消息状态 | ||||
|         // TODO @puhui999:待定~ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV