File tree Expand file tree Collapse file tree
src/main/java/com/project/submate/subscribe/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -55,9 +55,17 @@ public SubscribeListResponseDto subscribeAllList() {
5555 // 디데이 계산(******Asia/Seoul 시간으로 나오지 않아서 임의로 결과에 -1을 해주었다)
5656 private int calculateDday (LocalDate startDate ) {
5757// LocalDate.plusMonths: 자동으로 월의 마지막 날짜를 고려하여 계산한다.
58- LocalDate baseDate = startDate .plusMonths (1 ); // 기준일: startDate + 1달
58+ // LocalDate baseDate = startDate.plusMonths(1); // 기준일: startDate + 1달
5959 LocalDate now = LocalDate .now (ZoneId .of ("Asia/Seoul" ));
60- int dDay = (int ) ChronoUnit .DAYS .between (now , baseDate );
60+
61+ // 반복 결제일: 매달 startDate의 day에 결제된다고 가정한다.
62+ LocalDate nextBillingDate = startDate ;
63+
64+ // 현재 날짜 이후의 가장 가까운 결제일을 찾는다.
65+ while (!nextBillingDate .isAfter (now )) {
66+ nextBillingDate = nextBillingDate .plusMonths (1 );
67+ }
68+ int dDay = (int ) ChronoUnit .DAYS .between (now , nextBillingDate );
6169 return Math .max (dDay , 0 ); // 음수 방지
6270 }
6371
You can’t perform that action at this time.
0 commit comments