From 010a159c39931fa82f15380e85c1592edc2225d6 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 10 Mar 2024 23:49:29 +0900 Subject: [PATCH 1/3] =?UTF-8?q?RAC-322=20fix=20:=20=EB=8B=A8=EC=9C=84?= =?UTF-8?q?=EB=A5=BC=20=EB=8B=AC=EC=97=90=EC=84=9C=20=EC=A3=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A8=EC=97=90=20=EB=94=B0=EB=9D=BC=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/salary/domain/service/SalaryGetService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java index 9eea5e32..23fbecba 100644 --- a/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java +++ b/src/main/java/com/postgraduate/domain/salary/domain/service/SalaryGetService.java @@ -33,10 +33,10 @@ public Page findDistinctSeniors(String search, Integer page) { return salaryRepository.findDistinctBySearchSenior(search, pageable); } - public List findAllLastMonth() { + public List findAllLast() { LocalDate salaryDate = SalaryUtil.getSalaryDate() - .minusMonths(1); + .minusDays(7); return salaryRepository.findAllLastSalary(salaryDate); } } From 0018185a597df1adabcb0c67b61474b23fa3f378 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 10 Mar 2024 23:49:42 +0900 Subject: [PATCH 2/3] =?UTF-8?q?RAC-322=20fix=20:=20=EC=A0=95=EC=82=B0?= =?UTF-8?q?=EC=9D=BC=20=EA=B3=84=EC=82=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/salary/util/SalaryUtil.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java index 5f3225f0..9fdce60b 100644 --- a/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java +++ b/src/main/java/com/postgraduate/domain/salary/util/SalaryUtil.java @@ -3,13 +3,14 @@ import com.postgraduate.domain.admin.presentation.constant.SalaryStatus; import com.postgraduate.domain.salary.domain.entity.Salary; +import java.time.DayOfWeek; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import static com.postgraduate.domain.admin.presentation.constant.SalaryStatus.*; public class SalaryUtil { - private static final int SALARY_DATE = 10; + private static final int SALARY_DATE = 4; // 목요일 + private static final int SALARY_END_DATE = 7; // 일요일 private SalaryUtil() { throw new IllegalArgumentException(); @@ -17,13 +18,10 @@ private SalaryUtil() { public static LocalDate getSalaryDate() { LocalDate now = LocalDate.now(); - return now.getDayOfMonth() < SALARY_DATE - ? now.withDayOfMonth(SALARY_DATE) - : now.plusMonths(1).withDayOfMonth(SALARY_DATE); - } - - public static DateTimeFormatter getMonthFormat() { - return DateTimeFormatter.ofPattern("yyyy-MM"); + DayOfWeek dayOfWeek = now.getDayOfWeek(); + return dayOfWeek.getValue() < SALARY_END_DATE + ? now.plusDays(7 + (dayOfWeek.getValue() - SALARY_DATE)) + : now.plusDays(dayOfWeek.getValue() - SALARY_DATE); } public static SalaryStatus getStatus(Salary salary) { From a652d48592d4466e42736ae32c57dd1509814482 Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 10 Mar 2024 23:50:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?RAC-322=20fix=20:=20=EC=83=88=EB=A1=9C?= =?UTF-8?q?=EC=9A=B4=20=EC=A0=95=EC=82=B0=20=EC=83=9D=EC=84=B1=20=EC=A3=BC?= =?UTF-8?q?=EB=8B=A8=EC=9C=84=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../salary/application/usecase/SalaryManageUseCase.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryManageUseCase.java b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryManageUseCase.java index 2855e4f8..2c00e40a 100644 --- a/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/salary/application/usecase/SalaryManageUseCase.java @@ -5,7 +5,6 @@ import com.postgraduate.domain.salary.domain.entity.Salary; import com.postgraduate.domain.salary.domain.service.SalaryGetService; import com.postgraduate.domain.salary.domain.service.SalarySaveService; -import com.postgraduate.domain.salary.util.SalaryUtil; import com.postgraduate.domain.senior.domain.service.SeniorGetService; import com.postgraduate.global.slack.SlackSalaryMessage; import lombok.RequiredArgsConstructor; @@ -25,13 +24,13 @@ public class SalaryManageUseCase { private final SeniorGetService seniorGetService; private final SlackSalaryMessage slackSalaryMessage; - @Scheduled(cron = "0 0 0 10 * *", zone = "Asia/Seoul") + @Scheduled(cron = "0 0 0 * * 4", zone = "Asia/Seoul") public void createSalary() { - List salaries = salaryGetService.findAllLastMonth(); + List salaries = salaryGetService.findAllLast(); slackSalaryMessage.sendSlackSalary(salaries); List seniorAndAccounts = seniorGetService.findAllSeniorAndAccount(); - LocalDate salaryDate = SalaryUtil.getSalaryDate(); + LocalDate salaryDate = LocalDate.now().plusDays(7); seniorAndAccounts.forEach(seniorAndAccount -> { Salary salary = SalaryMapper.mapToSalary(seniorAndAccount.senior(), salaryDate, seniorAndAccount.account()); salarySaveService.save(salary);