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)) {