From 105315caf5fc8e9b449f635918681b14b20b6995 Mon Sep 17 00:00:00 2001 From: DOEKYONG Date: Thu, 29 Jun 2023 03:08:17 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20#59:=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=EC=8B=9C=20=EB=B3=B4=EB=82=B4=EB=8A=94=20res?= =?UTF-8?q?ponseDto=EC=97=90=20=EC=A3=BC=EB=AC=B8=EB=B2=88=ED=98=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/codesquad/kiosk/service/OrderService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/be/src/main/java/com/codesquad/kiosk/service/OrderService.java b/be/src/main/java/com/codesquad/kiosk/service/OrderService.java index f7a3a527..d5ac937d 100644 --- a/be/src/main/java/com/codesquad/kiosk/service/OrderService.java +++ b/be/src/main/java/com/codesquad/kiosk/service/OrderService.java @@ -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 ); } @@ -80,8 +84,10 @@ 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 @@ -89,6 +95,7 @@ public CashPaymentResponseDto cashPayment( OrderRequestDto requestDto ) { .totalPay(totalPay) .changes(changes) .result(true) + .orderNumber(createOrderNumber(dto,now)) .build(); } private boolean random() {