From 0ba45ff65c7ca1291c88295c75ed5297adf8d517 Mon Sep 17 00:00:00 2001 From: ssolpang Date: Thu, 6 Feb 2025 18:39:11 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat/=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20enum=EC=97=90=20=EC=A4=91=EB=8F=84=20?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=EB=A9=B4=EC=84=9C=20=EC=A0=95=EC=82=B0=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=EC=9D=B8=20=EC=83=81=ED=83=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80#364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../habitpay/domain/challenge/domain/ChallengeState.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/habitpay/habitpay/domain/challenge/domain/ChallengeState.java b/src/main/java/com/habitpay/habitpay/domain/challenge/domain/ChallengeState.java index d2d7c058..1208fe8f 100644 --- a/src/main/java/com/habitpay/habitpay/domain/challenge/domain/ChallengeState.java +++ b/src/main/java/com/habitpay/habitpay/domain/challenge/domain/ChallengeState.java @@ -9,5 +9,6 @@ public enum ChallengeState { COMPLETED_PENDING_SETTLEMENT, COMPLETED_SETTLED, CANCELED, + CANCELED_SETTLED, CANCELED_BEFORE_START; } \ No newline at end of file From 9860d646329c4f97f58b594138d1cc33ba1e8dbf Mon Sep 17 00:00:00 2001 From: ssolpang Date: Thu, 6 Feb 2025 19:13:36 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat/Challenge=20=EC=83=81=EC=84=B8=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=EA=B3=BC=20=EB=AA=A9=EB=A1=9D=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20DTO=EC=97=90=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EB=AC=B8=EC=9E=90=EC=97=B4=20=EC=86=8D?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80#364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../habitpay/domain/challenge/dto/ChallengeDetailsResponse.java | 2 ++ .../domain/challenge/dto/ChallengeEnrolledListItemResponse.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeDetailsResponse.java b/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeDetailsResponse.java index 4772218c..e4036717 100644 --- a/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeDetailsResponse.java +++ b/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeDetailsResponse.java @@ -28,6 +28,7 @@ public class ChallengeDetailsResponse { private Boolean isHost; private Boolean isMemberEnrolledInChallenge; private Boolean isGivenUp; + private String challengeState; public static ChallengeDetailsResponse of(Member member, Challenge challenge, List enrolledMembersProfileImageList, @@ -50,6 +51,7 @@ public static ChallengeDetailsResponse of(Member member, Challenge challenge, .isHost(challenge.getHost().getId().equals(member.getId())) .isMemberEnrolledInChallenge(isMemberEnrolledInChallenge) .isGivenUp(isGivenUp) + .challengeState(String.valueOf(challenge.getState())) .build(); } } diff --git a/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeEnrolledListItemResponse.java b/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeEnrolledListItemResponse.java index 585f5fda..ffcd4b46 100644 --- a/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeEnrolledListItemResponse.java +++ b/src/main/java/com/habitpay/habitpay/domain/challenge/dto/ChallengeEnrolledListItemResponse.java @@ -27,6 +27,7 @@ public class ChallengeEnrolledListItemResponse { private int successCount; private Boolean isTodayParticipatingDay; private Boolean isParticipatedToday; + private String challengeState; public static ChallengeEnrolledListItemResponse of(Challenge challenge, ChallengeEnrollment challengeEnrollment, ParticipationStat stat, String hostProfileImage, boolean isParticipatedToday) { return ChallengeEnrolledListItemResponse.builder() @@ -46,6 +47,7 @@ public static ChallengeEnrolledListItemResponse of(Challenge challenge, Challeng .successCount(stat.getSuccessCount()) .isTodayParticipatingDay(challenge.isTodayParticipatingDay()) .isParticipatedToday(isParticipatedToday) + .challengeState(String.valueOf(challenge.getState())) .build(); } } From b32e322079fa898d2852b6f54a34fae21648d13e Mon Sep 17 00:00:00 2001 From: ssolpang Date: Thu, 6 Feb 2025 19:54:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test,docs/=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EB=B0=8F=20=EB=AC=B8=EC=84=9C=20=EC=88=98=EC=A0=95#364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/api/challenge.adoc | 11 + .../challenge/api/ChallengeApiTest.java | 225 +++++++++--------- 2 files changed, 127 insertions(+), 109 deletions(-) diff --git a/src/docs/asciidoc/api/challenge.adoc b/src/docs/asciidoc/api/challenge.adoc index 77a26f9d..6b8c15b5 100644 --- a/src/docs/asciidoc/api/challenge.adoc +++ b/src/docs/asciidoc/api/challenge.adoc @@ -19,6 +19,17 @@ operation::challenge/get-challenge-page[snippets='http-request,http-response,res 현재 접속한 사용자가 참여하고 있는 챌린지 목록을 반환합니다. + +챌린지 상태의 경우, 다음의 7가지 상태 중 하나가 문자열로 전달됩니다. + +[ "SCHEDULED"(진행 예정), +"IN_PROGRESS"(진행 중), +"COMPLETED_PENDING_SETTLEMENT"(완료, 정산 안 됨), +"COMPLETED_SETTLED"(완료, 정산됨), +"CANCELED"(중도 취소), +"CANCELED_SETTLED"(중도 취소, 정산됨), +"CANCELED_BEFORE_START"(시작 전 취소함) ] + operation::challenge/get-my-challenge-list[snippets='http-request,http-response,response-fields'] === 다른 멤버의 챌린지 참여 목록 조회 diff --git a/src/test/java/com/habitpay/habitpay/domain/challenge/api/ChallengeApiTest.java b/src/test/java/com/habitpay/habitpay/domain/challenge/api/ChallengeApiTest.java index cf02698c..7d3bcfd0 100644 --- a/src/test/java/com/habitpay/habitpay/domain/challenge/api/ChallengeApiTest.java +++ b/src/test/java/com/habitpay/habitpay/domain/challenge/api/ChallengeApiTest.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.habitpay.habitpay.docs.springrestdocs.AbstractRestDocsTests; import com.habitpay.habitpay.domain.challenge.application.*; +import com.habitpay.habitpay.domain.challenge.domain.ChallengeState; import com.habitpay.habitpay.domain.challenge.dto.ChallengeCreationRequest; import com.habitpay.habitpay.domain.challenge.dto.ChallengeCreationResponse; import com.habitpay.habitpay.domain.challenge.dto.ChallengeDetailsResponse; @@ -169,23 +170,24 @@ void getEnrolledChallengeList() throws Exception { // given ChallengeEnrolledListItemResponse response = ChallengeEnrolledListItemResponse.builder() - .challengeId(1L) - .title("챌린지 제목") - .description("챌린지 설명") - .startDate(ZonedDateTime.now()) - .endDate(ZonedDateTime.now().plusDays(5)) - .stopDate(null) - .totalParticipatingDaysCount(2) - .numberOfParticipants(1) - .participatingDays(1 << 2) - .totalFee(1000) - .isPaidAll(false) - .hostProfileImage("챌린지 주최자 프로필 이미지") - .isMemberGivenUp(false) - .successCount(4) - .isTodayParticipatingDay(true) - .isParticipatedToday(false) - .build(); + .challengeId(1L) + .title("챌린지 제목") + .description("챌린지 설명") + .startDate(ZonedDateTime.now()) + .endDate(ZonedDateTime.now().plusDays(5)) + .stopDate(null) + .totalParticipatingDaysCount(2) + .numberOfParticipants(1) + .participatingDays(1 << 2) + .totalFee(1000) + .isPaidAll(false) + .hostProfileImage("챌린지 주최자 프로필 이미지") + .isMemberGivenUp(false) + .successCount(4) + .isTodayParticipatingDay(true) + .isParticipatedToday(false) + .challengeState(String.valueOf(ChallengeState.IN_PROGRESS)) + .build(); given(challengeSearchService.getEnrolledChallengeList(any(Member.class))) .willReturn(SuccessResponse.of(SuccessCode.NO_MESSAGE, List.of(response))); @@ -201,24 +203,25 @@ void getEnrolledChallengeList() throws Exception { headerWithName(HttpHeaders.AUTHORIZATION).description("액세스 토큰") ), responseFields( - fieldWithPath("message").description("메세지"), - fieldWithPath("data[].challengeId").description("챌린지 ID"), - fieldWithPath("data[].title").description("챌린지 제목"), - fieldWithPath("data[].description").description("챌린지 설명"), - fieldWithPath("data[].startDate").description("챌린지 시작 일시"), - fieldWithPath("data[].endDate").description("챌린지 종료 일시"), - fieldWithPath("data[].stopDate").description("챌린지 중단 일시"), - fieldWithPath("data[].totalParticipatingDaysCount").description("챌린지 총 참여 일수"), - fieldWithPath("data[].numberOfParticipants").description("챌린지 참여 인원"), - fieldWithPath("data[].participatingDays").description("챌린지 참여 요일"), - fieldWithPath("data[].totalFee").description("나의 벌금 합계"), - fieldWithPath("data[].isPaidAll").description("최종 정산 여부"), - fieldWithPath("data[].hostProfileImage").description("챌린지 주최자 프로필 이미지"), - fieldWithPath("data[].isMemberGivenUp").description("현재 사용자의 챌린지 포기 여부"), - fieldWithPath("data[].successCount").description("챌린지 인증 성공 횟수"), - fieldWithPath("data[].isTodayParticipatingDay").description( - "오늘 요일 == 챌린지 참여 요일"), - fieldWithPath("data[].isParticipatedToday").description("오늘 챌린지 참여 여부") + fieldWithPath("message").description("메세지"), + fieldWithPath("data[].challengeId").description("챌린지 ID"), + fieldWithPath("data[].title").description("챌린지 제목"), + fieldWithPath("data[].description").description("챌린지 설명"), + fieldWithPath("data[].startDate").description("챌린지 시작 일시"), + fieldWithPath("data[].endDate").description("챌린지 종료 일시"), + fieldWithPath("data[].stopDate").description("챌린지 중단 일시"), + fieldWithPath("data[].totalParticipatingDaysCount").description("챌린지 총 참여 일수"), + fieldWithPath("data[].numberOfParticipants").description("챌린지 참여 인원"), + fieldWithPath("data[].participatingDays").description("챌린지 참여 요일"), + fieldWithPath("data[].totalFee").description("나의 벌금 합계"), + fieldWithPath("data[].isPaidAll").description("최종 정산 여부"), + fieldWithPath("data[].hostProfileImage").description("챌린지 주최자 프로필 이미지"), + fieldWithPath("data[].isMemberGivenUp").description("현재 사용자의 챌린지 포기 여부"), + fieldWithPath("data[].successCount").description("챌린지 인증 성공 횟수"), + fieldWithPath("data[].isTodayParticipatingDay").description( + "오늘 요일 == 챌린지 참여 요일"), + fieldWithPath("data[].isParticipatedToday").description("오늘 챌린지 참여 여부"), + fieldWithPath("data[].challengeState").description("챌린지 상태") ) )); } @@ -230,23 +233,24 @@ void getEnrolledChallengeListForMember() throws Exception { // given ChallengeEnrolledListItemResponse response = ChallengeEnrolledListItemResponse.builder() - .challengeId(1L) - .title("챌린지 제목") - .description("챌린지 설명") - .startDate(ZonedDateTime.now()) - .endDate(ZonedDateTime.now().plusDays(5)) - .stopDate(null) - .totalParticipatingDaysCount(2) - .numberOfParticipants(1) - .participatingDays(1 << 2) - .totalFee(1000) - .isPaidAll(false) - .hostProfileImage("챌린지 주최자 프로필 이미지") - .isMemberGivenUp(false) - .successCount(4) - .isTodayParticipatingDay(true) - .isParticipatedToday(false) - .build(); + .challengeId(1L) + .title("챌린지 제목") + .description("챌린지 설명") + .startDate(ZonedDateTime.now()) + .endDate(ZonedDateTime.now().plusDays(5)) + .stopDate(null) + .totalParticipatingDaysCount(2) + .numberOfParticipants(1) + .participatingDays(1 << 2) + .totalFee(1000) + .isPaidAll(false) + .hostProfileImage("챌린지 주최자 프로필 이미지") + .isMemberGivenUp(false) + .successCount(4) + .isTodayParticipatingDay(true) + .isParticipatedToday(false) + .challengeState(String.valueOf(ChallengeState.COMPLETED_PENDING_SETTLEMENT)) + .build(); given(challengeSearchService.getEnrolledChallengeListForMember(anyLong())) .willReturn(SuccessResponse.of(SuccessCode.NO_MESSAGE, List.of(response))); @@ -262,24 +266,25 @@ void getEnrolledChallengeListForMember() throws Exception { headerWithName(HttpHeaders.AUTHORIZATION).description("액세스 토큰") ), responseFields( - fieldWithPath("message").description("메세지"), - fieldWithPath("data[].challengeId").description("챌린지 ID"), - fieldWithPath("data[].title").description("챌린지 제목"), - fieldWithPath("data[].description").description("챌린지 설명"), - fieldWithPath("data[].startDate").description("챌린지 시작 일시"), - fieldWithPath("data[].endDate").description("챌린지 종료 일시"), - fieldWithPath("data[].stopDate").description("챌린지 중단 일시"), - fieldWithPath("data[].totalParticipatingDaysCount").description("챌린지 총 참여 일수"), - fieldWithPath("data[].numberOfParticipants").description("챌린지 참여 인원"), - fieldWithPath("data[].participatingDays").description("챌린지 참여 요일"), - fieldWithPath("data[].totalFee").description("나의 벌금 합계"), - fieldWithPath("data[].isPaidAll").description("최종 정산 여부"), - fieldWithPath("data[].hostProfileImage").description("챌린지 주최자 프로필 이미지"), - fieldWithPath("data[].isMemberGivenUp").description("현재 사용자의 챌린지 포기 여부"), - fieldWithPath("data[].successCount").description("챌린지 인증 성공 횟수"), - fieldWithPath("data[].isTodayParticipatingDay").description( - "오늘 요일 == 챌린지 참여 요일"), - fieldWithPath("data[].isParticipatedToday").description("오늘 챌린지 참여 여부") + fieldWithPath("message").description("메세지"), + fieldWithPath("data[].challengeId").description("챌린지 ID"), + fieldWithPath("data[].title").description("챌린지 제목"), + fieldWithPath("data[].description").description("챌린지 설명"), + fieldWithPath("data[].startDate").description("챌린지 시작 일시"), + fieldWithPath("data[].endDate").description("챌린지 종료 일시"), + fieldWithPath("data[].stopDate").description("챌린지 중단 일시"), + fieldWithPath("data[].totalParticipatingDaysCount").description("챌린지 총 참여 일수"), + fieldWithPath("data[].numberOfParticipants").description("챌린지 참여 인원"), + fieldWithPath("data[].participatingDays").description("챌린지 참여 요일"), + fieldWithPath("data[].totalFee").description("나의 벌금 합계"), + fieldWithPath("data[].isPaidAll").description("최종 정산 여부"), + fieldWithPath("data[].hostProfileImage").description("챌린지 주최자 프로필 이미지"), + fieldWithPath("data[].isMemberGivenUp").description("현재 사용자의 챌린지 포기 여부"), + fieldWithPath("data[].successCount").description("챌린지 인증 성공 횟수"), + fieldWithPath("data[].isTodayParticipatingDay").description( + "오늘 요일 == 챌린지 참여 요일"), + fieldWithPath("data[].isParticipatedToday").description("오늘 챌린지 참여 여부"), + fieldWithPath("data[].challengeState").description("챌린지 상태") ) )); } @@ -291,24 +296,25 @@ void getChallengeDetails() throws Exception { // given ChallengeDetailsResponse challengeDetailsResponse = ChallengeDetailsResponse.builder() - .title("챌린지 제목") - .description("챌린지 설명") - .startDate(ZonedDateTime.now()) - .endDate(ZonedDateTime.now().plusDays(5)) - .stopDate(null) - .numberOfParticipants(1) - .participatingDays(1 << 2) - .feePerAbsence(1000) - .totalAbsenceFee(0) - .isPaidAll(false) - .hostNickname("챌린지 주최자 닉네임") - .enrolledMembersProfileImageList(List.of("imageLink1", "imageLink2", "imageLink3")) - .isHost(true) - .isMemberEnrolledInChallenge(true) - .isTodayParticipatingDay(true) - .isParticipatedToday(true) - .isGivenUp(false) - .build(); + .title("챌린지 제목") + .description("챌린지 설명") + .startDate(ZonedDateTime.now()) + .endDate(ZonedDateTime.now().plusDays(5)) + .stopDate(null) + .numberOfParticipants(1) + .participatingDays(1 << 2) + .feePerAbsence(1000) + .totalAbsenceFee(0) + .isPaidAll(false) + .hostNickname("챌린지 주최자 닉네임") + .enrolledMembersProfileImageList(List.of("imageLink1", "imageLink2", "imageLink3")) + .isHost(true) + .isMemberEnrolledInChallenge(true) + .isTodayParticipatingDay(true) + .isParticipatedToday(true) + .isGivenUp(false) + .challengeState(String.valueOf(ChallengeState.SCHEDULED)) + .build(); given(challengeDetailsService.getChallengeDetails(anyLong(), any(Member.class))) .willReturn(SuccessResponse.of(SuccessCode.NO_MESSAGE, challengeDetailsResponse)); @@ -324,27 +330,28 @@ void getChallengeDetails() throws Exception { headerWithName(HttpHeaders.AUTHORIZATION).description("액세스 토큰") ), responseFields( - fieldWithPath("message").description("메세지"), - fieldWithPath("data.title").description("챌린지 제목"), - fieldWithPath("data.description").description("챌린지 설명"), - fieldWithPath("data.startDate").description("챌린지 시작 일시"), - fieldWithPath("data.endDate").description("챌린지 종료 일시"), - fieldWithPath("data.stopDate").description("챌린지 중단 일시"), - fieldWithPath("data.numberOfParticipants").description("챌린지 참여 인"), - fieldWithPath("data.participatingDays").description("챌린지 참여 요일"), - fieldWithPath("data.feePerAbsence").description("미참여 1회당 벌금"), - fieldWithPath("data.totalAbsenceFee").description("챌린지 전체 벌금"), - fieldWithPath("data.isPaidAll").description("최종 정산 여부"), - fieldWithPath("data.hostNickname").description("챌린지 주최자 닉네임"), - fieldWithPath("data.enrolledMembersProfileImageList").description( - "챌린지 참여자 프로필 이미지 (최대 3명)"), - fieldWithPath("data.isHost").description("현재 접속한 사용자 == 챌린지 주최자"), - fieldWithPath("data.isMemberEnrolledInChallenge").description( - "현재 접속한 사용자의 챌린지 참여 여부"), - fieldWithPath("data.isTodayParticipatingDay").description("금일이 챌린지 참여일인지 여부"), - fieldWithPath("data.isParticipatedToday").description( - "현재 접속한 사용자가 챌린지의 참가자일 경우, 금일 참여했는지 여부(참가자가 아니어도 false)"), - fieldWithPath("data.isGivenUp").description("챌린지 중도 포기 여부") + fieldWithPath("message").description("메세지"), + fieldWithPath("data.title").description("챌린지 제목"), + fieldWithPath("data.description").description("챌린지 설명"), + fieldWithPath("data.startDate").description("챌린지 시작 일시"), + fieldWithPath("data.endDate").description("챌린지 종료 일시"), + fieldWithPath("data.stopDate").description("챌린지 중단 일시"), + fieldWithPath("data.numberOfParticipants").description("챌린지 참여 인"), + fieldWithPath("data.participatingDays").description("챌린지 참여 요일"), + fieldWithPath("data.feePerAbsence").description("미참여 1회당 벌금"), + fieldWithPath("data.totalAbsenceFee").description("챌린지 전체 벌금"), + fieldWithPath("data.isPaidAll").description("최종 정산 여부"), + fieldWithPath("data.hostNickname").description("챌린지 주최자 닉네임"), + fieldWithPath("data.enrolledMembersProfileImageList").description( + "챌린지 참여자 프로필 이미지 (최대 3명)"), + fieldWithPath("data.isHost").description("현재 접속한 사용자 == 챌린지 주최자"), + fieldWithPath("data.isMemberEnrolledInChallenge").description( + "현재 접속한 사용자의 챌린지 참여 여부"), + fieldWithPath("data.isTodayParticipatingDay").description("금일이 챌린지 참여일인지 여부"), + fieldWithPath("data.isParticipatedToday").description( + "현재 접속한 사용자가 챌린지의 참가자일 경우, 금일 참여했는지 여부(참가자가 아니어도 false)"), + fieldWithPath("data.isGivenUp").description("챌린지 중도 포기 여부"), + fieldWithPath("data.challengeState").description("챌린지 상태") ) )); } From 2b1b99e3c1d842dc4ab7cf887891aa2562fe2b9e Mon Sep 17 00:00:00 2001 From: ssolpang Date: Thu, 6 Feb 2025 20:16:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?test,docs/=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EC=A0=95=EC=82=B0=20api=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD#364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ChallengeSettlementService.java | 9 ++++++--- .../habitpay/domain/challenge/domain/Challenge.java | 11 +++++++++++ .../habitpay/global/error/exception/ErrorCode.java | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/habitpay/habitpay/domain/challenge/application/ChallengeSettlementService.java b/src/main/java/com/habitpay/habitpay/domain/challenge/application/ChallengeSettlementService.java index 5079f764..55525b93 100644 --- a/src/main/java/com/habitpay/habitpay/domain/challenge/application/ChallengeSettlementService.java +++ b/src/main/java/com/habitpay/habitpay/domain/challenge/application/ChallengeSettlementService.java @@ -33,11 +33,14 @@ public SuccessResponse settleChallenge(Long challengeId, Member member) { throw new BadRequestException(ErrorCode.INVALID_CHALLENGE_SETTLEMENT_TIME); } - if (!(challenge.getState() == ChallengeState.COMPLETED_PENDING_SETTLEMENT)) { - throw new BadRequestException(ErrorCode.INVALID_CHALLENGE_STATE_FOR_SETTLEMENT); + switch (challenge.getState()) { + case COMPLETED_PENDING_SETTLEMENT -> challenge.setStateCompletedSettled(); + case COMPLETED_SETTLED -> challenge.setStateCompletedPendingSettlement(); + case CANCELED -> challenge.setStateCanceledSettled(); + case CANCELED_SETTLED -> challenge.setStateCanceled(); + default -> throw new BadRequestException(ErrorCode.INVALID_CHALLENGE_STATE_FOR_SETTLEMENT); } - challenge.setStateCompletedSettled(); challengeRepository.save(challenge); return SuccessResponse.of(SuccessCode.CHALLENGE_SETTLEMENT_SUCCESS); diff --git a/src/main/java/com/habitpay/habitpay/domain/challenge/domain/Challenge.java b/src/main/java/com/habitpay/habitpay/domain/challenge/domain/Challenge.java index 2292637c..ff08e30e 100644 --- a/src/main/java/com/habitpay/habitpay/domain/challenge/domain/Challenge.java +++ b/src/main/java/com/habitpay/habitpay/domain/challenge/domain/Challenge.java @@ -157,6 +157,7 @@ public void setStateInProgress() { } public void setStateCompletedPendingSettlement() { + this.isPaidAll = false; this.state = ChallengeState.COMPLETED_PENDING_SETTLEMENT; } @@ -165,6 +166,16 @@ public void setStateCompletedSettled() { this.state = ChallengeState.COMPLETED_SETTLED; } + public void setStateCanceledSettled() { + this.isPaidAll = true; + this.state = ChallengeState.CANCELED_SETTLED; + } + + public void setStateCanceled() { + this.isPaidAll = false; + this.state = ChallengeState.CANCELED; + } + public boolean isTodayParticipatingDay() { ZonedDateTime nowInLocal = TimeZoneConverter.convertEtcToLocalTimeZone(ZonedDateTime.now()); DayOfWeek today = nowInLocal.getDayOfWeek(); diff --git a/src/main/java/com/habitpay/habitpay/global/error/exception/ErrorCode.java b/src/main/java/com/habitpay/habitpay/global/error/exception/ErrorCode.java index 3dc5cb0c..956a12ef 100644 --- a/src/main/java/com/habitpay/habitpay/global/error/exception/ErrorCode.java +++ b/src/main/java/com/habitpay/habitpay/global/error/exception/ErrorCode.java @@ -47,7 +47,7 @@ public enum ErrorCode { NOT_ALLOWED_TO_CANCEL_ENROLLMENT_OF_HOST(HttpStatus.BAD_REQUEST, "챌린지 주최자는 참여 취소가 불가능 합니다."), NOT_ALLOWED_TO_DELETE_CHALLENGE(HttpStatus.FORBIDDEN, "챌린지 삭제는 챌린지 주최자만 가능합니다."), INVALID_CHALLENGE_SETTLEMENT_TIME(HttpStatus.BAD_REQUEST, "정산은 챌린지 종료 이후에 가능합니다."), - INVALID_CHALLENGE_STATE_FOR_SETTLEMENT(HttpStatus.BAD_REQUEST, "정산은 챌린지가 종료 이후 정산 대기 상태일 때만 가능합니다."), + INVALID_CHALLENGE_STATE_FOR_SETTLEMENT(HttpStatus.BAD_REQUEST, "정산 혹은 정산 취소 처리가 불가한 상태입니다."), // Challenge Participation Record RECORD_NOT_FOUND(HttpStatus.NOT_FOUND, "챌린지 참여 기록이 존재하지 않습니다."), From 58423be942153c722c78718354eab3890a93ecd3 Mon Sep 17 00:00:00 2001 From: ssolpang Date: Thu, 6 Feb 2025 20:34:17 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat/=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=A0=95=EC=82=B0=20=EC=83=81=ED=83=9C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20=EC=8B=9C=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=20=EB=B3=80=EA=B2=BD#364?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/habitpay/habitpay/global/response/SuccessCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/habitpay/habitpay/global/response/SuccessCode.java b/src/main/java/com/habitpay/habitpay/global/response/SuccessCode.java index af67b421..b083704c 100644 --- a/src/main/java/com/habitpay/habitpay/global/response/SuccessCode.java +++ b/src/main/java/com/habitpay/habitpay/global/response/SuccessCode.java @@ -22,7 +22,7 @@ public enum SuccessCode { CANCEL_CHALLENGE_ENROLLMENT_SUCCESS("정상적으로 챌린지 등록을 취소했습니다."), GIVING_UP_CHALLENGE("정상적으로 챌린지 중도 포기 처리가 되었습니다."), DELETE_CHALLENGE_SUCCESS("정상적으로 챌린지를 삭제했습니다."), - CHALLENGE_SETTLEMENT_SUCCESS("정상적으로 챌린지 정산이 완료되었습니다."), + CHALLENGE_SETTLEMENT_SUCCESS("정상적으로 챌린지 정산 상태가 변경되었습니다."), // Post CREATE_POST_SUCCESS("정상적으로 포스트를 생성했습니다."),