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) { private List<CpApply> autoRefuseWaitAppliesAfterAgree(CpApply cpApply, String relationType) {
Map<Long, CpApply> refusedApplyMap = new LinkedHashMap<>(); Map<Long, CpApply> refusedApplyMap = new LinkedHashMap<>();
addRefusedApplies(refusedApplyMap, List<CpApply> samePairRefusedApplies = cpApplyService.refuseOtherWaitAppliesBetweenUsers(
cpApplyService.refuseOtherWaitAppliesBetweenUsers(cpApply.getId(), cpApply.getId(), cpApply.getSendApplyUserId(), cpApply.getAcceptApplyUserId());
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, addRefusedApplies(refusedApplyMap,
refuseWaitAppliesIfLimitReached(cpApply, cpApply.getSendApplyUserId(), relationType)); refuseWaitAppliesIfLimitReached(cpApply, cpApply.getSendApplyUserId(), relationType));
addRefusedApplies(refusedApplyMap, addRefusedApplies(refusedApplyMap,

View File

@ -37,14 +37,14 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
@Override @Override
public void dismiss(Long requestUserId, String relationType) { public void dismiss(Long requestUserId, String relationType) {
update() update()
.set(CpApply::getStatus, CpApplyStatus.DISMISS) .set(CpApply::getStatus, CpApplyStatus.DISMISS.name())
.set(CpApply::getUpdateTime, LocalDateTime.now()) .set(CpApply::getUpdateTime, LocalDateTime.now())
.set(CpApply::getUpdateUser, requestUserId) .set(CpApply::getUpdateUser, requestUserId)
.eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType))
.eq(CpApply::getStatus, CpApplyStatus.AGREE) .eq(CpApply::getStatus, CpApplyStatus.AGREE.name())
.and(where -> where.eq(CpApply::getSendApplyUserId, requestUserId) .and(where -> where.eq(CpApply::getSendApplyUserId, requestUserId)
.or().eq(CpApply::getAcceptApplyUserId, requestUserId)) .or().eq(CpApply::getAcceptApplyUserId, requestUserId))
.last(PageConstant.LIMIT_ONE) .last(PageConstant.LIMIT_ONE)
.execute(); .execute();
} }
@ -58,7 +58,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
return Optional.ofNullable( return Optional.ofNullable(
query() query()
.select(CpApply::getId) .select(CpApply::getId)
.eq(CpApply::getStatus, CpApplyStatus.WAIT) .eq(CpApply::getStatus, CpApplyStatus.WAIT.name())
.eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType))
.eq(CpApply::getAcceptApplyUserId, acceptApplyUserId) .eq(CpApply::getAcceptApplyUserId, acceptApplyUserId)
.eq(CpApply::getSendApplyUserId, sendApplyUserId) .eq(CpApply::getSendApplyUserId, sendApplyUserId)
@ -88,19 +88,19 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
.select(CpApply::getId) .select(CpApply::getId)
.eq(CpApply::getSendApplyUserId, sendApplyUserId) .eq(CpApply::getSendApplyUserId, sendApplyUserId)
.eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType))
.eq(CpApply::getStatus, CpApplyStatus.WAIT) .eq(CpApply::getStatus, CpApplyStatus.WAIT.name())
.getOne()) .getOne())
.map(cpApply -> Objects.nonNull(cpApply.getId())) .map(cpApply -> Objects.nonNull(cpApply.getId()))
.orElse(Boolean.FALSE); .orElse(Boolean.FALSE);
} }
@Override @Override
public boolean changeStatusById(Long id, CpApplyStatus status) { public boolean changeStatusById(Long id, CpApplyStatus status) {
return update() return update()
.set(CpApply::getStatus, status) .set(CpApply::getStatus, status.name())
.eq(CpApply::getId, id) .eq(CpApply::getId, id)
.execute(); .execute();
} }
@Override @Override
public void refuseStatusWait(Long acceptApplyUserId) { public void refuseStatusWait(Long acceptApplyUserId) {
@ -110,8 +110,8 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
@Override @Override
public void refuseStatusWait(Long acceptApplyUserId, String relationType) { public void refuseStatusWait(Long acceptApplyUserId, String relationType) {
update() update()
.set(CpApply::getStatus, CpApplyStatus.REFUSE) .set(CpApply::getStatus, CpApplyStatus.REFUSE.name())
.eq(CpApply::getStatus, CpApplyStatus.WAIT) .eq(CpApply::getStatus, CpApplyStatus.WAIT.name())
.eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType))
.eq(CpApply::getAcceptApplyUserId, acceptApplyUserId) .eq(CpApply::getAcceptApplyUserId, acceptApplyUserId)
.execute(); .execute();
@ -130,7 +130,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
public List<CpApply> refuseOtherWaitAppliesBetweenUsers(Long excludeApplyId, Long userId, public List<CpApply> refuseOtherWaitAppliesBetweenUsers(Long excludeApplyId, Long userId,
Long cpUserId) { Long cpUserId) {
List<CpApply> applies = query() List<CpApply> applies = query()
.eq(CpApply::getStatus, CpApplyStatus.WAIT) .eq(CpApply::getStatus, CpApplyStatus.WAIT.name())
.ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId) .ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId)
.and(where -> where .and(where -> where
.nested(w -> w.eq(CpApply::getSendApplyUserId, userId) .nested(w -> w.eq(CpApply::getSendApplyUserId, userId)
@ -147,7 +147,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
return applies; return applies;
} }
update() update()
.set(CpApply::getStatus, CpApplyStatus.REFUSE) .set(CpApply::getStatus, CpApplyStatus.REFUSE.name())
.set(CpApply::getUpdateTime, LocalDateTime.now()) .set(CpApply::getUpdateTime, LocalDateTime.now())
.in(CpApply::getId, applyIds) .in(CpApply::getId, applyIds)
.execute(); .execute();
@ -159,7 +159,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
public List<CpApply> refuseWaitAppliesByUserAndRelation(Long excludeApplyId, Long userId, public List<CpApply> refuseWaitAppliesByUserAndRelation(Long excludeApplyId, Long userId,
String relationType) { String relationType) {
List<CpApply> applies = query() List<CpApply> applies = query()
.eq(CpApply::getStatus, CpApplyStatus.WAIT) .eq(CpApply::getStatus, CpApplyStatus.WAIT.name())
.eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType)) .eq(CpApply::getRelationType, CpRelationshipType.normalize(relationType))
.ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId) .ne(Objects.nonNull(excludeApplyId), CpApply::getId, excludeApplyId)
.and(where -> where.eq(CpApply::getSendApplyUserId, userId) .and(where -> where.eq(CpApply::getSendApplyUserId, userId)
@ -174,7 +174,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
return applies; return applies;
} }
update() update()
.set(CpApply::getStatus, CpApplyStatus.REFUSE) .set(CpApply::getStatus, CpApplyStatus.REFUSE.name())
.set(CpApply::getUpdateTime, LocalDateTime.now()) .set(CpApply::getUpdateTime, LocalDateTime.now())
.in(CpApply::getId, applyIds) .in(CpApply::getId, applyIds)
.execute(); .execute();
@ -185,8 +185,8 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
@Override @Override
public List<CpApply> listRefuse(Long userId) { public List<CpApply> listRefuse(Long userId) {
return query() return query()
.eq(CpApply::getStatus, CpApplyStatus.REFUSE) .eq(CpApply::getStatus, CpApplyStatus.REFUSE.name())
.eq(CpApply::getAcceptApplyUserId, userId) .eq(CpApply::getAcceptApplyUserId, userId)
.last(PageConstant.MAX_LIMIT) .last(PageConstant.MAX_LIMIT)
.list(); .list();
} }
@ -194,7 +194,7 @@ public class CpApplyServiceImpl extends BaseServiceImpl<CpApplyDAO, CpApply> imp
@Override @Override
public List<CpApply> listRefuseBetweenUsers(Long userId, Long cpUserId) { public List<CpApply> listRefuseBetweenUsers(Long userId, Long cpUserId) {
return query() return query()
.eq(CpApply::getStatus, CpApplyStatus.REFUSE) .eq(CpApply::getStatus, CpApplyStatus.REFUSE.name())
.and(where -> where .and(where -> where
.nested(w -> w.eq(CpApply::getSendApplyUserId, userId) .nested(w -> w.eq(CpApply::getSendApplyUserId, userId)
.eq(CpApply::getAcceptApplyUserId, cpUserId)) .eq(CpApply::getAcceptApplyUserId, cpUserId))