feat(creator-calculate): 채널 후원 국가 정책과 월별 합계를 연결한다
This commit is contained in:
+49
-17
@@ -1,5 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.creator.admin.calculate.channelDonation
|
||||
|
||||
import com.querydsl.core.types.dsl.BooleanExpression
|
||||
import com.querydsl.core.types.dsl.DateTimePath
|
||||
import com.querydsl.core.types.dsl.Expressions
|
||||
import com.querydsl.core.types.dsl.StringTemplate
|
||||
@@ -8,28 +9,58 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||
import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
||||
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||
import kr.co.vividnext.sodalive.member.QMember.member
|
||||
import kr.co.vividnext.sodalive.v2.settlement.adapter.out.persistence.CountrySettlementExpressions
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.time.LocalDateTime
|
||||
|
||||
@Repository
|
||||
class CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
private val queryFactory: JPAQueryFactory
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
private val countrySettlementExpressions: CountrySettlementExpressions
|
||||
) {
|
||||
fun getChannelDonationSettlementTotal(
|
||||
startDate: LocalDateTime,
|
||||
endDate: LocalDateTime,
|
||||
memberId: Long
|
||||
): GetCreatorChannelDonationSettlementTotalQueryData {
|
||||
return getChannelDonationSettlementTotal(
|
||||
baseWhereCondition(startDate, memberId).and(useCan.createdAt.loe(endDate))
|
||||
)
|
||||
}
|
||||
|
||||
fun getMonthlyChannelDonationSettlementTotal(
|
||||
startInclusiveUtc: LocalDateTime,
|
||||
endExclusiveUtc: LocalDateTime,
|
||||
memberId: Long
|
||||
): GetCreatorChannelDonationSettlementTotalQueryData {
|
||||
return getChannelDonationSettlementTotal(
|
||||
baseWhereCondition(startInclusiveUtc, memberId).and(useCan.createdAt.lt(endExclusiveUtc))
|
||||
)
|
||||
}
|
||||
|
||||
private fun getChannelDonationSettlementTotal(
|
||||
condition: BooleanExpression
|
||||
): GetCreatorChannelDonationSettlementTotalQueryData {
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetCreatorChannelDonationSettlementTotalQueryData(
|
||||
useCan.id.countDistinct(),
|
||||
useCanCalculate.can.sum()
|
||||
useCanCalculate.can.sum(),
|
||||
countrySettlementExpressions.newPolicyCan(useCan.createdAt, useCanCalculate.can),
|
||||
countrySettlementExpressions.newPolicyWeightedRatioCan(
|
||||
useCan.createdAt,
|
||||
useCanCalculate.can,
|
||||
member.countryCode,
|
||||
useCan.countryCode
|
||||
)
|
||||
)
|
||||
)
|
||||
.from(useCanCalculate)
|
||||
.innerJoin(useCanCalculate.useCan, useCan)
|
||||
.where(baseWhereCondition(startDate, endDate, memberId))
|
||||
.leftJoin(member)
|
||||
.on(member.id.eq(useCanCalculate.recipientCreatorId))
|
||||
.where(condition)
|
||||
.fetchOne()
|
||||
?: GetCreatorChannelDonationSettlementTotalQueryData(
|
||||
count = 0L,
|
||||
@@ -44,7 +75,7 @@ class CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
.select(formattedDate.countDistinct())
|
||||
.from(useCanCalculate)
|
||||
.innerJoin(useCanCalculate.useCan, useCan)
|
||||
.where(baseWhereCondition(startDate, endDate, memberId))
|
||||
.where(baseWhereCondition(startDate, memberId), useCan.createdAt.loe(endDate))
|
||||
.fetchOne()
|
||||
?.toInt()
|
||||
?: 0
|
||||
@@ -64,12 +95,21 @@ class CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
QGetCreatorChannelDonationSettlementQueryData(
|
||||
formattedDate,
|
||||
useCan.id.countDistinct(),
|
||||
useCanCalculate.can.sum()
|
||||
useCanCalculate.can.sum(),
|
||||
countrySettlementExpressions.newPolicyCan(useCan.createdAt, useCanCalculate.can),
|
||||
countrySettlementExpressions.newPolicyWeightedRatioCan(
|
||||
useCan.createdAt,
|
||||
useCanCalculate.can,
|
||||
member.countryCode,
|
||||
useCan.countryCode
|
||||
)
|
||||
)
|
||||
)
|
||||
.from(useCanCalculate)
|
||||
.innerJoin(useCanCalculate.useCan, useCan)
|
||||
.where(baseWhereCondition(startDate, endDate, memberId))
|
||||
.leftJoin(member)
|
||||
.on(member.id.eq(useCanCalculate.recipientCreatorId))
|
||||
.where(baseWhereCondition(startDate, memberId), useCan.createdAt.loe(endDate))
|
||||
.groupBy(formattedDate)
|
||||
.orderBy(formattedDate.desc())
|
||||
.offset(offset)
|
||||
@@ -77,26 +117,18 @@ class CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
.fetch()
|
||||
}
|
||||
|
||||
private fun baseWhereCondition(startDate: LocalDateTime, endDate: LocalDateTime, memberId: Long) = useCan.canUsage.eq(
|
||||
private fun baseWhereCondition(startDate: LocalDateTime, memberId: Long) = useCan.canUsage.eq(
|
||||
CanUsage.CHANNEL_DONATION
|
||||
)
|
||||
.and(useCan.isRefund.isFalse)
|
||||
.and(useCanCalculate.status.eq(UseCanCalculateStatus.RECEIVED))
|
||||
.and(useCanCalculate.recipientCreatorId.eq(memberId))
|
||||
.and(useCan.createdAt.goe(startDate))
|
||||
.and(useCan.createdAt.loe(endDate))
|
||||
|
||||
private fun getFormattedDate(dateTimePath: DateTimePath<LocalDateTime>): StringTemplate {
|
||||
return Expressions.stringTemplate(
|
||||
"DATE_FORMAT({0}, {1})",
|
||||
Expressions.dateTimeTemplate(
|
||||
LocalDateTime::class.java,
|
||||
"CONVERT_TZ({0},{1},{2})",
|
||||
dateTimePath,
|
||||
"UTC",
|
||||
"Asia/Seoul"
|
||||
),
|
||||
"%Y-%m-%d"
|
||||
"DATE_FORMAT(CONVERT_TZ({0}, 'UTC', 'Asia/Seoul'), '%Y-%m-%d')",
|
||||
dateTimePath
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -6,10 +6,15 @@ import kr.co.vividnext.sodalive.calculate.channelDonation.ChannelDonationSettlem
|
||||
data class GetCreatorChannelDonationSettlementQueryData @QueryProjection constructor(
|
||||
val date: String,
|
||||
val count: Long,
|
||||
val totalCan: Int?
|
||||
val totalCan: Int?,
|
||||
val newPolicyCan: Int = 0,
|
||||
val newPolicyWeightedRatioCan: Long = 0
|
||||
) {
|
||||
@QueryProjection
|
||||
constructor(date: String, count: Long, totalCan: Int?) : this(date, count, totalCan, 0, 0)
|
||||
|
||||
fun toResponseItem(creatorNickname: String): GetCreatorChannelDonationSettlementItem {
|
||||
val settlement = ChannelDonationSettlementCalculator.calculate(totalCan ?: 0)
|
||||
val settlement = ChannelDonationSettlementCalculator.calculate(totalCan ?: 0, newPolicyCan, newPolicyWeightedRatioCan)
|
||||
|
||||
return GetCreatorChannelDonationSettlementItem(
|
||||
date = date,
|
||||
|
||||
+7
-2
@@ -5,11 +5,16 @@ import kr.co.vividnext.sodalive.calculate.channelDonation.ChannelDonationSettlem
|
||||
|
||||
data class GetCreatorChannelDonationSettlementTotalQueryData @QueryProjection constructor(
|
||||
val count: Long?,
|
||||
val totalCan: Int?
|
||||
val totalCan: Int?,
|
||||
val newPolicyCan: Int = 0,
|
||||
val newPolicyWeightedRatioCan: Long = 0
|
||||
) {
|
||||
@QueryProjection
|
||||
constructor(count: Long?, totalCan: Int?) : this(count, totalCan, 0, 0)
|
||||
|
||||
fun toResponseTotal(): GetCreatorChannelDonationSettlementTotal {
|
||||
val totalCan = totalCan ?: 0
|
||||
val settlement = ChannelDonationSettlementCalculator.calculate(totalCan)
|
||||
val settlement = ChannelDonationSettlementCalculator.calculate(totalCan, newPolicyCan, newPolicyWeightedRatioCan)
|
||||
|
||||
return GetCreatorChannelDonationSettlementTotal(
|
||||
count = (count ?: 0L).toInt(),
|
||||
|
||||
+6
-1
@@ -12,6 +12,8 @@ import kr.co.vividnext.sodalive.configs.QueryDslConfig
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRepository
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.v2.settlement.adapter.out.persistence.CountrySettlementExpressions
|
||||
import kr.co.vividnext.sodalive.v2.settlement.domain.CountrySettlementPolicy
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
@@ -36,7 +38,10 @@ class CreatorAdminChannelDonationCalculateQueryRepositoryTest @Autowired constru
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
registerMysqlDateFunctions()
|
||||
repository = CreatorAdminChannelDonationCalculateQueryRepository(queryFactory)
|
||||
repository = CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
queryFactory,
|
||||
CountrySettlementExpressions(CountrySettlementPolicy())
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
package kr.co.vividnext.sodalive.creator.admin.calculate.channelDonation
|
||||
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||
import kr.co.vividnext.sodalive.can.payment.PaymentGateway
|
||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
||||
import kr.co.vividnext.sodalive.can.use.UseCan
|
||||
import kr.co.vividnext.sodalive.can.use.UseCanCalculate
|
||||
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||
import kr.co.vividnext.sodalive.configs.QueryDslConfig
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.member.MemberRole
|
||||
import kr.co.vividnext.sodalive.v2.settlement.adapter.out.persistence.CountrySettlementExpressions
|
||||
import kr.co.vividnext.sodalive.v2.settlement.domain.CountrySettlementPolicy
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.params.ParameterizedTest
|
||||
import org.junit.jupiter.params.provider.MethodSource
|
||||
import org.junit.jupiter.params.provider.ValueSource
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
|
||||
import org.springframework.context.annotation.Import
|
||||
import java.time.LocalDateTime
|
||||
import javax.persistence.EntityManager
|
||||
|
||||
@DataJpaTest(
|
||||
properties = [
|
||||
"spring.cache.type=none",
|
||||
"spring.jpa.database-platform=kr.co.vividnext.sodalive.support.H2MySqlFunctionDialect"
|
||||
]
|
||||
)
|
||||
@Import(QueryDslConfig::class)
|
||||
class CreatorChannelDonationCountryPolicyRepositoryTest @Autowired constructor(
|
||||
private val queryFactory: JPAQueryFactory,
|
||||
private val entityManager: EntityManager
|
||||
) {
|
||||
private lateinit var repository: CreatorAdminChannelDonationCalculateQueryRepository
|
||||
private lateinit var sender: Member
|
||||
private val boundary = LocalDateTime.of(2026, 10, 31, 15, 0)
|
||||
private val start = boundary.minusSeconds(1)
|
||||
private val end = boundary.plusDays(1)
|
||||
|
||||
@BeforeEach
|
||||
fun setup() {
|
||||
entityManager.createNativeQuery(
|
||||
"CREATE ALIAS IF NOT EXISTS DATE_FORMAT FOR 'kr.co.vividnext.sodalive.support.H2MysqlDateFunctions.dateFormat'"
|
||||
).executeUpdate()
|
||||
entityManager.createNativeQuery(
|
||||
"CREATE ALIAS IF NOT EXISTS CONVERT_TZ FOR 'kr.co.vividnext.sodalive.support.H2MysqlDateFunctions.convertTz'"
|
||||
).executeUpdate()
|
||||
repository = CreatorAdminChannelDonationCalculateQueryRepository(
|
||||
queryFactory,
|
||||
CountrySettlementExpressions(CountrySettlementPolicy())
|
||||
)
|
||||
sender = saveMember("sender", "US", MemberRole.USER)
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("policyCases")
|
||||
@DisplayName("크리에이터 기존 조회는 사용 시각과 본인의 현재 국가 및 저장된 거래 국가로 후원 금액을 계산한다")
|
||||
fun shouldApplyCountryPolicyThroughCurrentCreatorQueries(case: PolicyCase) {
|
||||
val creator = saveMember("creator", "US")
|
||||
val creatorId = requireNotNull(creator.id)
|
||||
val usage = saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 100, 0, countryCode = case.transactionCountry), case.at)
|
||||
saveCalculation(creator, usage)
|
||||
creator.countryCode = case.creatorCountry
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
|
||||
val total = repository.getChannelDonationSettlementTotal(start, end, creatorId).toResponseTotal()
|
||||
val daily = repository.getChannelDonation(start, end, creatorId, 0, 20).single().toResponseItem("creator")
|
||||
|
||||
assertEquals(case.expected, total)
|
||||
assertEquals(case.expected.settlementAmount, daily.settlementAmount)
|
||||
assertEquals(case.expected.withholdingTax, daily.withholdingTax)
|
||||
assertEquals(case.expected.depositAmount, daily.depositAmount)
|
||||
assertEquals("creator", daily.creator)
|
||||
assertEquals(1, daily.count)
|
||||
assertEquals(100, daily.totalCan)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("크리에이터 전체 금액은 정책 전후 한 캔씩을 한 번 계산하고 일별 페이지의 반올림 합과 구분한다")
|
||||
fun shouldKeepWholePeriodRoundingSeparateFromDailyPages() {
|
||||
val creator = saveMember("creator", "KR")
|
||||
val creatorId = requireNotNull(creator.id)
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 1, 0, countryCode = "KR"), start))
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 1, 0, countryCode = "KR"), boundary))
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
|
||||
assertEquals(
|
||||
GetCreatorChannelDonationSettlementTotal(2, 2, 200, 13, 150, 5, 145),
|
||||
repository.getChannelDonationSettlementTotal(start, end, creatorId).toResponseTotal()
|
||||
)
|
||||
assertEquals(2, repository.getChannelDonationTotalCount(start, end, creatorId))
|
||||
assertEquals(
|
||||
listOf(GetCreatorChannelDonationSettlementItem("2026-11-01", "creator", 1, 1, 100, 7, 70, 2, 68)),
|
||||
repository.getChannelDonation(start, end, creatorId, 0, 1).map { it.toResponseItem("creator") }
|
||||
)
|
||||
assertEquals(
|
||||
listOf(GetCreatorChannelDonationSettlementItem("2026-10-31", "creator", 1, 1, 100, 7, 79, 3, 76)),
|
||||
repository.getChannelDonation(start, end, creatorId, 1, 1).map { it.toResponseItem("creator") }
|
||||
)
|
||||
assertEquals(
|
||||
emptyList<GetCreatorChannelDonationSettlementQueryData>(),
|
||||
repository.getChannelDonation(start, end, creatorId, 2, 1)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("크리에이터 혼합 국가 일별 행은 본인의 수신 배분만 합하고 PG 분할을 후원 건수로 중복 계산하지 않는다")
|
||||
fun shouldKeepMixedCountriesInOneDailyRowWithRecipientScopedAllocations() {
|
||||
val creator = saveMember("creator", "KR")
|
||||
val creatorId = requireNotNull(creator.id)
|
||||
val otherCreator = saveMember("other", "JP")
|
||||
val shared = saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 5, 0, countryCode = "KR"), boundary)
|
||||
saveCalculation(creator, shared, UseCanCalculate(1, PaymentGateway.PG, UseCanCalculateStatus.RECEIVED))
|
||||
saveCalculation(creator, shared, UseCanCalculate(1, PaymentGateway.GOOGLE_IAP, UseCanCalculateStatus.RECEIVED))
|
||||
saveCalculation(otherCreator, shared, UseCanCalculate(3, PaymentGateway.APPLE_IAP, UseCanCalculateStatus.RECEIVED))
|
||||
val foreign = saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 1, 0, countryCode = "JP"), boundary.plusSeconds(1))
|
||||
saveCalculation(creator, foreign)
|
||||
saveCalculation(creator, foreign, UseCanCalculate(40, PaymentGateway.PG, UseCanCalculateStatus.REFUND))
|
||||
saveCalculation(creator, foreign, UseCanCalculate(40, PaymentGateway.PG, UseCanCalculateStatus.CALCULATE_COMPLETE))
|
||||
entityManager.persist(
|
||||
UseCanCalculate(40, PaymentGateway.PG, UseCanCalculateStatus.RECEIVED).apply { useCan = foreign }
|
||||
)
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 40, 0, isRefund = true), boundary))
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.DONATION, 40, 0), boundary))
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 40, 0), start.minusSeconds(1)))
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 40, 0), end.plusSeconds(1)))
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
|
||||
assertEquals(
|
||||
GetCreatorChannelDonationSettlementTotal(2, 3, 300, 20, 187, 6, 181),
|
||||
repository.getChannelDonationSettlementTotal(start, end, creatorId).toResponseTotal()
|
||||
)
|
||||
assertEquals(1, repository.getChannelDonationTotalCount(start, end, creatorId))
|
||||
assertEquals(
|
||||
listOf(GetCreatorChannelDonationSettlementItem("2026-11-01", "creator", 2, 3, 300, 20, 187, 6, 181)),
|
||||
repository.getChannelDonation(start, end, creatorId, 0, 1).map { it.toResponseItem("creator") }
|
||||
)
|
||||
assertEquals(
|
||||
emptyList<GetCreatorChannelDonationSettlementQueryData>(),
|
||||
repository.getChannelDonation(start, end, creatorId, 1, 1)
|
||||
)
|
||||
assertEquals(
|
||||
GetCreatorChannelDonationSettlementTotal(0, 0, 0, 0, 0, 0, 0),
|
||||
repository.getChannelDonationSettlementTotal(start, end, requireNotNull(sender.id)).toResponseTotal()
|
||||
)
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = [0, 1])
|
||||
@DisplayName("빈 크리에이터 집계와 유효한 0캔 후원은 금액이 0이어도 행과 건수가 다르다")
|
||||
fun shouldDistinguishEmptyResultsFromZeroCanSources(sourceCount: Int) {
|
||||
val creator = saveMember("creator", "KR")
|
||||
val creatorId = requireNotNull(creator.id)
|
||||
repeat(sourceCount) {
|
||||
saveCalculation(creator, saveUsage(UseCan(CanUsage.CHANNEL_DONATION, 0, 0, countryCode = "KR"), boundary))
|
||||
}
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
|
||||
assertEquals(
|
||||
GetCreatorChannelDonationSettlementTotal(sourceCount, 0, 0, 0, 0, 0, 0),
|
||||
repository.getChannelDonationSettlementTotal(start, end, creatorId).toResponseTotal()
|
||||
)
|
||||
assertEquals(sourceCount, repository.getChannelDonationTotalCount(start, end, creatorId))
|
||||
assertEquals(
|
||||
List(sourceCount) { GetCreatorChannelDonationSettlementItem("2026-11-01", "creator", 1, 0, 0, 0, 0, 0, 0) },
|
||||
repository.getChannelDonation(start, end, creatorId, 0, 20).map { it.toResponseItem("creator") }
|
||||
)
|
||||
}
|
||||
|
||||
private fun saveMember(nickname: String, country: String?, role: MemberRole = MemberRole.CREATOR): Member {
|
||||
val member = Member(
|
||||
email = "$nickname@test.com",
|
||||
password = "password",
|
||||
nickname = nickname,
|
||||
role = role,
|
||||
countryCode = country
|
||||
)
|
||||
entityManager.persist(member)
|
||||
return member
|
||||
}
|
||||
|
||||
private fun saveUsage(usage: UseCan, at: LocalDateTime): UseCan {
|
||||
usage.member = sender
|
||||
entityManager.persist(usage)
|
||||
entityManager.flush()
|
||||
entityManager.createQuery("update UseCan u set u.createdAt = :at where u.id = :id")
|
||||
.setParameter("at", at).setParameter("id", usage.id).executeUpdate()
|
||||
return usage
|
||||
}
|
||||
|
||||
private fun saveCalculation(
|
||||
creator: Member,
|
||||
usage: UseCan,
|
||||
calculation: UseCanCalculate = UseCanCalculate(usage.can, PaymentGateway.PG, UseCanCalculateStatus.RECEIVED)
|
||||
) {
|
||||
calculation.useCan = usage
|
||||
calculation.recipientCreatorId = creator.id
|
||||
entityManager.persist(calculation)
|
||||
}
|
||||
|
||||
data class PolicyCase(
|
||||
val creatorCountry: String?,
|
||||
val transactionCountry: String?,
|
||||
val at: LocalDateTime,
|
||||
val expected: GetCreatorChannelDonationSettlementTotal
|
||||
)
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun policyCases(): List<PolicyCase> {
|
||||
val boundary = LocalDateTime.of(2026, 10, 31, 15, 0)
|
||||
val legacy = GetCreatorChannelDonationSettlementTotal(1, 100, 10000, 660, 7939, 262, 7677)
|
||||
val korean = GetCreatorChannelDonationSettlementTotal(1, 100, 10000, 660, 7005, 231, 6774)
|
||||
val foreign = GetCreatorChannelDonationSettlementTotal(1, 100, 10000, 660, 6538, 216, 6322)
|
||||
val cross = GetCreatorChannelDonationSettlementTotal(1, 100, 10000, 660, 4670, 154, 4516)
|
||||
return listOf(
|
||||
PolicyCase("JP", "KR", boundary.minusSeconds(1), legacy),
|
||||
PolicyCase("KR", "KR", boundary, korean),
|
||||
PolicyCase("KR", "KR", boundary.plusDays(1), korean),
|
||||
PolicyCase("JP", "JP", boundary.plusSeconds(1), foreign),
|
||||
PolicyCase("KR", "JP", boundary, cross),
|
||||
PolicyCase(null, null, boundary, korean),
|
||||
PolicyCase(null, "KR", boundary, korean),
|
||||
PolicyCase("KR", null, boundary, korean),
|
||||
PolicyCase("", " ", boundary, korean),
|
||||
PolicyCase(" ", "", boundary, korean),
|
||||
PolicyCase("JP", null, boundary, cross),
|
||||
PolicyCase(null, "JP", boundary, cross)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -160,8 +160,14 @@ class CreatorChannelDonationEndToEndTest @Autowired constructor(
|
||||
assertEquals(500, totalBefore.totalCan)
|
||||
assertEquals(1, settlement.count)
|
||||
assertEquals(500, settlement.totalCan)
|
||||
assertEquals(39695, settlement.settlementAmount)
|
||||
assertEquals(38385, settlement.depositAmount)
|
||||
// 500 CAN: 50,000 - PG 3,300 = 46,700; 원천세는 비율별 정산액의 3.3%를 반올림한다.
|
||||
val (expectedSettlement, expectedDeposit) = when {
|
||||
createdAt < LocalDateTime.of(2026, 10, 31, 15, 0) -> 39695 to 38385
|
||||
createdAt < LocalDateTime.of(2026, 12, 31, 15, 0) -> 35025 to 33869
|
||||
else -> 32690 to 31611
|
||||
}
|
||||
assertEquals(expectedSettlement, settlement.settlementAmount)
|
||||
assertEquals(expectedDeposit, settlement.depositAmount)
|
||||
println("SETTLEMENT EVIDENCE before creatorId=${fixture.creator.id} at=$createdAt total=$totalBefore item=$settlement")
|
||||
|
||||
deleteThroughHttp(fixture.creator.id!!, donationId, fixture.creator, true)
|
||||
|
||||
Reference in New Issue
Block a user