test #348

Merged
klaus merged 4 commits from test into main 2025-10-10 19:19:47 +00:00
4 changed files with 27 additions and 18 deletions
Showing only changes of commit 38c50a4f8a - Show all commits

View File

@@ -26,6 +26,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
), ),
"%Y-%m-%d" "%Y-%m-%d"
) )
val currency = Expressions.stringTemplate("RIGHT({0}, 3)", payment.locale)
return queryFactory return queryFactory
.select( .select(
@@ -33,7 +34,8 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
formattedDate, formattedDate,
payment.price.sum(), payment.price.sum(),
payment.id.count(), payment.id.count(),
payment.paymentGateway payment.paymentGateway,
currency
) )
) )
.from(payment) .from(payment)
@@ -45,7 +47,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
.and(charge.status.eq(ChargeStatus.CHARGE)) .and(charge.status.eq(ChargeStatus.CHARGE))
.and(payment.status.eq(PaymentStatus.COMPLETE)) .and(payment.status.eq(PaymentStatus.COMPLETE))
) )
.groupBy(formattedDate, payment.paymentGateway) .groupBy(formattedDate, payment.paymentGateway, currency)
.orderBy(formattedDate.desc()) .orderBy(formattedDate.desc())
.fetch() .fetch()
} }

View File

@@ -20,35 +20,40 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository)
.withZoneSameInstant(ZoneId.of("UTC")) .withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime() .toLocalDateTime()
var totalChargeAmount = 0.toBigDecimal() val totalsByCurrency = mutableMapOf<String, Pair<java.math.BigDecimal, Long>>()
var totalChargeCount = 0L
val chargeStatusList = repository.getChargeStatus(startDate, endDate) val chargeStatusList = repository.getChargeStatus(startDate, endDate)
.map { .map {
val chargeAmount = it.amount val chargeAmount = it.amount
val chargeCount = it.chargeCount val chargeCount = it.chargeCount
val currency = it.currency
totalChargeAmount += chargeAmount val prev = totalsByCurrency[currency] ?: (0.toBigDecimal() to 0L)
totalChargeCount += chargeCount totalsByCurrency[currency] = (prev.first + chargeAmount) to (prev.second + chargeCount)
GetChargeStatusResponse( GetChargeStatusResponse(
date = it.date, date = it.date,
chargeAmount = chargeAmount, chargeAmount = chargeAmount,
chargeCount = chargeCount, chargeCount = chargeCount,
pg = it.paymentGateWay.name pg = it.paymentGateWay.name,
currency = currency
) )
} }
.toMutableList() .toMutableList()
chargeStatusList.add( val summaryRows = totalsByCurrency.entries
0, .sortedBy { it.key }
GetChargeStatusResponse( .map { (currency, total) ->
date = "합계", GetChargeStatusResponse(
chargeAmount = totalChargeAmount, date = "합계",
chargeCount = totalChargeCount, chargeAmount = total.first,
pg = "" chargeCount = total.second,
) pg = "",
) currency = currency
)
}
chargeStatusList.addAll(0, summaryRows)
return chargeStatusList.toList() return chargeStatusList.toList()
} }

View File

@@ -8,5 +8,6 @@ data class GetChargeStatusQueryDto @QueryProjection constructor(
val date: String, val date: String,
val amount: BigDecimal, val amount: BigDecimal,
val chargeCount: Long, val chargeCount: Long,
val paymentGateWay: PaymentGateway val paymentGateWay: PaymentGateway,
val currency: String
) )

View File

@@ -6,5 +6,6 @@ data class GetChargeStatusResponse(
val date: String, val date: String,
val chargeAmount: BigDecimal, val chargeAmount: BigDecimal,
val chargeCount: Long, val chargeCount: Long,
val pg: String val pg: String,
val currency: String
) )