From e5eeebf84ac7d21863a2dab5d904f30eda9cc929 Mon Sep 17 00:00:00 2001 From: hy001 Date: Mon, 25 May 2026 11:16:53 +0800 Subject: [PATCH] =?UTF-8?q?cp=E5=8A=9F=E8=83=BD=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/user/ProcessCpApplyCmd.java | 12 +++-- .../user/user/impl/CpApplyServiceImpl.java | 52 +++++++++---------- 2 files changed, 35 insertions(+), 29 deletions(-) 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 af7b5cab..fd0fc6b3 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 @@ -134,9 +134,15 @@ public class ProcessCpApplyCmd { private List autoRefuseWaitAppliesAfterAgree(CpApply cpApply, String relationType) { Map refusedApplyMap = new LinkedHashMap<>(); - addRefusedApplies(refusedApplyMap, - cpApplyService.refuseOtherWaitAppliesBetweenUsers(cpApply.getId(), - cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId())); + List samePairRefusedApplies = cpApplyService.refuseOtherWaitAppliesBetweenUsers( + cpApply.getId(), cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId()); + addRefusedApplies(refusedApplyMap, samePairRefusedApplies); + if (!samePairRefusedApplies.isEmpty()) { + log.info("[CP] auto refused other wait applies between same users after agree, " + + "agreeApplyId={}, sendUserId={}, acceptUserId={}, applyIds={}", + cpApply.getId(), cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId(), + samePairRefusedApplies.stream().map(CpApply::getId).toList()); + } addRefusedApplies(refusedApplyMap, refuseWaitAppliesIfLimitReached(cpApply, cpApply.getSendApplyUserId(), relationType)); addRefusedApplies(refusedApplyMap, diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpApplyServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpApplyServiceImpl.java index e7a88513..eed281c6 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpApplyServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/impl/CpApplyServiceImpl.java @@ -37,14 +37,14 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp @Override public void dismiss(Long requestUserId, String relationType) { update() - .set(CpApply::getStatus, CpApplyStatus.DISMISS) + .set(CpApply::getStatus, CpApplyStatus.DISMISS.name()) .set(CpApply::getUpdateTime, LocalDateTime.now()) .set(CpApply::getUpdateUser, requestUserId) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) - .eq(CpApply::getStatus, CpApplyStatus.AGREE) + .eq(CpApply::getStatus, CpApplyStatus.AGREE.name()) .and(where -> where.eq(CpApply::getSendApplyUserId, requestUserId) - .or().eq(CpApply::getAcceptApplyUserId, requestUserId)) - .last(PageConstant.LIMIT_ONE) + .or().eq(CpApply::getAcceptApplyUserId, requestUserId)) + .last(PageConstant.LIMIT_ONE) .execute(); } @@ -58,7 +58,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp return Optional.ofNullable( query() .select(CpApply::getId) - .eq(CpApply::getStatus, CpApplyStatus.WAIT) + .eq(CpApply::getStatus, CpApplyStatus.WAIT.name()) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getAcceptApplyUserId, acceptApplyUserId) .eq(CpApply::getSendApplyUserId, sendApplyUserId) @@ -88,19 +88,19 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp .select(CpApply::getId) .eq(CpApply::getSendApplyUserId, sendApplyUserId) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) - .eq(CpApply::getStatus, CpApplyStatus.WAIT) + .eq(CpApply::getStatus, CpApplyStatus.WAIT.name()) .getOne()) - .map(cpApply -> Objects.nonNull(cpApply.getId())) - .orElse(Boolean.FALSE); - } - - @Override - public boolean changeStatusById(Long id, CpApplyStatus status) { - return update() - .set(CpApply::getStatus, status) - .eq(CpApply::getId, id) - .execute(); - } + .map(cpApply -> Objects.nonNull(cpApply.getId())) + .orElse(Boolean.FALSE); + } + + @Override + public boolean changeStatusById(Long id, CpApplyStatus status) { + return update() + .set(CpApply::getStatus, status.name()) + .eq(CpApply::getId, id) + .execute(); + } @Override public void refuseStatusWait(Long acceptApplyUserId) { @@ -110,8 +110,8 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp @Override public void refuseStatusWait(Long acceptApplyUserId, String relationType) { update() - .set(CpApply::getStatus, CpApplyStatus.REFUSE) - .eq(CpApply::getStatus, CpApplyStatus.WAIT) + .set(CpApply::getStatus, CpApplyStatus.REFUSE.name()) + .eq(CpApply::getStatus, CpApplyStatus.WAIT.name()) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getAcceptApplyUserId, acceptApplyUserId) .execute(); @@ -130,7 +130,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp public List refuseOtherWaitAppliesBetweenUsers(Long excludeApplyId, Long userId, Long cpUserId) { List applies = query() - .eq(CpApply::getStatus, CpApplyStatus.WAIT) + .eq(CpApply::getStatus, CpApplyStatus.WAIT.name()) .ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId) .and(where -> where .nested(w -> w.eq(CpApply::getSendApplyUserId, userId) @@ -147,7 +147,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp return applies; } update() - .set(CpApply::getStatus, CpApplyStatus.REFUSE) + .set(CpApply::getStatus, CpApplyStatus.REFUSE.name()) .set(CpApply::getUpdateTime, LocalDateTime.now()) .in(CpApply::getId, applyIds) .execute(); @@ -159,7 +159,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp public List refuseWaitAppliesByUserAndRelation(Long excludeApplyId, Long userId, String relationType) { List applies = query() - .eq(CpApply::getStatus, CpApplyStatus.WAIT) + .eq(CpApply::getStatus, CpApplyStatus.WAIT.name()) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId) .and(where -> where.eq(CpApply::getSendApplyUserId, userId) @@ -174,7 +174,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp return applies; } update() - .set(CpApply::getStatus, CpApplyStatus.REFUSE) + .set(CpApply::getStatus, CpApplyStatus.REFUSE.name()) .set(CpApply::getUpdateTime, LocalDateTime.now()) .in(CpApply::getId, applyIds) .execute(); @@ -185,8 +185,8 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp @Override public List listRefuse(Long userId) { return query() - .eq(CpApply::getStatus, CpApplyStatus.REFUSE) - .eq(CpApply::getAcceptApplyUserId, userId) + .eq(CpApply::getStatus, CpApplyStatus.REFUSE.name()) + .eq(CpApply::getAcceptApplyUserId, userId) .last(PageConstant.MAX_LIMIT) .list(); } @@ -194,7 +194,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl imp @Override public List listRefuseBetweenUsers(Long userId, Long cpUserId) { return query() - .eq(CpApply::getStatus, CpApplyStatus.REFUSE) + .eq(CpApply::getStatus, CpApplyStatus.REFUSE.name()) .and(where -> where .nested(w -> w.eq(CpApply::getSendApplyUserId, userId) .eq(CpApply::getAcceptApplyUserId, cpUserId))