test #348

Merged
klaus merged 4 commits from test into main 2025-10-10 19:19:47 +00:00
3 changed files with 22 additions and 13 deletions
Showing only changes of commit 778f0c3ba2 - Show all commits

View File

@@ -21,6 +21,7 @@ class AdminChargeStatusController(private val service: AdminChargeStatusService)
@GetMapping("/detail")
fun getChargeStatusDetail(
@RequestParam startDateStr: String,
@RequestParam paymentGateway: PaymentGateway
) = ApiResponse.ok(service.getChargeStatusDetail(startDateStr, paymentGateway))
@RequestParam paymentGateway: PaymentGateway,
@RequestParam(value = "currency", required = false) currency: String? = null
) = ApiResponse.ok(service.getChargeStatusDetail(startDateStr, paymentGateway, currency))
}

View File

@@ -1,5 +1,6 @@
package kr.co.vividnext.sodalive.admin.charge
import com.querydsl.core.BooleanBuilder
import com.querydsl.core.types.dsl.Expressions
import com.querydsl.jpa.impl.JPAQueryFactory
import kr.co.vividnext.sodalive.can.QCan.can1
@@ -55,7 +56,8 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
fun getChargeStatusDetail(
startDate: LocalDateTime,
endDate: LocalDateTime,
paymentGateway: PaymentGateway
paymentGateway: PaymentGateway,
currency: String? = null
): List<GetChargeStatusDetailQueryDto> {
val formattedDate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})",
@@ -68,6 +70,17 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
),
"%Y-%m-%d %H:%i:%s"
)
val currencyExpr = Expressions.stringTemplate("RIGHT({0}, 3)", payment.locale)
val whereBuilder = BooleanBuilder()
whereBuilder.and(charge.createdAt.goe(startDate))
.and(charge.createdAt.loe(endDate))
.and(charge.status.eq(ChargeStatus.CHARGE))
.and(payment.status.eq(PaymentStatus.COMPLETE))
.and(payment.paymentGateway.eq(paymentGateway))
if (currency != null) {
whereBuilder.and(currencyExpr.eq(currency))
}
return queryFactory
.select(
@@ -76,7 +89,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
member.nickname,
payment.method.coalesce(""),
payment.price,
payment.locale.coalesce(""),
currencyExpr.coalesce(""),
formattedDate
)
)
@@ -84,13 +97,7 @@ class AdminChargeStatusQueryRepository(private val queryFactory: JPAQueryFactory
.innerJoin(charge.member, member)
.innerJoin(charge.payment, payment)
.leftJoin(charge.can, can1)
.where(
charge.createdAt.goe(startDate)
.and(charge.createdAt.loe(endDate))
.and(charge.status.eq(ChargeStatus.CHARGE))
.and(payment.status.eq(PaymentStatus.COMPLETE))
.and(payment.paymentGateway.eq(paymentGateway))
)
.where(whereBuilder)
.orderBy(formattedDate.desc())
.fetch()
}

View File

@@ -60,7 +60,8 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository)
fun getChargeStatusDetail(
startDateStr: String,
paymentGateway: PaymentGateway
paymentGateway: PaymentGateway,
currency: String? = null
): List<GetChargeStatusDetailResponse> {
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
@@ -73,7 +74,7 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository)
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
return repository.getChargeStatusDetail(startDate, endDate, paymentGateway)
return repository.getChargeStatusDetail(startDate, endDate, paymentGateway, currency)
.map {
GetChargeStatusDetailResponse(
memberId = it.memberId,