From bf65d36868a2539e9baa218d52b9df4b62a99ca1 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Thu, 22 Jan 2026 11:12:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BD=A9=E6=88=B4=E5=8B=8B?= =?UTF-8?q?=E7=AB=A0=E5=92=8C=E5=8D=B8=E8=BD=BD=E5=8B=8B=E7=AB=A0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/listener/BadgeOperateListener.java | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/BadgeOperateListener.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/BadgeOperateListener.java index e7c8c249..078b3d04 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/BadgeOperateListener.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/listener/BadgeOperateListener.java @@ -31,6 +31,7 @@ import com.red.circle.tool.core.collection.CollectionUtils; import com.red.circle.tool.core.date.TimestampUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; /** * 徽章操作处理. @@ -125,15 +126,9 @@ public class BadgeOperateListener implements MessageListener { badgeBackpackService.save(buildSaveUserBadgeBackpack(badgeId, userId, days)); // 我的勋章 + Set badgeIdSet = getUseBadgeIdSet(userId); + UserProfile userProfile = userProfileGateway.getByUserId(userId); - List wearBadge = userProfile.getWearBadge(); - List honorBadge = userProfile.getWearHonor(); - wearBadge.addAll(honorBadge); - Set badgeIdSet = wearBadge.stream().map(UserUseBadgeDTO::getId).collect(Collectors.toSet()); - - //新增得勋章 - badgeIdSet.add(badgeId); - userRunProfileService.updateUserWearBadgesOverlay(userId, userBadgeCommon.listUseBadge(userId, userProfile.getSysOriginChild(), badgeIdSet) ); @@ -142,26 +137,26 @@ public class BadgeOperateListener implements MessageListener { }); } + @NotNull + private Set getUseBadgeIdSet(Long userId) { + List ownBadgeList = badgeBackpackService.query() + .eq(BadgeBackpack::getUserId, userId) + .eq(BadgeBackpack::getUseProps, Boolean.TRUE) + .list(); + return ownBadgeList.stream().map(BadgeBackpack::getBadgeId).collect(Collectors.toSet()); + } + /** * 移除徽章. */ private void handleRemoveBadge(Long userId, Long badgeId) { badgeBackpackService.deleteBadges(userId, Sets.newHashSet(badgeId)); - userProfileGateway.removeCache(userId); + + Set badgeIdSet = getUseBadgeIdSet(userId); + UserProfile userProfile = userProfileGateway.getByUserId(userId); - if (Objects.isNull(userProfile)) { - return; - } - List wearBadge = userProfile.getWearBadge(); - List honorBadge = userProfile.getWearHonor(); - wearBadge.addAll(honorBadge); - if (CollectionUtils.isEmpty(wearBadge)) { - return; - } - Set saveWear = wearBadge.stream().map(UserUseBadgeDTO::getId) - .filter(id -> !badgeId.equals(id)).collect(Collectors.toSet()); userRunProfileService.updateUserWearBadgesOverlay(userId, - userBadgeCommon.listUseBadge(userId, userProfile.getSysOriginChild(), saveWear) + userBadgeCommon.listUseBadge(userId, userProfile.getSysOriginChild(), badgeIdSet) ); }