diff --git a/src/main/java/com/tookscan/tookscan/order/domain/Document.java b/src/main/java/com/tookscan/tookscan/order/domain/Document.java index 42b9f2c7..7411c45c 100644 --- a/src/main/java/com/tookscan/tookscan/order/domain/Document.java +++ b/src/main/java/com/tookscan/tookscan/order/domain/Document.java @@ -154,5 +154,13 @@ public int getOcrPrice() { return pageCount * additionalPriceForOcr; } + + public int getEstimatedOcrPrice() { + return pageCount * additionalPriceForOcr; + } + + public int getEstimatedOneDayScanPrice() { + return pageCount * order.getAdditionalPriceForOneDayScan(); + } } diff --git a/src/main/java/com/tookscan/tookscan/order/domain/service/DocumentService.java b/src/main/java/com/tookscan/tookscan/order/domain/service/DocumentService.java index 5c3566be..31e453a8 100644 --- a/src/main/java/com/tookscan/tookscan/order/domain/service/DocumentService.java +++ b/src/main/java/com/tookscan/tookscan/order/domain/service/DocumentService.java @@ -58,13 +58,14 @@ public void updateRecoveryOptionPrice(Document document, Integer recoveryOptionP private int calculateRecoveryOptionPrice(int pageCount, ERecoveryOption recoveryOption) { if (recoveryOption == ERecoveryOption.SPRING) { - int basePrice = 3000; // 300페이지까지 기본 3,000원 - if (pageCount <= 300) { + int basePrice = 3000; // 400페이지까지 기본 3,000원 + if (pageCount <= 400) { return basePrice; } - int extraPages = pageCount - 300; - int increments = (int) Math.ceil(extraPages / 100.0); // 100페이지당 1,000원 (올림) - return basePrice + (increments * 1000); + // 이후 300페이지 단위로 3,000원씩 추가 + int extraPages = pageCount - 400; + int increments = (int) Math.ceil(extraPages / 300.0); // 300페이지당 3,000원 (올림) + return basePrice + (increments * 3000); } // 기타 옵션은 고정가(현재 0원) return recoveryOption.getPrice(); diff --git a/src/main/java/com/tookscan/tookscan/order/presentation/dto/response/EstimateUserOrderPriceResponseDto.java b/src/main/java/com/tookscan/tookscan/order/presentation/dto/response/EstimateUserOrderPriceResponseDto.java index 2231e345..ace2df4c 100644 --- a/src/main/java/com/tookscan/tookscan/order/presentation/dto/response/EstimateUserOrderPriceResponseDto.java +++ b/src/main/java/com/tookscan/tookscan/order/presentation/dto/response/EstimateUserOrderPriceResponseDto.java @@ -49,6 +49,12 @@ public class EstimateUserOrderPriceResponseDto extends SelfValidating { @@ -88,6 +94,14 @@ public static class DocumentInfoDto extends SelfValidating { @NotNull private final Integer cuttingPrice; + @JsonProperty("estimated_ocr_price") + @NotNull + private final Integer estimatedOcrPrice; + + @JsonProperty("estimated_one_day_scan_price") + @NotNull + private final Integer estimatedOneDayScanPrice; + @Builder public DocumentInfoDto(String name, Integer pageCount, @@ -97,7 +111,9 @@ public DocumentInfoDto(String name, Integer recoveryPrice, Integer oneDayScanPrice, Integer cuttingPrice, - Integer ocrPrice) { + Integer ocrPrice, + Integer estimatedOcrPrice, + Integer estimatedOneDayScanPrice) { this.name = name; this.pageCount = pageCount; this.pagePrice = pagePrice; @@ -107,6 +123,8 @@ public DocumentInfoDto(String name, this.oneDayScanPrice = oneDayScanPrice; this.ocrPrice = ocrPrice; this.cuttingPrice = cuttingPrice; + this.estimatedOcrPrice = estimatedOcrPrice; + this.estimatedOneDayScanPrice = estimatedOneDayScanPrice; this.validateSelf(); } @@ -121,6 +139,8 @@ public static DocumentInfoDto fromEntity(Document document) { .oneDayScanPrice(document.getOneDayScanPrice()) .ocrPrice(document.getOcrPrice()) .cuttingPrice(document.getCuttingPrice()) + .estimatedOcrPrice(document.getEstimatedOcrPrice()) + .estimatedOneDayScanPrice(document.getEstimatedOneDayScanPrice()) .build(); } } @@ -137,7 +157,9 @@ public EstimateUserOrderPriceResponseDto( Integer couponPrice, Integer couponPercentage, Integer paymentTotal, - Integer ocrPrice + Integer ocrPrice, + Integer estimatedOcrPrice, + Integer estimatedOneDayScanPrice ) { this.documents = documents; this.documentsPrice = documentsPrice; @@ -150,6 +172,8 @@ public EstimateUserOrderPriceResponseDto( this.couponPercentage = couponPercentage; this.paymentTotal = paymentTotal; this.ocrPrice = ocrPrice; + this.estimatedOcrPrice = estimatedOcrPrice; + this.estimatedOneDayScanPrice = estimatedOneDayScanPrice; this.validateSelf(); } @@ -182,6 +206,12 @@ public static EstimateUserOrderPriceResponseDto of(Order order, int recoveryPriceSum = checkedDocs.stream() .mapToInt(DocumentInfoDto::getRecoveryPrice) .sum(); + int estimatedOcrPriceSum = checkedDocs.stream() + .mapToInt(DocumentInfoDto::getEstimatedOcrPrice) + .sum(); + int estimatedOneDayScanPriceSum = checkedDocs.stream() + .mapToInt(DocumentInfoDto::getEstimatedOneDayScanPrice) + .sum(); return EstimateUserOrderPriceResponseDto.builder() .documents(allDocs) @@ -193,6 +223,8 @@ public static EstimateUserOrderPriceResponseDto of(Order order, .deliveryPrice(order.getDelivery().getDeliveryPrice()) .recoveryPrice(recoveryPriceSum) .cuttingPrice(cuttingPriceSum) + .estimatedOcrPrice(estimatedOcrPriceSum) + .estimatedOneDayScanPrice(estimatedOneDayScanPriceSum) .couponPrice(order.getUsedCoupon() != null ? order.getUsedCoupon().getIssuedCoupon().getDiscountPrice(order.getDocumentsTotalAmount(), ocrPriceSum, order.getDelivery().getDeliveryPrice()) : 0) .paymentTotal(order.getTotalAmount()) .build();