Skip to content

Commit

Permalink
Merge pull request #265 from Geek-sasaeng/mini
Browse files Browse the repository at this point in the history
Mini
  • Loading branch information
xhaktmchl authored Jan 2, 2023
2 parents 851c200 + 556c461 commit d071d8d
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 108 deletions.
103 changes: 0 additions & 103 deletions src/main/generated/shop/geeksasang/domain/member/QMember.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import shop.geeksasang.dto.chat.PostChatImageReq;


import shop.geeksasang.dto.chat.chatparty.PatchOrderReq;
import shop.geeksasang.dto.chat.partychatroom.GetPartyChatRoomsRes;
import shop.geeksasang.dto.chat.PostChatReq;
import shop.geeksasang.dto.chat.partychatroom.PartyChatRoomRes;
Expand Down Expand Up @@ -181,13 +182,12 @@ public BaseResponse<SuccessCommonRes> removeChatRoomMember(HttpServletRequest re
return new BaseResponse(new SuccessCommonRes());
}

//todo : dto validation
@ApiOperation(value = "송금 완료 ", notes = "(jwt 토큰 필요) 채팅방 내에서 송금완료 버튼을 누를 때 사용하는 api")
@ApiResponses({
@ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."),
@ApiResponse(code = 2008 ,message ="채팅방 멤버가 존재하지 않습니다."),
@ApiResponse(code = 2208 ,message ="채팅방 멤버가 존재하지 않습니다."),
@ApiResponse(code = 2009 ,message ="존재하지 않는 멤버입니다."),
@ApiResponse(code = 2005 ,message ="채팅방이 존재하지 않습니다."),
@ApiResponse(code = 2207 ,message ="채팅방이 존재하지 않습니다."),
@ApiResponse(code = 4000 ,message ="서버 오류입니다.")
})
@PatchMapping("/members/remittance")
Expand All @@ -196,4 +196,22 @@ public BaseResponse<String> changeRemittance(HttpServletRequest request, @Valid
deliveryPartyChatService.changeRemittance(jwtInfo.getUserId(), dto.getRoomId());
return new BaseResponse<>("요청에 성공하셨습니다.");
}

