From 866b38535eb3fb333ef8fdd8c140cedc37266f59 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 17 Jun 2024 19:41:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=E3=80=91MALL=EF=BC=9Areview=20=E5=AE=A2=E6=9C=8D=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/WebSocketMessageTypeConstants.java | 4 ++-- .../enums/kehu/KeFuMessageContentTypeEnum.java | 1 + .../admin/kefu/KeFuConversationController.java | 2 +- .../admin/kefu/KeFuMessageController.java | 3 +-- .../app/kefu/AppKeFuMessageController.java | 3 ++- .../kefu/vo/message/AppKeFuMessageSendReqVO.java | 13 ++++++++----- .../dal/mysql/kefu/KeFuConversationMapper.java | 2 ++ .../service/kefu/KeFuConversationService.java | 2 +- .../service/kefu/KeFuConversationServiceImpl.java | 8 +++++--- 9 files changed, 23 insertions(+), 15 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/WebSocketMessageTypeConstants.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/WebSocketMessageTypeConstants.java index d060998ad..4b1c34837 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/WebSocketMessageTypeConstants.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/WebSocketMessageTypeConstants.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.promotion.enums; /** - * websocket 消息类型枚举类 + * Promotion 的 WebSocket 消息类型枚举类 * * @author HUIHUI */ public interface WebSocketMessageTypeConstants { - //======================= mall 客服 ======================= + // ======================= mall 客服 ======================= String KEFU_MESSAGE_TYPE = "kefu_message_type"; // 客服消息类型 String KEFU_MESSAGE_ADMIN_READ = "kefu_message_read_status_change"; // 客服消息管理员已读 diff --git a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java index 616630c2e..51ee59332 100644 --- a/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java +++ b/yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/kehu/KeFuMessageContentTypeEnum.java @@ -20,6 +20,7 @@ public enum KeFuMessageContentTypeEnum implements IntArrayValuable { VOICE(3, "语音消息"), VIDEO(4, "视频消息"), SYSTEM(5, "系统消息"), + // ========== 商城特殊消息 ========== PRODUCT(10, "商品消息"), ORDER(11, "订单消息"); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java index 5a1d9e77f..55042f547 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuConversationController.java @@ -31,7 +31,7 @@ public class KeFuConversationController { @Operation(summary = "置顶客服会话") @PreAuthorize("@ss.hasPermission('promotion:kefu-conversation:update')") public CommonResult updateConversationPinned(@Valid @RequestBody KeFuConversationUpdatePinnedReqVO updateReqVO) { - conversationService.updateAdminPinned(updateReqVO); + conversationService.updateConversationPinnedByAdmin(updateReqVO); return success(true); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java index 04a32e156..58de6c476 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/kefu/KeFuMessageController.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.promotion.controller.admin.kefu; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -37,7 +36,7 @@ public class KeFuMessageController { } @PutMapping("/update-read-status") - @Operation(summary = "更新会员客服消息已读状态") + @Operation(summary = "更新客服消息已读状态") @Parameter(name = "conversationId", description = "会话编号", required = true) @PreAuthorize("@ss.hasPermission('promotion:kefu-message:update')") public CommonResult updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) { diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java index 8b54c8db4..71eb8bdb1 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/AppKeFuMessageController.java @@ -33,7 +33,7 @@ public class AppKeFuMessageController { @PostMapping("/send") @Operation(summary = "发送客服消息") @PreAuthenticated - public CommonResult createKefuMessage(@Valid @RequestBody AppKeFuMessageSendReqVO sendReqVO) { + public CommonResult sendKefuMessage(@Valid @RequestBody AppKeFuMessageSendReqVO sendReqVO) { sendReqVO.setSenderId(getLoginUserId()).setSenderType(UserTypeEnum.MEMBER.getValue()); // 设置用户编号和类型 return success(kefuMessageService.sendKefuMessage(sendReqVO)); } @@ -43,6 +43,7 @@ public class AppKeFuMessageController { @Parameter(name = "conversationId", description = "会话编号", required = true) @PreAuthenticated public CommonResult updateKefuMessageReadStatus(@RequestParam("conversationId") Long conversationId) { + // TODO @puhui999:需要传递 userId;万一用户模拟一个 conversationId kefuMessageService.updateKefuMessageReadStatus(conversationId); return success(true); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessageSendReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessageSendReqVO.java index 78df4112d..432ed56b6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessageSendReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/kefu/vo/message/AppKeFuMessageSendReqVO.java @@ -9,14 +9,10 @@ import lombok.Data; @Data public class AppKeFuMessageSendReqVO { + // TODO @puhui999:应该没有传递编号哈 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23202") private Long id; - @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571") - private Long senderId; - @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer senderType; - @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "消息类型不能为空") private Integer contentType; @@ -24,4 +20,11 @@ public class AppKeFuMessageSendReqVO { @NotEmpty(message = "消息不能为空") private String content; + // ========== 后端设置的参数,前端无需传递 ========== + + @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571", hidden = true) + private Long senderId; + @Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1", hidden = true) + private Integer senderType; + } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java index 577ce1b50..f5c4fac29 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/kefu/KeFuConversationMapper.java @@ -22,12 +22,14 @@ public interface KeFuConversationMapper extends BaseMapperX .orderByDesc(KeFuConversationDO::getCreateTime)); } + // TODO @puhui999:这个不用单独搞个方法哈。Service 直接 new 一个对象,然后调用 update 方法。 default void updateAdminUnreadMessageCountWithZero(Long id) { update(new LambdaUpdateWrapper() .eq(KeFuConversationDO::getId, id) .set(KeFuConversationDO::getAdminUnreadMessageCount, 0)); } + // TODO @puhui999:改成 updateAdminUnreadMessageCountIncrement 增加 default void updateAdminUnreadMessageCount(Long id) { update(new LambdaUpdateWrapper() .eq(KeFuConversationDO::getId, id) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java index c99e74b5c..04b39769b 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationService.java @@ -25,7 +25,7 @@ public interface KeFuConversationService { * * @param updateReqVO 请求 */ - void updateAdminPinned(KeFuConversationUpdatePinnedReqVO updateReqVO); + void updateConversationPinnedByAdmin(KeFuConversationUpdatePinnedReqVO updateReqVO); /** * 更新会话客服消息冗余信息 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java index 0f6c185f3..fcd609b9d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/kefu/KeFuConversationServiceImpl.java @@ -40,7 +40,7 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { } @Override - public void updateAdminPinned(KeFuConversationUpdatePinnedReqVO updateReqVO) { + public void updateConversationPinnedByAdmin(KeFuConversationUpdatePinnedReqVO updateReqVO) { conversationMapper.updateById(new KeFuConversationDO().setId(updateReqVO.getId()).setAdminPinned(updateReqVO.getAdminPinned())); } @@ -54,11 +54,12 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { .setLastMessageTime(kefuMessage.getCreateTime()).setLastMessageContent(kefuMessage.getContent()) .setLastMessageContentType(kefuMessage.getContentType())); - // 2.2 更新管理员未读消息数 + // 2.1 更新管理员未读消息数 if (UserTypeEnum.MEMBER.getValue().equals(kefuMessage.getSenderType())) { conversationMapper.updateAdminUnreadMessageCount(kefuMessage.getConversationId()); } - // 2.4 会员用户发送消息时,如果管理员删除过会话则进行恢复 + // 2.2 会员用户发送消息时,如果管理员删除过会话则进行恢复 + // TODO @puhui999:其实不用判断用户类型;只要be已删除,就恢复! if (UserTypeEnum.MEMBER.getValue().equals(kefuMessage.getSenderType()) && Boolean.TRUE.equals(conversation.getAdminDeleted())) { updateConversationAdminDeleted(kefuMessage.getConversationId(), Boolean.FALSE); @@ -106,6 +107,7 @@ public class KeFuConversationServiceImpl implements KeFuConversationService { @Override public KeFuConversationDO getConversationByUserId(Long userId) { + // TODO @puhui999:service 不写 dao 的逻辑哈 return conversationMapper.selectOne(KeFuConversationDO::getUserId, userId); }