-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
토스 페이먼츠 결제 승인 로직 전의 주문 승인 로직 추가 #110
Merged
daadaadaah
merged 5 commits into
f-lab-edu:develop
from
daadaadaah:feat/add-approveOrder
Jul 8, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
66c0e34
`OrderController`에 `approveOrder` 추가
daadaadaah 1597f3b
`OrderService`의 `approveOrder`에서 DB에서 검증에 필요한 데이터 가져오기
daadaadaah 33184ca
`OrderService`의 `approveOrder`에서 검증 로직 추가
daadaadaah 70c10af
`OrderService`의 `approveOrder`에서 재고 감소 로직 추가
daadaadaah 7e8e479
`OrderService`의 `approveOrder`에서 실제 주문 수량 계산 로직 추가
daadaadaah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/hcommerce/heecommerce/order/InvalidPaymentAmountException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public class InvalidPaymentAmountException extends RuntimeException { | ||
public InvalidPaymentAmountException() { | ||
super("결제 금액이 유효하지 않습니다."); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/hcommerce/heecommerce/order/OrderApproveForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.beans.ConstructorProperties; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class OrderApproveForm { | ||
|
||
@NotNull | ||
private final String paymentKey; // 토스 키 | ||
|
||
@NotNull | ||
private final String orderId; // 토스 주문 식별자 | ||
|
||
@NotNull | ||
private final int amount; // 총 결제 금액 | ||
|
||
@Builder | ||
@ConstructorProperties({ | ||
"paymentKey", | ||
"orderId", | ||
"amount" | ||
}) | ||
public OrderApproveForm(String paymentKey, String orderId, int amount) { | ||
this.paymentKey = paymentKey; | ||
this.orderId = orderId; | ||
this.amount = amount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hcommerce/heecommerce/order/OrderEntityForOrderApproveValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class OrderEntityForOrderApproveValidation { | ||
|
||
private final byte[] dealProductUuid; | ||
private final int orderQuantity; | ||
private final int totalPaymentAmount; | ||
private final OutOfStockHandlingOption outOfStockHandlingOption; | ||
|
||
@Builder | ||
public OrderEntityForOrderApproveValidation( | ||
byte[] dealProductUuid, | ||
int orderQuantity, | ||
int totalPaymentAmount, | ||
OutOfStockHandlingOption outOfStockHandlingOption | ||
) { | ||
this.dealProductUuid = dealProductUuid; | ||
this.orderQuantity = orderQuantity; | ||
this.totalPaymentAmount = totalPaymentAmount; | ||
this.outOfStockHandlingOption = outOfStockHandlingOption; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/hcommerce/heecommerce/order/OrderQueryMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
@Mapper | ||
public interface OrderQueryMapper { | ||
|
||
OrderEntityForOrderApproveValidation findOrderEntityForOrderApproveValidation(@Param("orderUuid") byte[] orderUuid); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hcommerce/heecommerce/order/OrderQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import com.hcommerce.heecommerce.common.utils.TypeConversionUtils; | ||
import java.util.UUID; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class OrderQueryRepository { | ||
|
||
private final OrderQueryMapper orderQueryMapper; | ||
|
||
@Autowired | ||
public OrderQueryRepository(OrderQueryMapper orderQueryMapper) { | ||
this.orderQueryMapper = orderQueryMapper; | ||
} | ||
|
||
public OrderEntityForOrderApproveValidation findOrderEntityForOrderApproveValidation(String orderId) { | ||
|
||
UUID orderUuid = UUID.fromString(orderId); | ||
|
||
byte[] orderUuidByte = TypeConversionUtils.convertUuidToBinary(orderUuid); | ||
|
||
return orderQueryMapper.findOrderEntityForOrderApproveValidation(orderUuidByte); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
<mapper namespace="com.hcommerce.heecommerce.order.OrderQueryMapper"> | ||
|
||
<!-- 주문 검증을 위해 주문 조회 --> | ||
<select id="findOrderEntityForOrderApproveValidation" resultType="OrderEntityForOrderApproveValidation"> | ||
SELECT deal_product_uuid, order_quantity, total_payment_amount, out_of_stock_handling_option FROM `order` WHERE uuid = #{orderUuid} | ||
</select> | ||
</mapper> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주석 추가