From dc6a58530db6a102da157916119958dbb312adc5 Mon Sep 17 00:00:00 2001 From: psyeon1120 Date: Wed, 20 Sep 2023 15:31:24 +0900 Subject: [PATCH] =?UTF-8?q?#180=20fix:=20=EA=B5=AC=EB=A7=A4=EC=9E=90?= =?UTF-8?q?=EB=8F=84=20=EC=9A=94=EC=B2=AD=EC=B7=A8=EC=86=8C=20=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=ED=95=98=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/psr/psr/order/service/OrderService.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/psr/psr/order/service/OrderService.kt b/src/main/kotlin/com/psr/psr/order/service/OrderService.kt index 2474925..a238e9e 100644 --- a/src/main/kotlin/com/psr/psr/order/service/OrderService.kt +++ b/src/main/kotlin/com/psr/psr/order/service/OrderService.kt @@ -79,14 +79,19 @@ class OrderService( orderRepository.save(order) } - // 요청 상태 수정(판매자만 수정 가능) + // 요청 상태 수정(요청취소 외에는 판매자만 수정 가능) fun editOrderStatus(user: User, status: String, orderId: Long) { val order: Order = orderRepository.findByIdAndStatus(orderId, ACTIVE_STATUS) ?: throw BaseException(BaseResponseCode.NOT_FOUND_ORDER) - if (order.product.user.id != user.id) throw BaseException(BaseResponseCode.NO_PERMISSION) val orderStatus = OrderStatus.findByValue(status) + // 요청대기 상태일 때 구매자나 판매자가 아닌경우 + if (orderStatus == OrderStatus.ORDER_WAITING) + if (order.product.user.id != user.id || order.user.id != user.id) throw BaseException(BaseResponseCode.NO_PERMISSION) + // 요청대기 상태가 아닐 때 판매자가 아닌경우 + else if (order.product.user.id != user.id) throw BaseException(BaseResponseCode.NO_PERMISSION) + order.editOrderStatus(orderStatus) val saveOrder = orderRepository.save(order)