diff --git a/src/main/java/site/goldenticket/common/response/ErrorCode.java b/src/main/java/site/goldenticket/common/response/ErrorCode.java index 1f4ab08b..a41f349c 100644 --- a/src/main/java/site/goldenticket/common/response/ErrorCode.java +++ b/src/main/java/site/goldenticket/common/response/ErrorCode.java @@ -42,6 +42,7 @@ public enum ErrorCode { NO_TRANSFER_PENDING_NEGO(BAD_REQUEST, "양도 대기중인 네고가 없습니다."), NO_REGISTERED_ACCOUNT(NOT_FOUND, "등록된 계좌가 없습니다"), TRANSFER_PENDING_NEGO(BAD_REQUEST,"양도 대기 중인 상품이 있어 결제할 수 없습니다."), + CANNOT_NEGOTIATE_SELF_PRODUCT(BAD_REQUEST, "자신의 상품에는 네고를 할 수 없습니다."), // Auth diff --git a/src/main/java/site/goldenticket/domain/nego/service/NegoServiceImpl.java b/src/main/java/site/goldenticket/domain/nego/service/NegoServiceImpl.java index ded4538f..507f44ce 100644 --- a/src/main/java/site/goldenticket/domain/nego/service/NegoServiceImpl.java +++ b/src/main/java/site/goldenticket/domain/nego/service/NegoServiceImpl.java @@ -120,6 +120,11 @@ public PriceProposeResponse proposePrice(Long productId, PriceProposeRequest req .orElseThrow(() -> new NoSuchElementException("Nego not found with id: " + userId)); Product product = productService.getProduct(productId); + Long productUserId = product.getUserId(); + + if(userId.equals(productUserId)){ + throw new CustomException("자신의 상품에는 네고를 할 수 없습니다.", ErrorCode.CANNOT_NEGOTIATE_SELF_PRODUCT); + } List allNegosForProduct = negoRepository.findAllByProduct(product); for (Nego nego : allNegosForProduct) {