From 5dc9abdd31fd31cc2a913e8bd1753dd1562639a2 Mon Sep 17 00:00:00 2001 From: Chan Jin Date: Thu, 16 Mar 2023 19:56:19 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=20event=20=EA=B4=80=EB=A6=AC?= =?UTF-8?q?=EC=9E=90=20=EC=A3=BC=EB=AC=B8=20=EC=B2=A0=ED=9A=8C=20=EA=B6=8C?= =?UTF-8?q?=ED=95=9C=20=EC=98=AC=EB=B0=94=EB=A5=B4=EA=B2=8C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20(#545)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor : 결제 관리자 취소 admin 으로 이동 * refactor : 결제 관리자 취소 권한 설정 --- .../api/order/controller/OrderAdminController.java | 11 +++++++++++ .../gosrock/api/order/controller/OrderController.java | 10 ---------- .../gosrock/api/order/service/CancelOrderUseCase.java | 10 ++++++---- .../domains/order/service/WithdrawOrderService.java | 4 +--- .../order/service/WithdrawOrderServiceTest.java | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderAdminController.java b/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderAdminController.java index 232db197..5aa59054 100644 --- a/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderAdminController.java +++ b/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderAdminController.java @@ -3,10 +3,12 @@ import band.gosrock.api.common.page.PageResponse; import band.gosrock.api.order.docs.ApproveOrderExceptionDocs; +import band.gosrock.api.order.docs.CancelOrderExceptionDocs; import band.gosrock.api.order.model.dto.request.AdminOrderTableQueryRequest; import band.gosrock.api.order.model.dto.response.OrderAdminTableElement; import band.gosrock.api.order.model.dto.response.OrderResponse; import band.gosrock.api.order.service.ApproveOrderUseCase; +import band.gosrock.api.order.service.CancelOrderUseCase; import band.gosrock.api.order.service.ReadOrderUseCase; import band.gosrock.common.annotation.ApiErrorExceptionsExample; import io.swagger.v3.oas.annotations.Operation; @@ -31,6 +33,7 @@ public class OrderAdminController { private final ApproveOrderUseCase approveOrderUseCase; private final ReadOrderUseCase readOrderUseCase; + private final CancelOrderUseCase cancelOrderUseCase; @Operation(summary = "어드민 목록 내 테이블 조회 OrderStage 는 꼭 보내주삼!") @GetMapping @@ -41,6 +44,14 @@ public PageResponse getEventOrders( return readOrderUseCase.getEventOrders(eventId, adminOrderTableQueryRequest, pageable); } + @Operation(summary = "결제 취소요청. 호스트 관리자가 결제를 취소 시킵니다.! (호스트 관리자용(관리자쪽에서 사용))") + @ApiErrorExceptionsExample(CancelOrderExceptionDocs.class) + @PostMapping("/{order_uuid}/cancel") + public OrderResponse cancelOrder( + @PathVariable("eventId") Long eventId, @PathVariable("order_uuid") String orderUuid) { + return cancelOrderUseCase.execute(eventId, orderUuid); + } + @Operation(summary = "주문 승인하기 . 호스트 관리자가 티켓 주문을 승인합니다. ( 어드민 이벤트쪽으로 이동예정 )") @ApiErrorExceptionsExample(ApproveOrderExceptionDocs.class) @PostMapping("/{order_uuid}/approve") diff --git a/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderController.java b/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderController.java index f2cdbaec..251743ad 100644 --- a/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderController.java +++ b/DuDoong-Api/src/main/java/band/gosrock/api/order/controller/OrderController.java @@ -2,7 +2,6 @@ import band.gosrock.api.common.slice.SliceResponse; -import band.gosrock.api.order.docs.CancelOrderExceptionDocs; import band.gosrock.api.order.docs.ConfirmOrderExceptionDocs; import band.gosrock.api.order.docs.CreateOrderExceptionDocs; import band.gosrock.api.order.docs.FreeOrderExceptionDocs; @@ -13,7 +12,6 @@ import band.gosrock.api.order.model.dto.response.OrderBriefElement; import band.gosrock.api.order.model.dto.response.OrderResponse; import band.gosrock.api.order.model.dto.response.OrderTicketResponse; -import band.gosrock.api.order.service.CancelOrderUseCase; import band.gosrock.api.order.service.ConfirmOrderUseCase; import band.gosrock.api.order.service.CreateOrderUseCase; import band.gosrock.api.order.service.CreateTossOrderUseCase; @@ -49,7 +47,6 @@ public class OrderController { private final CreateOrderUseCase createOrderUseCase; private final ConfirmOrderUseCase confirmOrderUseCase; private final FreeOrderUseCase freeOrderUseCase; - private final CancelOrderUseCase cancelOrderUseCase; private final RefundOrderUseCase refundOrderUseCase; private final ReadOrderUseCase readOrderUseCase; @@ -87,13 +84,6 @@ public OrderResponse freeOrder(@PathVariable("order_uuid") String orderUuid) { return freeOrderUseCase.execute(orderUuid); } - @Operation(summary = "결제 취소요청. 호스트 관리자가 결제를 취소 시킵니다.! (호스트 관리자용(관리자쪽에서 사용))") - @ApiErrorExceptionsExample(CancelOrderExceptionDocs.class) - @PostMapping("/{order_uuid}/cancel") - public OrderResponse cancelOrder(@PathVariable("order_uuid") String orderUuid) { - return cancelOrderUseCase.execute(orderUuid); - } - @Operation(summary = "결제 환불요청. 본인이 구매한 오더를 환불 시킵니다.! (본인 용)") @ApiErrorExceptionsExample(RefundOrderExceptionDocs.class) @PostMapping("/{order_uuid}/refund") diff --git a/DuDoong-Api/src/main/java/band/gosrock/api/order/service/CancelOrderUseCase.java b/DuDoong-Api/src/main/java/band/gosrock/api/order/service/CancelOrderUseCase.java index eaa0bd77..2cd43e61 100644 --- a/DuDoong-Api/src/main/java/band/gosrock/api/order/service/CancelOrderUseCase.java +++ b/DuDoong-Api/src/main/java/band/gosrock/api/order/service/CancelOrderUseCase.java @@ -1,7 +1,9 @@ package band.gosrock.api.order.service; +import static band.gosrock.api.common.aop.hostRole.FindHostFrom.EVENT_ID; +import static band.gosrock.api.common.aop.hostRole.HostQualification.MANAGER; -import band.gosrock.api.config.security.SecurityUtils; +import band.gosrock.api.common.aop.hostRole.HostRolesAllowed; import band.gosrock.api.order.model.dto.response.OrderResponse; import band.gosrock.api.order.model.mapper.OrderMapper; import band.gosrock.common.annotation.UseCase; @@ -16,9 +18,9 @@ public class CancelOrderUseCase { private final OrderMapper orderMapper; - public OrderResponse execute(String orderUuid) { - Long currentUserId = SecurityUtils.getCurrentUserId(); - withdrawOrderService.cancelOrder(orderUuid, currentUserId); + @HostRolesAllowed(role = MANAGER, findHostFrom = EVENT_ID, applyTransaction = false) + public OrderResponse execute(Long eventId, String orderUuid) { + withdrawOrderService.cancelOrder(orderUuid); return orderMapper.toOrderResponse(orderUuid); } } diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/service/WithdrawOrderService.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/service/WithdrawOrderService.java index 8b1b1c23..c7aac782 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/service/WithdrawOrderService.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/order/service/WithdrawOrderService.java @@ -21,10 +21,8 @@ public class WithdrawOrderService { private final OrderValidator orderValidator; @RedissonLock(LockName = "주문", identifier = "orderUuid") - public String cancelOrder(String orderUuid, Long userId) { + public String cancelOrder(String orderUuid) { Order order = orderAdaptor.findByOrderUuid(orderUuid); - // TODO : 관리자 권환으로 치환. - orderValidator.validOwner(order, userId); order.cancel(orderValidator); return orderUuid; } diff --git a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/WithdrawOrderServiceTest.java b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/WithdrawOrderServiceTest.java index da7cef9a..eb118ce6 100644 --- a/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/WithdrawOrderServiceTest.java +++ b/DuDoong-Domain/src/test/java/band/gosrock/domain/domains/order/service/WithdrawOrderServiceTest.java @@ -57,7 +57,7 @@ void setUp() { AtomicLong successCount = new AtomicLong(); // when CunCurrencyExecutorService.execute( - () -> withdrawOrderService.cancelOrder(order.getUuid(), userId), successCount); + () -> withdrawOrderService.cancelOrder(order.getUuid()), successCount); assertThat(successCount.get()).isGreaterThanOrEqualTo(1); }