Skip to content

Commit

Permalink
refactor codesquad-kiosk-max-team-02#59: 결제 성공시 보내는 responseDto에 주문번호 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
DOEKYONG committed Jun 28, 2023
1 parent d8706eb commit 105315c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions be/src/main/java/com/codesquad/kiosk/service/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public int calculateOrder(OrderRequestDto orderRequestDto) {
return amount;
}

public CardPaymentResponseDto cardPay(OrderRequestDto orderRequestDto){
public CardPaymentResponseDto cardPay(int totalPay,OrderRequestDto orderRequestDto){
String now = createNowDateformat();
Order order = orderRepository.getOrder().orElse(Order.builder().orderTime(now).orderNumber(0).build());
OrderNumberCreatorDto dto = new OrderNumberCreatorDto(order.getOrderTime(),order.getOrderNumber());
return new CardPaymentResponseDto(
createOrderNumber(dto,now),
totalPay,
orderRequestDto.getNumber(),
calculateOrder(orderRequestDto),
Boolean.TRUE
);
}
Expand Down Expand Up @@ -80,15 +84,18 @@ public ReceiptDto getReceiptByOrderId(Integer orderId) {
return orderRepository.getReceiptByOrderId(orderId);
}

public CashPaymentResponseDto cashPayment( OrderRequestDto requestDto ) {
int totalPay = calculateOrder(requestDto);
public CashPaymentResponseDto cashPayment( int totalPay,OrderRequestDto requestDto ) {
String now = createNowDateformat();
Order order = orderRepository.getOrder().orElse(Order.builder().orderTime(now).orderNumber(0).build());
OrderNumberCreatorDto dto = new OrderNumberCreatorDto(order.getOrderTime(),order.getOrderNumber());
int inputMoney = requestDto.getNumber();
int changes = inputMoney - totalPay;
return CashPaymentResponseDto
.builder()
.totalPay(totalPay)
.changes(changes)
.result(true)
.orderNumber(createOrderNumber(dto,now))
.build();
}
private boolean random() {
Expand Down

0 comments on commit 105315c

Please sign in to comment.