diff --git a/src/main/java/com/example/catchroom_be/domain/product/service/SaleSchedulerService.java b/src/main/java/com/example/catchroom_be/domain/product/service/SaleSchedulerService.java index fcd89cd..0c476f1 100644 --- a/src/main/java/com/example/catchroom_be/domain/product/service/SaleSchedulerService.java +++ b/src/main/java/com/example/catchroom_be/domain/product/service/SaleSchedulerService.java @@ -52,4 +52,15 @@ public void applyProductUnsold() { product.updateDealState(DealState.UNSOLD); } } + + @Scheduled(cron = "0 0 0 * * *",zone = "Asia/Seoul") + @Transactional + public void applyUnableSold() { + List productList = productRepository.findAll(); + for (Product product : productList) { + if (product.getOrderHistory().getCheckIn().isBefore(LocalDate.now()) && product.getDealState() != DealState.DONEDEAL) { + product.updateDealState(DealState.UNABLESELL); + } + } + } } diff --git a/src/main/java/com/example/catchroom_be/domain/product/type/DealState.java b/src/main/java/com/example/catchroom_be/domain/product/type/DealState.java index 2077c84..48c0b1f 100644 --- a/src/main/java/com/example/catchroom_be/domain/product/type/DealState.java +++ b/src/main/java/com/example/catchroom_be/domain/product/type/DealState.java @@ -1,5 +1,5 @@ package com.example.catchroom_be.domain.product.type; public enum DealState { - ONSALE,EXPIRED,UNSOLD,DONEDEAL + ONSALE,EXPIRED,UNSOLD,DONEDEAL,UNABLESELL }