diff --git a/src/main/java/com/example/repick/domain/clothingSales/dto/GetSellingClothingSales.java b/src/main/java/com/example/repick/domain/clothingSales/dto/GetSellingClothingSales.java index c5ce6293..85098c88 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/dto/GetSellingClothingSales.java +++ b/src/main/java/com/example/repick/domain/clothingSales/dto/GetSellingClothingSales.java @@ -10,20 +10,22 @@ public record GetSellingClothingSales( @Schema(description = "판매 진행 시작일", example = "2024.01.01") String salesStartDate, @Schema(description = "남은 판매 일수", example= "90") Integer remainingSalesDays, @Schema(description = "판매 중인 의류 수량", example = "43") Integer sellingQuantity, - @Schema(description = "구매 확정 대기 수량", example = "7") Integer pendingQuantity, - @Schema(description = "구매 확정 완료 수량", example = "36") Integer soldQuantity, + @Schema(description = "구매 확정 대기 수량", example = "7") Integer confirmPendingQuantity, + @Schema(description = "판매 완료 수량", example = "36") Integer soldQuantity, + @Schema(description = "기간 만료 수량", example = "0") Integer expiredQuantity, @Schema(description = "총 포인트", example = "2300") Long totalPoint ) { - public static GetSellingClothingSales of(ClothingSales clothingSales, String salesStartDate, int remainingSalesDays, int sellingQuantity, int pendingQuantity, int soldQuantity) { + public static GetSellingClothingSales of(ClothingSales clothingSales, String salesStartDate, int remainingSalesDays, int sellingQuantity, int confirmPendingQuantity, int soldQuantity, int expiredQuantity, long totalPoint) { return new GetSellingClothingSales( clothingSales.getId(), clothingSales.getClothingSalesCount(), salesStartDate, remainingSalesDays, sellingQuantity, - pendingQuantity, + confirmPendingQuantity, soldQuantity, - clothingSales.getPoint()); + expiredQuantity, + totalPoint); } } diff --git a/src/main/java/com/example/repick/domain/clothingSales/dto/PostBagInit.java b/src/main/java/com/example/repick/domain/clothingSales/dto/PostBagInit.java index fe30f964..5085e77a 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/dto/PostBagInit.java +++ b/src/main/java/com/example/repick/domain/clothingSales/dto/PostBagInit.java @@ -20,7 +20,6 @@ public BagCollect toEntity(User user, Integer clothingSalesCount) { .bagQuantity(bagQuantity) .initAddress(new Address(postalCode, mainAddress, detailAddress)) .clothingSalesCount(clothingSalesCount) - .point(0L) .clothingSalesState(ClothingSalesStateType.BAG_INIT_REQUEST) .build(); } diff --git a/src/main/java/com/example/repick/domain/clothingSales/dto/PostBoxCollect.java b/src/main/java/com/example/repick/domain/clothingSales/dto/PostBoxCollect.java index 98e3036f..5dbcd0e5 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/dto/PostBoxCollect.java +++ b/src/main/java/com/example/repick/domain/clothingSales/dto/PostBoxCollect.java @@ -25,7 +25,6 @@ public BoxCollect toEntity(User user, Integer clothingSalesCount) { .address(new Address(postalCode, mainAddress, detailAddress)) .collectionDate(LocalDate.parse(collectionDate)) .clothingSalesCount(clothingSalesCount) - .point(0L) .clothingSalesState(ClothingSalesStateType.BOX_COLLECT_REQUEST) .build(); } diff --git a/src/main/java/com/example/repick/domain/clothingSales/entity/BagCollect.java b/src/main/java/com/example/repick/domain/clothingSales/entity/BagCollect.java index a18a5000..22892ee1 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/entity/BagCollect.java +++ b/src/main/java/com/example/repick/domain/clothingSales/entity/BagCollect.java @@ -17,7 +17,7 @@ public class BagCollect extends ClothingSales{ private Integer bagQuantity; @Column(name = "notify_count") - private int notifyCount = 0; + private int notifyCount; public void updateNotifyCount(int notifyCount) { this.notifyCount = notifyCount; diff --git a/src/main/java/com/example/repick/domain/clothingSales/entity/ClothingSales.java b/src/main/java/com/example/repick/domain/clothingSales/entity/ClothingSales.java index 603f9463..75b362e8 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/entity/ClothingSales.java +++ b/src/main/java/com/example/repick/domain/clothingSales/entity/ClothingSales.java @@ -43,9 +43,6 @@ public abstract class ClothingSales { @Column(name = "clothing_sales_count") private Integer clothingSalesCount; - @Column(name = "point") - private Long point; - @Column(name = "weight") private Double weight; @@ -81,9 +78,6 @@ public void updateImageUrl(String imageUrl) { this.imageUrl = imageUrl; } - public void updatePoint(long point) { - this.point = point; - } public void updateWeight(double weight) { this.weight = weight; } diff --git a/src/main/java/com/example/repick/domain/clothingSales/service/ClothingSalesService.java b/src/main/java/com/example/repick/domain/clothingSales/service/ClothingSalesService.java index f72d1dd3..3495f8d7 100644 --- a/src/main/java/com/example/repick/domain/clothingSales/service/ClothingSalesService.java +++ b/src/main/java/com/example/repick/domain/clothingSales/service/ClothingSalesService.java @@ -138,13 +138,15 @@ public GetSellingClothingSales getSellingClothingSales(Long clothingSalesId) { private GetSellingClothingSales getSellingClothingSalesInfo(ClothingSales clothingSales) { List productList = clothingSales.getProductList(); if(productList.isEmpty()) { - return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), 0, 0, 0, 0); + return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), 0, 0, 0, 0, 0, 0); } int remainingSalesDays = (int) ChronoUnit.DAYS.between(LocalDate.now(), clothingSales.getSalesStartDate().toLocalDate().plusDays(90)); int sellingQuantity = 0; - int pendingQuantity = 0; + int confirmPendingQuantity = 0; int soldQuantity = 0; + int expiredQuantity = 0; + long totalPoint = 0; for (Product product : productList) { if (product.getProductState().equals(ProductStateType.SELLING)) { @@ -154,12 +156,15 @@ private GetSellingClothingSales getSellingClothingSalesInfo(ClothingSales clothi .orElseThrow(() -> new CustomException(INVALID_PRODUCT_ID)); if (productOrder.isConfirmed()) { soldQuantity++; + totalPoint += product.getSettlement(); } else { - pendingQuantity++; + confirmPendingQuantity++; } + } else if (product.getProductState().equals(ProductStateType.SELLING_END)) { + expiredQuantity++; } } - return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), remainingSalesDays, sellingQuantity, pendingQuantity, soldQuantity); + return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), remainingSalesDays, sellingQuantity, confirmPendingQuantity, soldQuantity, expiredQuantity, totalPoint); } diff --git a/src/main/java/com/example/repick/domain/product/scheduler/ProductScheduler.java b/src/main/java/com/example/repick/domain/product/scheduler/ProductScheduler.java index 8946e863..85a092c2 100644 --- a/src/main/java/com/example/repick/domain/product/scheduler/ProductScheduler.java +++ b/src/main/java/com/example/repick/domain/product/scheduler/ProductScheduler.java @@ -46,9 +46,9 @@ public void updateProductDiscountRate() { } private void handleExpiredSales(ClothingSales clothingSales) { - clothingSales.getProductList().forEach(p -> { - productService.changeSellingState(p, ProductStateType.SELLING_END); - }); + clothingSales.getProductList().stream() + .filter(p -> p.getProductState() == ProductStateType.SELLING) + .forEach(p -> productService.changeSellingState(p, ProductStateType.SELLING_END)); ClothingSalesState clothingSalesState = ClothingSalesState.of(clothingSales.getId(), ClothingSalesStateType.SELLING_EXPIRED); clothingSales.updateClothingSalesState(ClothingSalesStateType.SELLING_EXPIRED); clothingSalesStateRepository.save(clothingSalesState);