From fda0dda3f918113b05be0bd5da7620f7f724adf4 Mon Sep 17 00:00:00 2001 From: HyemIin Date: Sat, 27 Jan 2024 15:57:42 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20:=20=EC=B2=B4=ED=81=AC=EC=9D=B8=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=EA=B0=80=20=EC=A7=80=EB=82=9C=20=EA=B2=BD=EC=9A=B0=20?= =?UTF-8?q?UNABLESELL=20enum=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SaleSchedulerService 업데이트 --- .../domain/product/service/SaleSchedulerService.java | 11 +++++++++++ .../catchroom_be/domain/product/type/DealState.java | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) 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 }