From 16c82d32b4808c1d758b89e6cced24901806acd1 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 29 Apr 2026 18:55:45 +0800 Subject: [PATCH] =?UTF-8?q?cp=E7=A9=BA=E9=97=B4=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 7ca7b1a196041787d4e727b9df7480792a8ffa05) --- .../command/user/query/CoupleSpaceQryExe.java | 43 +++++-------------- 1 file changed, 11 insertions(+), 32 deletions(-) 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 18f1fc52..0482cf00 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 @@ -4,9 +4,9 @@ import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.other.app.dto.clientobject.user.relation.cp.CoupleSpaceCO; 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.PropsBackpack; +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.service.props.PropsBackpackService; +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.inner.asserts.user.UserErrorCode; import com.red.circle.other.inner.enums.material.PropsCommodityType; @@ -30,7 +30,7 @@ import java.util.stream.Collectors; public class CoupleSpaceQryExe { private final CpRelationshipCacheService cpRelationshipCacheService; - private final PropsBackpackService propsBackpackService; + private final CpRingBackpackService cpRingBackpackService; private final PropsSourceRecordService propsSourceRecordService; public CoupleSpaceCO execute(CoupleSpaceQryCmd cmd) { @@ -74,44 +74,23 @@ public class CoupleSpaceQryExe { } private List buildSharedRingBackpack(Long meUserId, Long cpUserId) { - List meBackpack = propsBackpackService - .listNotExpiredByUserIdAndType(meUserId, PropsCommodityType.CP_RING); - if (CollectionUtils.isEmpty(meBackpack)) { + List meRings = cpRingBackpackService.listNotExpired(meUserId, cpUserId); + if (CollectionUtils.isEmpty(meRings)) { return Collections.emptyList(); } - List cpBackpack = propsBackpackService - .listNotExpiredByUserIdAndType(cpUserId, PropsCommodityType.CP_RING); - if (CollectionUtils.isEmpty(cpBackpack)) { - return Collections.emptyList(); - } - - // 取双方共同拥有的 propsId 交集 - Set cpPropsIds = cpBackpack.stream() - .map(PropsBackpack::getPropsId) - .collect(Collectors.toSet()); - List shared = meBackpack.stream() - .filter(b -> cpPropsIds.contains(b.getPropsId())) - .toList(); - if (CollectionUtils.isEmpty(shared)) { - return Collections.emptyList(); - } - - // 批量查资源信息 - Set propsIds = shared.stream().map(PropsBackpack::getPropsId).collect(Collectors.toSet()); + Set propsIds = meRings.stream().map(CpRingBackpack::getPropsId).collect(Collectors.toSet()); Map sourceMap = propsSourceRecordService.mapByIds(propsIds); - return shared.stream().map(backpack -> { - PropsSourceRecord source = sourceMap.get(backpack.getPropsId()); + return meRings.stream().map(ring -> { + PropsSourceRecord source = sourceMap.get(ring.getPropsId()); if (source == null) { return null; } return new UserBackpackProps() - .setUserId(backpack.getUserId()) - .setType(backpack.getType()) - .setExpireTime(backpack.getExpireTime()) - .setUseProps(backpack.getUseProps()) - .setAllowGive(backpack.getAllowGive()) + .setUserId(ring.getUserId()) + .setType(PropsCommodityType.CP_RING.name()) + .setExpireTime(ring.getExpireTime()) .setPropsResources(new PropsResources() .setId(source.getId()) .setType(source.getType())