diff --git a/DuDoong-Api/src/main/java/band/gosrock/api/ticketItem/dto/request/CreateTicketItemRequest.java b/DuDoong-Api/src/main/java/band/gosrock/api/ticketItem/dto/request/CreateTicketItemRequest.java index fb1092f1..6c736562 100644 --- a/DuDoong-Api/src/main/java/band/gosrock/api/ticketItem/dto/request/CreateTicketItemRequest.java +++ b/DuDoong-Api/src/main/java/band/gosrock/api/ticketItem/dto/request/CreateTicketItemRequest.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Positive; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.springframework.lang.Nullable; @@ -43,7 +44,7 @@ public class CreateTicketItemRequest { @Schema(defaultValue = "0", nullable = false, example = "4000") private Long price; - @NotNull + @Positive @Schema(nullable = false, example = "100") private Long supplyCount; diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/domain/TicketItem.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/domain/TicketItem.java index 026d82c7..cf746a50 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/domain/TicketItem.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/domain/TicketItem.java @@ -103,7 +103,10 @@ public TicketItem( this.supplyCount = supplyCount; this.purchaseLimit = purchaseLimit; this.type = type; - this.accountInfo = AccountInfoVo.valueOf(bankName, accountNumber, accountHolder); + this.accountInfo = + payType.equals(TicketPayType.DUDOONG_TICKET) + ? AccountInfoVo.valueOf(bankName, accountNumber, accountHolder) + : null; this.isQuantityPublic = isQuantityPublic; this.isSellable = isSellable; this.saleStartAt = saleStartAt; @@ -117,6 +120,14 @@ public void addItemOptionGroup(OptionGroup optionGroup) { throw ForbiddenOptionChangeException.EXCEPTION; } + // 무료티켓에 유료 옵션 적용 불가 + if (this.payType.equals(TicketPayType.FREE_TICKET) + && optionGroup.getOptions().stream() + .anyMatch( + option -> option.getAdditionalPrice().isGreaterThan(Money.ZERO))) { + throw ForbiddenOptionPriceException.EXCEPTION; + } + // 중복 체크 if (this.hasItemOptionGroup(optionGroup.getId())) { throw DuplicatedItemOptionGroupException.EXCEPTION; diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/ForbiddenOptionPriceException.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/ForbiddenOptionPriceException.java new file mode 100644 index 00000000..2e747b02 --- /dev/null +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/ForbiddenOptionPriceException.java @@ -0,0 +1,13 @@ +package band.gosrock.domain.domains.ticket_item.exception; + + +import band.gosrock.common.exception.DuDoongCodeException; + +public class ForbiddenOptionPriceException extends DuDoongCodeException { + + public static final DuDoongCodeException EXCEPTION = new ForbiddenOptionPriceException(); + + private ForbiddenOptionPriceException() { + super(TicketItemErrorCode.FORBIDDEN_OPTION_PRICE); + } +} diff --git a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/TicketItemErrorCode.java b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/TicketItemErrorCode.java index 1ca340f7..38fd01c1 100644 --- a/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/TicketItemErrorCode.java +++ b/DuDoong-Domain/src/main/java/band/gosrock/domain/domains/ticket_item/exception/TicketItemErrorCode.java @@ -51,7 +51,9 @@ public enum TicketItemErrorCode implements BaseErrorCode { @ExplainError("제휴되지 않은 호스트가 유료티켓 생성을 요청했을때 발생하는 오류입니다.") INVALID_PARTNER(BAD_REQUEST, "Ticket_Item_400_3", "제휴된 호스트가 아닙니다."), @ExplainError("해당 티켓상품에 적용되지 않은 옵션을 취소 시도할 경우 발생하는 오류입니다.") - NOT_APPLIED_ITEM_OPTION_GROUP(BAD_REQUEST, "Item_Option_Group_400_3", "적용되지 않은 옵션입니다."); + NOT_APPLIED_ITEM_OPTION_GROUP(BAD_REQUEST, "Item_Option_Group_400_3", "적용되지 않은 옵션입니다."), + @ExplainError("무료 티켓에 유료 옵션을 적용하려고 했을 때 발생하는 오류입니다.") + FORBIDDEN_OPTION_PRICE(BAD_REQUEST, "Item_Option_Group_400_4", "유료 옵션을 적용할 수 없습니다."); private Integer status; private String code;