From 43ccad87cefba0237f493139ab443812a9ef069a Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 29 Apr 2026 19:19:47 +0800 Subject: [PATCH] =?UTF-8?q?cp=E7=A9=BA=E9=97=B4=E5=88=86=E6=89=8B=E4=B8=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 2a6ec19d59c4e0bced1e18ec93fe27a54316a090) --- .../command/user/query/CoupleSpaceQryExe.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/CoupleSpaceQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/CoupleSpaceQryExe.java index 0482cf00..6ddd477a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/CoupleSpaceQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/query/CoupleSpaceQryExe.java @@ -6,17 +6,26 @@ import com.red.circle.other.app.dto.cmd.user.relation.cp.CoupleSpaceQryCmd; import com.red.circle.other.infra.database.cache.service.cp.CpRelationshipCacheService; import com.red.circle.other.infra.database.rds.entity.props.CpRingBackpack; import com.red.circle.other.infra.database.rds.entity.props.PropsSourceRecord; +import com.red.circle.other.infra.database.rds.entity.user.user.BaseInfo; +import com.red.circle.other.infra.database.rds.entity.user.user.CpLevelConfig; +import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; import com.red.circle.other.infra.database.rds.service.props.CpRingBackpackService; import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService; +import com.red.circle.other.infra.database.rds.service.user.user.BaseInfoService; +import com.red.circle.other.infra.database.rds.service.user.user.CpRelationshipService; +import com.red.circle.other.infra.database.rds.service.user.user.CpValueService; import com.red.circle.other.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.enums.material.PropsCommodityType; import com.red.circle.other.inner.model.dto.material.props.PropsResources; import com.red.circle.other.inner.model.dto.material.props.UserBackpackProps; import com.red.circle.other.inner.model.dto.user.CpSimpleUserProfileCO; import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.date.DateUtils; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import java.math.BigDecimal; +import java.time.ZoneId; import java.util.*; import java.util.stream.Collectors; @@ -30,6 +39,9 @@ import java.util.stream.Collectors; public class CoupleSpaceQryExe { private final CpRelationshipCacheService cpRelationshipCacheService; + private final CpRelationshipService cpRelationshipService; + private final BaseInfoService baseInfoService; + private final CpValueService cpValueService; private final CpRingBackpackService cpRingBackpackService; private final PropsSourceRecordService propsSourceRecordService; @@ -40,6 +52,11 @@ public class CoupleSpaceQryExe { .filter(cp -> cp.getCpUserId().equals(cmd.getCpUserId())) .findFirst() .orElse(null); + + if (cpInfo == null) { + cpInfo = buildDismissingCpInfo(cmd.requiredReqUserId(), cmd.getCpUserId()); + } + ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, cpInfo); CoupleSpaceCO co = new CoupleSpaceCO(); @@ -73,6 +90,49 @@ public class CoupleSpaceQryExe { return co; } + private CpSimpleUserProfileCO buildDismissingCpInfo(Long userId, Long cpUserId) { + CpRelationship dismissing = cpRelationshipService.getDismissingCp(userId, cpUserId); + if (dismissing == null) { + return null; + } + + BaseInfo meInfo = baseInfoService.getById(userId); + BaseInfo cpUser = baseInfoService.getById(cpUserId); + if (meInfo == null || cpUser == null) { + return null; + } + + BigDecimal cpValue = cpValueService.mapCpVal(Set.of(dismissing.getCpValId())) + .getOrDefault(dismissing.getCpValId(), BigDecimal.ZERO); + Long days = DateUtils.toDurationDays(dismissing.getCreateTime(), DateUtils.now()); + String firstDay = dismissing.getCreateTime().toInstant() + .atZone(ZoneId.systemDefault()).toLocalDate().toString(); + + CpLevelConfig levelConfig = CpLevelConfig.of(cpValue); + return new CpSimpleUserProfileCO() + .setMeUserId(meInfo.getId()) + .setMeAccount(meInfo.getAccount()) + .setMeUserAvatar(meInfo.getUserAvatar()) + .setMeUserNickname(meInfo.getUserNickname()) + .setCpUserId(cpUser.getId()) + .setCpAccount(cpUser.getAccount()) + .setCpUserAvatar(cpUser.getUserAvatar()) + .setCpUserNickname(cpUser.getUserNickname()) + .setStatus(dismissing.getStatus()) + .setCpValId(dismissing.getCpValId()) + .setCpValue(cpValue) + .setDays(days) + .setFirstDay(firstDay) + .setCreateTime(dismissing.getCreateTime()) + .setCpLevel(levelConfig.getLevel()) + .setNextLevelExp(levelConfig.nextExpThreshold()) + .setLoveHeartLevel(levelConfig.getLoveHeartLevel()) + .setMicEffectLevel(levelConfig.getMicEffectLevel()) + .setProfileCardLevel(levelConfig.getProfileCardLevel()) + .setGiftWindowLevel(levelConfig.getGiftWindowLevel()) + .setHasNonMicEffect(levelConfig.isHasNonMicEffect()); + } + private List buildSharedRingBackpack(Long meUserId, Long cpUserId) { List meRings = cpRingBackpackService.listNotExpired(meUserId, cpUserId); if (CollectionUtils.isEmpty(meRings)) {