Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ sourceSets {
main.java.srcDirs += [generated]
}

test {
maxParallelForks = 1
}

// gradle clean ์‹œ์— QClass ๋””๋ ‰ํ† ๋ฆฌ ์‚ญ์ œ
clean {
delete file(generated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -20,6 +21,7 @@
import com.backend.global.dto.request.GlobalRequest;
import com.backend.global.dto.response.GenericResponse;
import com.backend.global.dto.response.ScrollResponse;
import com.backend.global.payment.dto.request.TossPaymentRequest;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand All @@ -36,6 +38,29 @@ public class ReservationController {

private final ReservationService reservationService;

@PostMapping("/prepare")
@Operation(summary = "์˜ˆ์•ฝ ์ค€๋น„ - ์ฃผ๋ฌธ์„œ ์ƒ์„ฑ", description = "๊ฒฐ์ œ๋ฅผ ์œ„ํ•œ ์˜ˆ์•ฝ ์ฃผ๋ฌธ์„œ ์ƒ์„ฑ")
public ResponseEntity<GenericResponse<ReservationResponse.Detail>> prepareReservation(
@RequestBody @Valid final ReservationRequest.Reserve requestDto,
@AuthenticationPrincipal final CustomOAuth2User user) {

ReservationResponse.Detail response = reservationService.prepareReservation(requestDto, user.getId());

return ResponseEntity.created(URI.create("/api/v1/reservations/" + response.reservationId()))
.body(GenericResponse.of(true, response));
}

@GetMapping("/confirm")
@Operation(summary = "๊ฒฐ์ œ ์Šน์ธ ๋ฐ ์˜ˆ์•ฝ ํ™•์ •", description = "Toss ๊ฒฐ์ œ ์„ฑ๊ณต ํ›„ ๊ฒฐ์ œ ์Šน์ธ API ํ˜ธ์ถœ")
public ResponseEntity<GenericResponse<Void>> confirmReservationPayment(
@ModelAttribute final TossPaymentRequest request,
@AuthenticationPrincipal final CustomOAuth2User user) {

reservationService.confirmReservationPayment(request, user.getId());

return ResponseEntity.ok(GenericResponse.of(true));
}

@PostMapping
@Operation(summary = "์˜ˆ์•ฝ ์‹ ์ฒญ ๋ฐ ์ƒ์„ฑ", description = "์œ ์ €๊ฐ€ ์„ ์ƒ ๋‚š์‹œ๋ฅผ ์˜ˆ์•ฝ ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” API")
public ResponseEntity<GenericResponse<ReservationResponse.Detail>> saveReservation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,21 @@ public record DetailWithName(
) {
}

/**
*
* @param reservationId
* @param shipFishingPostId
* @param reservationNumber
* @param subject
* @param reservationDate
* @param startTime
* @param location
* @param guestCount
* @param totalPrice
* @param reservationStatus
* @param fileIdList
* @param createdAt
*/
@Builder
public record DetailQueryDto(
Long reservationId,
Expand All @@ -149,6 +164,21 @@ public record DetailQueryDto(
}
}

/**
*
* @param reservationId
* @param shipFishingPostId
* @param reservationNumber
* @param subject
* @param reservationDate
* @param startTime
* @param location
* @param guestCount
* @param totalPrice
* @param reservationStatus
* @param fileUrlList
* @param createdAt
*/
@Builder
public record DetailReservationList(
Long reservationId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.backend.domain.reservation.entity;

import java.time.LocalDate;
import java.time.OffsetDateTime;

import com.backend.global.baseentity.BaseEntity;
import com.backend.global.payment.dto.response.TossPaymentResponse;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down Expand Up @@ -58,7 +60,28 @@ public class Reservation extends BaseEntity {
@Builder.Default
@Enumerated(EnumType.STRING)
@Column(nullable = false)
private ReservationStatus status = ReservationStatus.CONFIRMED;
private ReservationStatus status = ReservationStatus.PENDING;

@Column(length = 100)
private String paymentKey;

@Column(length = 20)
private String paymentMethod;

@Column(length = 50)
private String cardNumber;

@Column(length = 20)
private String cardApproveNo;

@Column(length = 1024)
private String receiptUrl;

@Column
private Long totalAmount;

@Column
private OffsetDateTime approvedAt;

public void updatePending(final Boolean isSuccess) {
this.status = isSuccess ? ReservationStatus.CONFIRMED : ReservationStatus.REJECTED;
Expand All @@ -67,4 +90,18 @@ public void updatePending(final Boolean isSuccess) {
public void updateCanceled() {
this.status = this.status == ReservationStatus.CONFIRMED ? ReservationStatus.CANCELLED : this.status;
}

public void updateTossPaymentInfo(final TossPaymentResponse response) {
this.paymentKey = response.getPaymentKey();
this.approvedAt = response.getApprovedAt();
this.paymentMethod = response.getMethod();
this.totalAmount = response.getTotalAmount();
if (response.getCard() != null) {
this.cardNumber = response.getCard().getNumber();
this.cardApproveNo = response.getCard().getApproveNo();
}
if (response.getReceipt() != null) {
this.receiptUrl = response.getReceipt().getUrl();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public enum ReservationErrorCode implements ErrorCode {
WRONG_PRICE_VALUE(HttpStatus.BAD_REQUEST, 11002, "์˜ˆ์•ฝ ๊ธˆ์•ก์ด ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค."),
NOT_AVAILABLE_DATE_RESERVATION(HttpStatus.CONFLICT, 11003, "์˜ˆ์•ฝ ๊ฐ€๋Šฅํ•œ ์ผ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค."),
NOT_AVAILABLE_END_RESERVATION(HttpStatus.CONFLICT, 11004, "์˜ˆ์•ฝ ์ •์› ์ดˆ๊ณผ ์ž…๋‹ˆ๋‹ค."),
NOT_AUTHORITY_RESERVATION(HttpStatus.FORBIDDEN, 11005, "ํ•ด๋‹น ์˜ˆ์•ฝ์— ๋Œ€ํ•œ ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค.");
NOT_AUTHORITY_RESERVATION(HttpStatus.FORBIDDEN, 11005, "ํ•ด๋‹น ์˜ˆ์•ฝ์— ๋Œ€ํ•œ ๊ถŒํ•œ์ด ์—†์Šต๋‹ˆ๋‹ค."),
ALREADY_CONFIRMED_RESERVATION(HttpStatus.BAD_REQUEST, 11006, "ํ•ด๋‹น ์˜ˆ์•ฝ์€ ์ด๋ฏธ ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");

private final HttpStatus httpStatus;
private final Integer code;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.backend.domain.reservation.repository;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import com.backend.domain.reservation.entity.Reservation;
Expand All @@ -9,4 +11,5 @@ public interface ReservationJpaRepository extends JpaRepository<Reservation, Lon

Long countByMemberIdAndStatus(final Long memberId, final ReservationStatus status);

Optional<Reservation> findByReservationNumber(final String reservationNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public interface ReservationRepository {
*/
Optional<Reservation> findById(final Long reservationId);

/**
* ์˜ˆ์•ฝ ๋ฒˆํ˜ธ๋กœ ์˜ˆ์•ฝ ์ •๋ณด ์กฐํšŒ ๋ฉ”์„œ๋“œ
*
* @param reservationNumber ์˜ˆ์•ฝ๋ฒˆํ˜ธ
* @return ์˜ˆ์•ฝ ๋ฐ์ดํ„ฐ
* @implSpec ์˜ˆ์•ฝ ๋ฒˆํ˜ธ์™€ ์ผ์น˜ํ•˜๋Š” ์˜ˆ์•ฝ ์ •๋ณด๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
*/
Optional<Reservation> findByReservationNumber(final String reservationNumber);

/**
* ์œ ์ €์˜ ์˜ˆ์•ฝ ๋‚ด์—ญ ํšŸ์ˆ˜๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public Optional<Reservation> findById(final Long reservationId) {
return reservationJpaRepository.findById(reservationId);
}

@Override
public Optional<Reservation> findByReservationNumber(final String reservationNumber) {

return reservationJpaRepository.findByReservationNumber(reservationNumber);
}

@Override
public Long getReservationCount(final Long memberId) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@
import com.backend.domain.reservation.dto.response.ReservationResponse;
import com.backend.global.dto.request.GlobalRequest;
import com.backend.global.dto.response.ScrollResponse;
import com.backend.global.payment.dto.request.TossPaymentRequest;

public interface ReservationService {

/**
* ์˜ˆ์•ฝ ์ „์— ์ฃผ๋ฌธ์„œ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ฉ”์„œ๋“œ
*
* @param requestDto ์˜ˆ์•ฝ ์ •๋ณด
* @param memberId ์œ ์ € ID
* @return ์ฃผ๋ฌธ์„œ ์ •๋ณด
*/
ReservationResponse.Detail prepareReservation(final ReservationRequest.Reserve requestDto, final Long memberId);

/**
* ๊ฒฐ์ œ ์š”์ฒญ ํ›„ ์žฌ๊ณ  ์ฐจ๊ฐ ์—ฌ๋ถ€๋กœ ๊ฒฐ์ œ ๋ฉ”์„œ๋“œ
*
* @param requestDto ํ† ์Šค ๊ฒฐ์ œ ์ •๋ณด
*/
void confirmReservationPayment(final TossPaymentRequest requestDto, final Long memberId);

/**
* ์˜ˆ์•ฝ์„ ์ƒ์„ฑํ•˜๋Š” ๋ฉ”์„œ๋“œ
*
Expand Down
Loading