diff --git a/backend/src/main/java/org/ftclub/cabinet/exception/ExceptionStatus.java b/backend/src/main/java/org/ftclub/cabinet/exception/ExceptionStatus.java index 55ac3ae7a..bf1bce5f1 100644 --- a/backend/src/main/java/org/ftclub/cabinet/exception/ExceptionStatus.java +++ b/backend/src/main/java/org/ftclub/cabinet/exception/ExceptionStatus.java @@ -55,8 +55,8 @@ public enum ExceptionStatus { CLUB_HAS_LENT_CABINET(HttpStatus.NOT_ACCEPTABLE, "대여 중인 사물함을 반납 후 삭제할 수 있습니다."), HANEAPI_ERROR(HttpStatus.BAD_GATEWAY, "24HANE API 통신에 에러가 있습니다."), EXTENSION_NOT_FOUND(HttpStatus.BAD_REQUEST, "연장권이 존재하지 않습니다."), + EXTENSION_LENT_DELAYED(HttpStatus.FORBIDDEN, "연장권은 연체된 사물함에 사용할 수 없습니다."), EXTENSION_SOLO_IN_SHARE_NOT_ALLOWED(HttpStatus.UNAUTHORIZED, "연장권은 1명일 때 사용할 수 없습니다."), - EXTENSION_LENT_DELAYED(HttpStatus.UNAUTHORIZED, "연장권은 연체된 사물함에 사용할 수 없습니다."), MAIL_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "메일 전송 중 에러가 발생했습니다"), SLACK_REQUEST_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "슬랙 인증 중 에러가 발생했습니다."), SLACK_MESSAGE_SEND_BAD_GATEWAY(HttpStatus.BAD_GATEWAY, "슬랙 메세지 전송 중 에러가 발생했습니다."), diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/domain/LentPolicyStatus.java b/backend/src/main/java/org/ftclub/cabinet/lent/domain/LentPolicyStatus.java index 947fd636b..196edfeea 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/domain/LentPolicyStatus.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/domain/LentPolicyStatus.java @@ -56,7 +56,7 @@ public enum LentPolicyStatus { INVALID_LENT_TYPE, INVALID_ARGUMENT, INVALID_EXPIREDAT, SWAP_SAME_CABINET, LENT_NOT_CLUB, - - SWAP_LIMIT_EXCEEDED + SWAP_LIMIT_EXCEEDED, + OVERDUE_CABINET_EXTEND } \ No newline at end of file diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java index 62a615afd..9d53e29a9 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentFacadeService.java @@ -441,6 +441,9 @@ public void plusExtensionDays(Long userId, Integer days) { userId, LentExtensionType.ALL, days); List lentHistories = lentQueryService.findCabinetActiveLentHistories( cabinet.getId()); + lentHistories.forEach( + lentHistory -> lentPolicyService.verifyExtendable(lentHistory.getExpiredAt()) + ); lentExtensionCommandService.useLentExtension(lentExtensionByItem, lentHistories); } } diff --git a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentPolicyService.java b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentPolicyService.java index 9ac733204..c26140638 100644 --- a/backend/src/main/java/org/ftclub/cabinet/lent/service/LentPolicyService.java +++ b/backend/src/main/java/org/ftclub/cabinet/lent/service/LentPolicyService.java @@ -43,6 +43,8 @@ private void handlePolicyStatus(LentPolicyStatus status, LocalDateTime policyDat throw ExceptionStatus.LENT_FULL.asServiceException(); case OVERDUE_CABINET: throw ExceptionStatus.LENT_EXPIRED.asServiceException(); + case OVERDUE_CABINET_EXTEND: + throw ExceptionStatus.EXTENSION_LENT_DELAYED.asServiceException(); case LENT_CLUB: throw ExceptionStatus.LENT_CLUB.asServiceException(); case LENT_NOT_CLUB: @@ -307,4 +309,17 @@ public void verifySwappable(boolean existSwapRecord, LocalDateTime swapExpiredAt handlePolicyStatus(LentPolicyStatus.SWAP_LIMIT_EXCEEDED, swapExpiredAt); } } + + /** + * 연장권 사용 시, 연체된 사물함에 사용하는지 확인합니다 + * + * @param expiredAt 대여만료 날짜 + */ + public void verifyExtendable(LocalDateTime expiredAt) { + LentPolicyStatus status = LentPolicyStatus.FINE; + if (expiredAt.isBefore(LocalDateTime.now())) { + status = LentPolicyStatus.OVERDUE_CABINET_EXTEND; + } + handlePolicyStatus(status, null); + } }