From 38c50a4f8a42078e22910cfc942f7532cd696b29 Mon Sep 17 00:00:00 2001 From: Klaus Date: Sat, 11 Oct 2025 02:31:15 +0900 Subject: [PATCH] =?UTF-8?q?fix(admin/charge):=20=ED=86=B5=ED=99=94?= =?UTF-8?q?=EB=B3=84=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=99=80=20=ED=95=A9?= =?UTF-8?q?=EA=B3=84=20=ED=96=89=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=ED=95=A9=EA=B3=84=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존 로직은 통화 구분 없이 전체 합계를 계산·표시하여 통화가 혼재된 데이터에서 오해의 소지가 있었음. - 관리 화면 요구사항: 통화(currency)별 합계를 명확히 제공. --- .../AdminChargeStatusQueryRepository.kt | 6 ++-- .../admin/charge/AdminChargeStatusService.kt | 33 +++++++++++-------- .../admin/charge/GetChargeStatusQueryDto.kt | 3 +- .../admin/charge/GetChargeStatusResponse.kt | 3 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusQueryRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusQueryRepository.kt index f1ec63c..6c9519d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusQueryRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusQueryRepository.kt @@ -26,6 +26,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory ), "%Y-%m-%d" ) + val currency = Expressions.stringTemplate("RIGHT({0}, 3)", payment.locale) return queryFactory .select( @@ -33,7 +34,8 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory formattedDate, payment.price.sum(), payment.id.count(), - payment.paymentGateway + payment.paymentGateway, + currency ) ) .from(payment) @@ -45,7 +47,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory .and(charge.status.eq(ChargeStatus.CHARGE)) .and(payment.status.eq(PaymentStatus.COMPLETE)) ) - .groupBy(formattedDate, payment.paymentGateway) + .groupBy(formattedDate, payment.paymentGateway, currency) .orderBy(formattedDate.desc()) .fetch() } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt index f1b5e7e..67f4891 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt @@ -20,35 +20,40 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository) .withZoneSameInstant(ZoneId.of("UTC")) .toLocalDateTime() - var totalChargeAmount = 0.toBigDecimal() - var totalChargeCount = 0L + val totalsByCurrency = mutableMapOf>() val chargeStatusList = repository.getChargeStatus(startDate, endDate) .map { val chargeAmount = it.amount val chargeCount = it.chargeCount + val currency = it.currency - totalChargeAmount += chargeAmount - totalChargeCount += chargeCount + val prev = totalsByCurrency[currency] ?: (0.toBigDecimal() to 0L) + totalsByCurrency[currency] = (prev.first + chargeAmount) to (prev.second + chargeCount) GetChargeStatusResponse( date = it.date, chargeAmount = chargeAmount, chargeCount = chargeCount, - pg = it.paymentGateWay.name + pg = it.paymentGateWay.name, + currency = currency ) } .toMutableList() - chargeStatusList.add( - 0, - GetChargeStatusResponse( - date = "합계", - chargeAmount = totalChargeAmount, - chargeCount = totalChargeCount, - pg = "" - ) - ) + val summaryRows = totalsByCurrency.entries + .sortedBy { it.key } + .map { (currency, total) -> + GetChargeStatusResponse( + date = "합계", + chargeAmount = total.first, + chargeCount = total.second, + pg = "", + currency = currency + ) + } + + chargeStatusList.addAll(0, summaryRows) return chargeStatusList.toList() } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt index 22bdd4c..c173892 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt @@ -8,5 +8,6 @@ data class GetChargeStatusQueryDto @QueryProjection constructor( val date: String, val amount: BigDecimal, val chargeCount: Long, - val paymentGateWay: PaymentGateway + val paymentGateWay: PaymentGateway, + val currency: String ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt index 75dffcb..3d914a9 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt @@ -6,5 +6,6 @@ data class GetChargeStatusResponse( val date: String, val chargeAmount: BigDecimal, val chargeCount: Long, - val pg: String + val pg: String, + val currency: String )