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