diff --git a/src/main/java/shop/geeksasang/config/exception/response/BaseResponseStatus.java b/src/main/java/shop/geeksasang/config/exception/response/BaseResponseStatus.java index 0259f705..f3621a2d 100644 --- a/src/main/java/shop/geeksasang/config/exception/response/BaseResponseStatus.java +++ b/src/main/java/shop/geeksasang/config/exception/response/BaseResponseStatus.java @@ -83,6 +83,7 @@ public enum BaseResponseStatus { NOT_EXIST_CHAT_ROOM_CHIEF(false,2024,"배달 파티 채팅방 방장이 존재하지 않습니다."), NOT_CHAT_ROOM_CHIEF(false,2025,"배달 파티 채팅방 방장이 아닙니다."), CANT_REMOVE_REMIT_MEMBER(false,2026,"송금을 완료한 멤버는 방에서 퇴장시킬 수 없습니다."), + ALREADY_PARTY_FINISH(false, 2027 , "이미 마감한 파티입니다."), diff --git a/src/main/java/shop/geeksasang/dto/chat/partychatroom/GetPartyChatRoomDetailRes.java b/src/main/java/shop/geeksasang/dto/chat/partychatroom/GetPartyChatRoomDetailRes.java index 30422211..ca8da396 100644 --- a/src/main/java/shop/geeksasang/dto/chat/partychatroom/GetPartyChatRoomDetailRes.java +++ b/src/main/java/shop/geeksasang/dto/chat/partychatroom/GetPartyChatRoomDetailRes.java @@ -35,9 +35,15 @@ public class GetPartyChatRoomDetailRes { @ApiModelProperty(example = "88", value = "채팅방 방장 id") private int chiefId; + @ApiModelProperty(example = "34", value = "채팅방 id") + private int partyId; + + @ApiModelProperty(example = "true", value = "배달 파티 매칭 완료 여부") + private Boolean isMatchingFinish; @Builder - public GetPartyChatRoomDetailRes(Boolean isRemittanceFinish, Boolean isChief, Boolean isOrderFinish, String accountNumber, String bank, LocalDateTime enterTime, int chiefId) { + public GetPartyChatRoomDetailRes(Boolean isRemittanceFinish, Boolean isChief, Boolean isOrderFinish, String accountNumber, String bank, LocalDateTime enterTime, + int chiefId, int partyId, boolean isMatchingFinish) { this.isRemittanceFinish = isRemittanceFinish; this.isChief = isChief; this.isOrderFinish = isOrderFinish; @@ -45,6 +51,8 @@ public GetPartyChatRoomDetailRes(Boolean isRemittanceFinish, Boolean isChief, Bo this.bank = bank; this.enterTime = enterTime; this.chiefId = chiefId; + this.partyId = partyId; + this.isMatchingFinish = isMatchingFinish; } public static GetPartyChatRoomDetailRes toDto(PartyChatRoom partyChatRoom, PartyChatRoomMember partyChatRoomMember,Boolean isChief,Boolean isOrderFinish){ @@ -56,6 +64,8 @@ public static GetPartyChatRoomDetailRes toDto(PartyChatRoom partyChatRoom, Party .bank(partyChatRoom.getBank()) .enterTime(partyChatRoomMember.getEnterTime()) .chiefId(partyChatRoom.getChief().getMemberId()) + .partyId(partyChatRoom.getDeliveryPartyId()) + .isMatchingFinish(partyChatRoom.getIsFinish()) .build(); } } diff --git a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java index 692a8888..58e356e1 100644 --- a/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java +++ b/src/main/java/shop/geeksasang/service/chat/DeliveryPartyChatService.java @@ -195,12 +195,16 @@ public PartyChatRoomMemberRes joinPartyChatRoom(int memberId, String chatRoomId, Member member = memberRepository.findMemberById(memberId) .orElseThrow(() -> new BaseException(NOT_EXIST_USER)); - String email = member.getEmail().getAddress(); String profileImgUrl = member.getProfileImgUrl(); PartyChatRoom partyChatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(chatRoomId)) .orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM)); + //이미 마감했는지 + if(partyChatRoom.getIsFinish()){ + throw new BaseException(ALREADY_PARTY_FINISH); + } + //Validation 기존의 멤버인지 예외 처리 if (partyChatRoom.getParticipants().stream().anyMatch(participant -> participant.getMemberId() == memberId)) { throw new BaseException(ALREADY_PARTICIPATE_CHATROOM); diff --git a/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java b/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java index b87cb0d4..49685220 100644 --- a/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java +++ b/src/main/java/shop/geeksasang/service/deliveryparty/DeliveryPartyService.java @@ -1,6 +1,7 @@ package shop.geeksasang.service.deliveryparty; import lombok.RequiredArgsConstructor; +import org.bson.types.ObjectId; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; @@ -312,10 +313,17 @@ public PatchLeaveChiefRes chiefLeaveDeliveryParty(String uuid, String nickName, @Transactional(readOnly = false) public PatchDeliveryPartyMatchingStatusRes patchDeliveryPartyMatchingStatus(Integer partyId, int userId) { + //여기서 방장 인증을 진행함. DeliveryParty deliveryParty = deliveryPartyRepository.findDeliveryPartyByIdAndUserIdAndMatchingStatus(partyId, userId). orElseThrow(() -> new BaseException(BaseResponseStatus.CAN_NOT_FINISH_DELIVERY_PARTY)); - deliveryParty.changeMatchingStatusToFinish(); + + //그러므로 여기서 방장 인증을 진행할 필요가 없음. + PartyChatRoom partyChatRoom = partyChatRoomRepository.findByDeliveryPartyId(partyId) + .orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM)); + + partyChatRoomRepository.changeIsFinish(new ObjectId(partyChatRoom.getId())); + return PatchDeliveryPartyMatchingStatusRes.builder() .deliveryPartyId(deliveryParty.getId()) .matchingStatus(deliveryParty.getMatchingStatus().toString())