관리자 콘텐츠 정산 API - 총 개수 추가

This commit is contained in:
Klaus 2023-11-10 17:20:11 +09:00
parent 472b51dd85
commit c590eff460
3 changed files with 33 additions and 3 deletions

View File

@ -46,6 +46,24 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
.fetch() .fetch()
} }
fun getCalculateContentTotalCount(startDate: LocalDateTime, endDate: LocalDateTime): Int {
return queryFactory
.select(audioContent.id)
.from(useCanCalculate)
.innerJoin(useCanCalculate.useCan, useCan)
.innerJoin(useCan.order, order)
.innerJoin(order.audioContent, audioContent)
.innerJoin(audioContent.member, member)
.where(
useCanCalculate.status.eq(UseCanCalculateStatus.RECEIVED)
.and(order.createdAt.goe(startDate))
.and(order.createdAt.loe(endDate))
)
.groupBy(audioContent.id, order.type)
.fetch()
.size
}
fun getCalculateContentList( fun getCalculateContentList(
startDate: LocalDateTime, startDate: LocalDateTime,
endDate: LocalDateTime, endDate: LocalDateTime,

View File

@ -77,7 +77,7 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
endDateStr: String, endDateStr: String,
offset: Long, offset: Long,
limit: Long limit: Long
): List<GetCalculateContentResponse> { ): GetCalculateContentResponse {
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul")) .atZone(ZoneId.of("Asia/Seoul"))
@ -89,7 +89,9 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
.withZoneSameInstant(ZoneId.of("UTC")) .withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime() .toLocalDateTime()
return repository val totalCount = repository.getCalculateContentTotalCount(startDate, endDate)
val items = repository
.getCalculateContentList(startDate, endDate, offset, limit) .getCalculateContentList(startDate, endDate, offset, limit)
.map { .map {
val orderTypeStr = if (it.orderType == OrderType.RENTAL) { val orderTypeStr = if (it.orderType == OrderType.RENTAL) {
@ -113,7 +115,7 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
// 입금액 // 입금액
val depositAmount = settlementAmount - tax val depositAmount = settlementAmount - tax
GetCalculateContentResponse( GetCalculateContentItemResponse(
nickname = it.nickname, nickname = it.nickname,
title = it.title, title = it.title,
registrationDate = it.registrationDate, registrationDate = it.registrationDate,
@ -130,5 +132,10 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
) )
} }
.toList() .toList()
return GetCalculateContentResponse(
totalCount = totalCount,
items = items
)
} }
} }

View File

@ -1,6 +1,11 @@
package kr.co.vividnext.sodalive.admin.calculate package kr.co.vividnext.sodalive.admin.calculate
data class GetCalculateContentResponse( data class GetCalculateContentResponse(
val totalCount: Int,
val items: List<GetCalculateContentItemResponse>
)
data class GetCalculateContentItemResponse(
// 등록 크리에이터 닉네임 // 등록 크리에이터 닉네임
val nickname: String, val nickname: String,
// 콘텐츠 제목 // 콘텐츠 제목