fix(channel-donation): 후원 조회 월 경계를 UTC 전달 기준으로 보정한다
This commit is contained in:
@@ -63,13 +63,23 @@ class ChannelDonationService(
|
||||
memberRepository.findCreatorByIdOrNull(creatorId)
|
||||
?: throw SodaException(messageKey = "member.validation.creator_not_found")
|
||||
|
||||
val utcZoneId = ZoneId.of("UTC")
|
||||
val kstZoneId = ZoneId.of("Asia/Seoul")
|
||||
val nowKst = ZonedDateTime.now(kstZoneId)
|
||||
val startDateTime = nowKst
|
||||
val nowUtc = ZonedDateTime.now(utcZoneId)
|
||||
val nowKst = nowUtc.withZoneSameInstant(kstZoneId)
|
||||
|
||||
val startDateTimeKst = nowKst
|
||||
.with(TemporalAdjusters.firstDayOfMonth())
|
||||
.toLocalDate()
|
||||
.atStartOfDay()
|
||||
val endDateTime = startDateTime.plusMonths(1)
|
||||
.atStartOfDay(kstZoneId)
|
||||
val endDateTimeKst = startDateTimeKst.plusMonths(1)
|
||||
|
||||
val startDateTime = startDateTimeKst
|
||||
.withZoneSameInstant(utcZoneId)
|
||||
.toLocalDateTime()
|
||||
val endDateTime = endDateTimeKst
|
||||
.withZoneSameInstant(utcZoneId)
|
||||
.toLocalDateTime()
|
||||
val isCreator = member.role == MemberRole.CREATOR && creatorId == member.id
|
||||
|
||||
val totalCount = channelDonationMessageRepository.getChannelDonationMessageTotalCount(
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import java.time.LocalDateTime
|
||||
import java.time.LocalTime
|
||||
import java.time.ZoneId
|
||||
|
||||
class ChannelDonationServiceTest {
|
||||
private lateinit var canPaymentService: CanPaymentService
|
||||
@@ -132,9 +133,20 @@ class ChannelDonationServiceTest {
|
||||
)
|
||||
|
||||
// then: 월 시작/다음 달 시작 범위를 사용해야 한다.
|
||||
assertEquals(1, capturedStartDateTime!!.dayOfMonth)
|
||||
assertEquals(LocalTime.MIDNIGHT, capturedStartDateTime!!.toLocalTime())
|
||||
assertEquals(capturedStartDateTime!!.plusMonths(1), capturedEndDateTime)
|
||||
val utcZoneId = ZoneId.of("UTC")
|
||||
val kstZoneId = ZoneId.of("Asia/Seoul")
|
||||
val startDateTimeKst = capturedStartDateTime!!
|
||||
.atZone(utcZoneId)
|
||||
.withZoneSameInstant(kstZoneId)
|
||||
.toLocalDateTime()
|
||||
val endDateTimeKst = capturedEndDateTime!!
|
||||
.atZone(utcZoneId)
|
||||
.withZoneSameInstant(kstZoneId)
|
||||
.toLocalDateTime()
|
||||
|
||||
assertEquals(1, startDateTimeKst.dayOfMonth)
|
||||
assertEquals(LocalTime.MIDNIGHT, startDateTimeKst.toLocalTime())
|
||||
assertEquals(startDateTimeKst.plusMonths(1), endDateTimeKst)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -246,9 +258,20 @@ class ChannelDonationServiceTest {
|
||||
)
|
||||
|
||||
// then: 월 시작/다음 달 시작 범위를 사용해야 한다.
|
||||
assertEquals(1, capturedStartDateTime!!.dayOfMonth)
|
||||
assertEquals(LocalTime.MIDNIGHT, capturedStartDateTime!!.toLocalTime())
|
||||
assertEquals(capturedStartDateTime!!.plusMonths(1), capturedEndDateTime)
|
||||
val utcZoneId = ZoneId.of("UTC")
|
||||
val kstZoneId = ZoneId.of("Asia/Seoul")
|
||||
val startDateTimeKst = capturedStartDateTime!!
|
||||
.atZone(utcZoneId)
|
||||
.withZoneSameInstant(kstZoneId)
|
||||
.toLocalDateTime()
|
||||
val endDateTimeKst = capturedEndDateTime!!
|
||||
.atZone(utcZoneId)
|
||||
.withZoneSameInstant(kstZoneId)
|
||||
.toLocalDateTime()
|
||||
|
||||
assertEquals(1, startDateTimeKst.dayOfMonth)
|
||||
assertEquals(LocalTime.MIDNIGHT, startDateTimeKst.toLocalTime())
|
||||
assertEquals(startDateTimeKst.plusMonths(1), endDateTimeKst)
|
||||
}
|
||||
|
||||
private fun createMember(id: Long, role: MemberRole, nickname: String): Member {
|
||||
|
||||
Reference in New Issue
Block a user