diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/DismissCpApplyCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/DismissCpApplyCmdExe.java index 55d28d78..ea375fca 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/DismissCpApplyCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/DismissCpApplyCmdExe.java @@ -3,14 +3,20 @@ package com.red.circle.other.app.command.user; import com.google.common.collect.Sets; import com.red.circle.external.inner.endpoint.message.ImMessageClient; import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyDismissCmd; +import com.red.circle.other.app.service.user.user.UserProfileService; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.common.user.UserGiftBackpackCommon; import com.red.circle.other.infra.database.cache.service.user.UserCpValueCacheService; import com.red.circle.other.infra.database.mongo.service.user.count.WeekCpValueCountService; +import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; import com.red.circle.other.infra.database.rds.service.user.user.CpApplyService; import com.red.circle.other.infra.database.rds.service.user.user.CpBlessRecordService; import com.red.circle.other.infra.database.rds.service.user.user.CpCabinAchieveService; 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 java.util.Arrays; +import java.util.List; import java.util.Objects; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -33,6 +39,7 @@ public class DismissCpApplyCmdExe { private final UserCpValueCacheService userCpValueCacheService; private final CpBlessRecordService cpBlessRecordService; private final CpCabinAchieveService cpCabinAchieveService; + private final UserProfileGateway userProfileGateway; public void execute(CpApplyDismissCmd cmd) { @@ -47,6 +54,8 @@ public class DismissCpApplyCmdExe { // 更新CP关系为分手中,不删除数据 cpRelationshipService.updateToDismissing(cmd.requiredReqUserId(), cmd.getCpUserId()); + userProfileGateway.removeCacheAll(Arrays.asList(cmd.requiredReqUserId(), cmd.getCpUserId())); + // 以下数据不删除,7天后由定时任务清理 // weekCpValueCountService.removeThisWeek(...) // cpValueService.deleteById(...) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/ProcessCpApplyCmd.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/ProcessCpApplyCmd.java index 1ff3698c..6c735669 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/ProcessCpApplyCmd.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/ProcessCpApplyCmd.java @@ -1,8 +1,6 @@ package com.red.circle.other.app.command.user; -import com.google.common.collect.Lists; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; -import com.red.circle.component.redis.service.RedisService; import com.red.circle.external.inner.endpoint.message.ImMessageClient; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; @@ -10,7 +8,6 @@ import com.red.circle.mq.business.model.event.user.CpApplyEvent; import com.red.circle.mq.rocket.business.producer.UserMqMessageService; import com.red.circle.other.app.dto.cmd.user.relation.cp.ProcessApplyCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; -import com.red.circle.other.infra.database.cache.service.user.UserRunProfileCacheService; import com.red.circle.other.infra.database.rds.entity.user.user.CpApply; import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; import com.red.circle.other.infra.database.rds.entity.user.user.CpValue; @@ -72,8 +69,8 @@ public class ProcessCpApplyCmd { cpRelationshipService.existsCp(cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId())); // 检查CP数量限制(最多4个) - int senderCpCount = cpRelationshipService.countNormalCp(cmd.requiredReqUserId()); - int receiverCpCount = cpRelationshipService.countNormalCp(cpApply.getAcceptApplyUserId()); + int senderCpCount = cpRelationshipService.countCp(cmd.requiredReqUserId()); + int receiverCpCount = cpRelationshipService.countCp(cpApply.getAcceptApplyUserId()); ResponseAssert.isFalse(UserRelationErrorCode.CP_LIMIT_EXCEEDED, senderCpCount >= 4); ResponseAssert.isFalse(UserRelationErrorCode.CP_LIMIT_EXCEEDED, receiverCpCount >= 4); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java index 5113e891..36609436 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/user/SendCpApplyCmdExe.java @@ -1,14 +1,10 @@ package com.red.circle.other.app.command.user; -import com.google.common.collect.Lists; import com.red.circle.common.business.core.enums.SysOriginPlatformEnum; -import com.red.circle.component.redis.service.RedisService; -import com.red.circle.external.inner.endpoint.message.ImMessageClient; import com.red.circle.external.inner.endpoint.message.OfficialNoticeClient; import com.red.circle.external.inner.model.cmd.message.notice.official.NoticeExtTemplateTypeCmd; import com.red.circle.external.inner.model.enums.message.OfficialNoticeTypeEnum; import com.red.circle.framework.core.asserts.ResponseAssert; -import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.mq.business.model.event.user.CpApplyEvent; import com.red.circle.mq.rocket.business.producer.UserMqMessageService; import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; @@ -16,7 +12,6 @@ import com.red.circle.other.app.dto.cmd.user.relation.cp.CpApplyCmd; import com.red.circle.other.app.util.OfficialNoticeUtils; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; -import com.red.circle.other.domain.model.user.UserProfile; import com.red.circle.other.infra.database.cache.service.other.EnumConfigCacheService; import com.red.circle.other.infra.database.rds.entity.user.user.CpApply; import com.red.circle.other.infra.database.rds.entity.user.user.CpRelationship; @@ -34,7 +29,7 @@ import com.red.circle.wallet.inner.model.enums.GoldOrigin; import java.util.Map; import java.util.Objects; -import java.util.concurrent.TimeUnit; + import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -78,8 +73,8 @@ public class SendCpApplyCmdExe { .existsCp(cmd.requiredReqUserId(), cmd.getAcceptApplyUserId())); // 检查CP数量限制(最多4个) - int senderCpCount = cpRelationshipService.countNormalCp(cmd.requiredReqUserId()); - int receiverCpCount = cpRelationshipService.countNormalCp(cmd.getAcceptApplyUserId()); + int senderCpCount = cpRelationshipService.countCp(cmd.requiredReqUserId()); + int receiverCpCount = cpRelationshipService.countCp(cmd.getAcceptApplyUserId()); ResponseAssert.isFalse(UserRelationErrorCode.CP_LIMIT_EXCEEDED, senderCpCount >= 4); ResponseAssert.isFalse(UserRelationErrorCode.CP_LIMIT_EXCEEDED, receiverCpCount >= 4); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/CpRelationshipService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/CpRelationshipService.java index 8b5b99dc..5387c29a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/CpRelationshipService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/CpRelationshipService.java @@ -100,7 +100,7 @@ public interface CpRelationshipService extends BaseService { * @param userId 用户id * @return CP数量 */ - int countNormalCp(Long userId); + int countCp(Long userId); /** * 获取分手中的CP关系. diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpRelationshipServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpRelationshipServiceImpl.java index eae489dd..2a9cb66a 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpRelationshipServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpRelationshipServiceImpl.java @@ -160,10 +160,9 @@ public class CpRelationshipServiceImpl extends } @Override - public int countNormalCp(Long userId) { + public int countCp(Long userId) { return Math.toIntExact(query() .eq(CpRelationship::getUserId, userId) - .eq(CpRelationship::getStatus, CpRelationshipStatus.NORMAL.name()) .count()); }