解绑cp和校验处理

This commit is contained in:
tianfeng 2025-12-11 20:01:53 +08:00
parent 005776a9f0
commit 45e963bb0f
5 changed files with 16 additions and 16 deletions

View File

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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -100,7 +100,7 @@ public interface CpRelationshipService extends BaseService<CpRelationship> {
* @param userId 用户id
* @return CP数量
*/
int countNormalCp(Long userId);
int countCp(Long userId);
/**
* 获取分手中的CP关系.

View File

@ -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());
}