cp功能修复

This commit is contained in:
hy001 2026-05-25 11:16:53 +08:00
parent 1520362d9f
commit e5eeebf84a
2 changed files with 35 additions and 29 deletions

View File

@ -134,9 +134,15 @@ public class ProcessCpApplyCmd {
private List<CpApply> autoRefuseWaitAppliesAfterAgree(CpApply cpApply, String relationType) {
Map<Long, CpApply> refusedApplyMap = new LinkedHashMap<>();
addRefusedApplies(refusedApplyMap,
cpApplyService.refuseOtherWaitAppliesBetweenUsers(cpApply.getId(),
cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId()));
List<CpApply> 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,

View File

@ -37,14 +37,14 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> imp
public List<CpApply> refuseOtherWaitAppliesBetweenUsers(Long excludeApplyId, Long userId,
Long cpUserId) {
List<CpApply> 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<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> imp
public List<CpApply> refuseWaitAppliesByUserAndRelation(Long excludeApplyId, Long userId,
String relationType) {
List<CpApply> 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<CpApplyDAO, CpApply> 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<CpApplyDAO, CpApply> imp
@Override
public List<CpApply> 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<CpApplyDAO, CpApply> imp
@Override
public List<CpApply> 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))