Skip to content

Commit

Permalink
Api-v0.1.7-1
Browse files Browse the repository at this point in the history
Api-v0.1.7-1
  • Loading branch information
ImNM authored Feb 22, 2023
2 parents 4a36a68 + c53f97e commit d6014e8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;
Expand Down Expand Up @@ -40,7 +39,7 @@ public class CreateTicketItemRequest {
@Schema(nullable = true, example = "김원진")
private String accountHolder;

@Positive
@NotNull
@Schema(defaultValue = "0", nullable = false, example = "4000")
private Long price;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public boolean isLessThan(Money other) {
return amount.compareTo(other.amount) < 0;
}

public boolean isLessThanOrEqual(Money other) {
return amount.compareTo(other.amount) <= 0;
}

public boolean isGreaterThanOrEqual(Money other) {
return amount.compareTo(other.amount) >= 0;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package band.gosrock.domain.domains.ticket_item.domain;

import static band.gosrock.common.consts.DuDoongStatic.MINIMUM_PAYMENT_WON;

import band.gosrock.domain.common.model.BaseTimeEntity;
import band.gosrock.domain.common.vo.AccountInfoVo;
Expand Down Expand Up @@ -168,31 +169,35 @@ public void validateEventId(Long eventId) {

public void validateTicketPayType(Boolean isPartner) {
// 두둥티켓은 무조건 승인 + 계좌정보 필요
if (this.payType.equals(TicketPayType.DUDOONG_TICKET)) {
if (!this.type.equals(TicketType.APPROVAL)) {
if (payType == TicketPayType.DUDOONG_TICKET) {
if (type != TicketType.APPROVAL) {
throw InvalidTicketTypeException.EXCEPTION;
}
if (StringUtils.isEmpty(this.accountInfo.getBankName())
|| StringUtils.isEmpty(this.accountInfo.getAccountNumber())
|| StringUtils.isEmpty(this.accountInfo.getAccountHolder())) {
// 두둥 티켓은 유로 티켓 이어야함.
if (price.isLessThanOrEqual(Money.ZERO)) {
throw InvalidTicketPriceException.EXCEPTION;
}
if (!StringUtils.hasText(accountInfo.getBankName())
|| !StringUtils.hasText(accountInfo.getAccountNumber())
|| !StringUtils.hasText(accountInfo.getAccountHolder())) {
throw EmptyAccountInfoException.EXCEPTION;
}
}
// 유료티켓은 무조건 선착순 + 제휴 확인 + 1000원 이상
else if (this.payType.equals(TicketPayType.PRICE_TICKET)) {
if (!this.type.equals(TicketType.FIRST_COME_FIRST_SERVED)) {
else if (payType == TicketPayType.PRICE_TICKET) {
if (type != TicketType.FIRST_COME_FIRST_SERVED) {
throw InvalidTicketTypeException.EXCEPTION;
}
if (!isPartner) {
throw InvalidPartnerException.EXCEPTION;
}
if (this.price.isLessThan(Money.wons(1000))) {
if (price.isLessThan(Money.wons(MINIMUM_PAYMENT_WON))) {
throw InvalidTicketPriceException.EXCEPTION;
}
}
// 무료티켓은 무조건 0원
else {
if (!this.price.equals(Money.ZERO)) {
if (!price.equals(Money.ZERO)) {
throw InvalidTicketPriceException.EXCEPTION;
}
}
Expand Down

0 comments on commit d6014e8

Please sign in to comment.