@ApiOperation(value = "주문 완료 ", notes = "(jwt 토큰 필요) 채팅방 내에서 주문 완료 버튼을 누를 때 사용하는 api")
@ApiResponses({
@ApiResponse(code = 1000 ,message ="요청에 성공하셨습니다."),
@ApiResponse(code = 2208 ,message ="채팅방 멤버가 존재하지 않습니다."),
@ApiResponse(code = 2009 ,message ="존재하지 않는 멤버입니다."),
@ApiResponse(code = 2207 ,message ="채팅방이 존재하지 않습니다."),
@ApiResponse(code = 2010 ,message ="존재하지 않는 파티입니다."),
@ApiResponse(code = 2210 ,message ="채팅이 존재하지 않습니다."),
@ApiResponse(code = 4000 ,message ="서버 오류입니다."),
})
@PatchMapping("/order")
public BaseResponse<String> changeOrderStatus(HttpServletRequest request, @Valid @RequestBody PatchOrderReq dto){
JwtInfo jwtInfo = (JwtInfo) request.getAttribute("jwtInfo");
deliveryPartyChatService.changeOrderStatus(jwtInfo.getUserId(), dto.getRoomId());
return new BaseResponse<>("요청에 성공하셨습니다.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import shop.geeksasang.config.domain.BaseEntity;
import shop.geeksasang.config.status.MatchingStatus;
import shop.geeksasang.config.status.OrderStatus;
import shop.geeksasang.config.type.OrderTimeCategoryType;
import shop.geeksasang.config.status.BaseStatus;
import shop.geeksasang.domain.location.Location;
Expand Down Expand Up @@ -79,6 +80,9 @@ public class DeliveryParty extends BaseEntity {

private String uuid;

@Enumerated(EnumType.STRING)
private OrderStatus orderStatus;

@Embedded
@AttributeOverrides({
@AttributeOverride(name="latitude",column = @Column(name="latitude")),
Expand Down Expand Up @@ -107,6 +111,7 @@ public static DeliveryParty makeParty(PostDeliveryPartyReq dto, OrderTimeCategor
.reportedCount(0)
.uuid(createUuid())
.deliveryPartyMembers(new ArrayList<>())
.orderStatus(OrderStatus.BEFORE_ORDER)
.build();

party.setStatus(BaseStatus.ACTIVE);
Expand Down Expand Up @@ -224,4 +229,8 @@ public void deleteNowChief(){
public void removeDeliveryPartyMember(DeliveryPartyMember deliveryPartyMember){
deliveryPartyMembers.remove(deliveryPartyMember);
}

public void changeOrderStatusToOrderComplete(){
this.orderStatus = OrderStatus.ORDER_COMPLETE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package shop.geeksasang.dto.chat.chatparty;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

@Getter
@NoArgsConstructor
public class PatchOrderReq {
@ApiModelProperty(example = "639ddf7e08c0c27e2d5e6090", value = "배달파티 채팅방 id", required = true)
@NotBlank(message = "배달 파티 채팅방 id를 입력하세요.")
private String roomId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.*;
import shop.geeksasang.config.status.BelongStatus;
import shop.geeksasang.config.status.MatchingStatus;
import shop.geeksasang.config.status.OrderStatus;
import shop.geeksasang.domain.deliveryparty.DeliveryParty;

import java.time.LocalDateTime;
Expand Down Expand Up @@ -97,6 +98,9 @@ public class PostDeliveryPartyRes {
@ApiModelProperty(example = "신한은행", value = "은행이름")
private String bank;

@ApiModelProperty(example = "BEFORE_ORDER", value = "주문 상태를 나타내는 값 - 주문 전: BEFORE_ORDER, 주문 완료상태: ORDER_COMPLETE, 배달 완료: DELIVERY_COMPLETE ")
private OrderStatus orderStatus;

static public PostDeliveryPartyRes toDto(DeliveryParty deliveryParty){
return PostDeliveryPartyRes.builder()
.id(deliveryParty.getId())
Expand Down Expand Up @@ -125,14 +129,15 @@ static public PostDeliveryPartyRes toDto(DeliveryParty deliveryParty){
.chatRoomName(deliveryParty.getChatRoomName())
.accountNumber(deliveryParty.getAccountNumber())
.bank(deliveryParty.getBank())
.orderStatus(deliveryParty.getOrderStatus())
.build();
}

@Builder
public PostDeliveryPartyRes(int id, String chief, int chiefId, String chiefProfileImgUrl, String foodCategory, boolean hashTag, String title, String content,
LocalDateTime orderTime, int currentMatching, int maxMatching, MatchingStatus matchingStatus, String updatedAt, Double latitude,
Double longitude, String storeUrl, boolean authorStatus, String uuid, BelongStatus belongStatus, int dormitoryId,
String dormitoryName, String createdAt, String orderTimeCategoryType, String chatRoomName, String accountNumber, String bank) {
String dormitoryName, String createdAt, String orderTimeCategoryType, String chatRoomName, String accountNumber, String bank, OrderStatus orderStatus) {
this.id = id;
this.chief = chief;
this.chiefId = chiefId;
Expand All @@ -159,6 +164,7 @@ public PostDeliveryPartyRes(int id, String chief, int chiefId, String chiefProfi
this.chatRoomName = chatRoomName;
this.accountNumber = accountNumber;
this.bank = bank;
this.orderStatus = orderStatus;
}

//테스트용
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import shop.geeksasang.repository.member.MemberRepository;
import shop.geeksasang.service.common.AwsS3Service;
import shop.geeksasang.service.deliveryparty.DeliveryPartyMemberService;
import shop.geeksasang.service.deliveryparty.DeliveryPartyService;

import java.io.IOException;
import java.time.LocalDateTime;
Expand All @@ -57,6 +58,7 @@ public class DeliveryPartyChatService {
private final MemberRepository memberRepository;
private final AwsS3Service awsS3Service;
private final DeliveryPartyMemberService deliveryPartyMemberService;
private final DeliveryPartyService deliveryPartyService;

private static final String PAGING_STANDARD = "createdAt";

Expand Down Expand Up @@ -330,7 +332,7 @@ public void changeRemittance(int memberId, String roomId) {

//채팅방 존재 여부 확인
PartyChatRoom chatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(roomId))
.orElseThrow(() -> new BaseException(NOT_EXIST_CHAT_ROOM_CHIEF));
.orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM));

//mongo 데이터 수정
partyChatRoomMemberRepository.changeRemittance(new ObjectId(member.getId()), new ObjectId(roomId));
Expand All @@ -339,5 +341,29 @@ public void changeRemittance(int memberId, String roomId) {
deliveryPartyMemberService.changeAccountTransferStatus(chatRoom.getDeliveryPartyId(), member.getMemberId());
}

@Transactional(readOnly = false)
public void changeOrderStatus(int memberId, String roomId) {

//mongo(채팅방) 회원 존재 여부 확인
PartyChatRoomMember chatRoomMember = partyChatRoomMemberRepository
.findByMemberIdAndChatRoomId(memberId, new ObjectId(roomId))
.orElseThrow(() -> new BaseException(NOT_EXISTS_PARTYCHATROOM_MEMBER));

//mysql 회원 존재 여부 확인
Member member = memberRepository.findMemberById(memberId)
.orElseThrow(() -> new BaseException(NOT_EXISTS_PARTICIPANT));

//채팅방 존재 여부 확인
PartyChatRoom partyChatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(roomId))
.orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM));

//mysql - OrderStatus 값 바꾸기
deliveryPartyService.changeOrderStatus(partyChatRoom.getDeliveryPartyId());

//주문 완료 시스템 메시지
this.createChat(memberId, roomId, "주문이 완료되었습니다.", true, member.getProfileImgUrl(), "publish", "none", false);

}

}
// String exchange, String routingKey, Object message
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,14 @@ public GetEndedDeliveryPartiesRes getEndedDeliveryParties(int userId, int cursor

return endedDeliveryParties;
}

@Transactional(readOnly = false)
public void changeOrderStatus(int partyId){
//배달파티 조회
DeliveryParty deliveryParty = deliveryPartyRepository.findDeliveryPartyById(partyId)
.orElseThrow(() -> new BaseException(NOT_EXISTS_PARTY));

//주문 완료 상태 수정
deliveryParty.changeOrderStatusToOrderComplete();
}
}

0 comments on commit d071d8d

Please sign in to comment.