크리에이터 기준 콘텐츠 합계 정산 API 추가
This commit is contained in:
parent
331a1549da
commit
586db3f008
|
@ -62,4 +62,18 @@ class AdminCalculateController(private val service: AdminCalculateService) {
|
|||
pageable.pageSize.toLong()
|
||||
)
|
||||
)
|
||||
|
||||
@GetMapping("/content-by-creator")
|
||||
fun getCalculateContentByCreator(
|
||||
@RequestParam startDateStr: String,
|
||||
@RequestParam endDateStr: String,
|
||||
pageable: Pageable
|
||||
) = ApiResponse.ok(
|
||||
service.getCalculateContentByCreator(
|
||||
startDateStr,
|
||||
endDateStr,
|
||||
pageable.offset,
|
||||
pageable.pageSize.toLong()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -248,10 +248,10 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
|
|||
endDate: LocalDateTime,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetCalculateLiveByCreatorQueryData> {
|
||||
): List<GetCalculateByCreatorQueryData> {
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetCalculateLiveByCreatorQueryData(
|
||||
QGetCalculateByCreatorQueryData(
|
||||
member.email,
|
||||
member.nickname,
|
||||
useCan.can.add(useCan.rewardCan).sum(),
|
||||
|
@ -274,4 +274,54 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
|
|||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
|
||||
fun getCalculateContentByCreatorTotalCount(startDate: LocalDateTime, endDate: LocalDateTime): Int {
|
||||
return queryFactory
|
||||
.select(member.id)
|
||||
.from(order)
|
||||
.innerJoin(order.audioContent, audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.leftJoin(creatorSettlementRatio)
|
||||
.on(member.id.eq(creatorSettlementRatio.member.id))
|
||||
.where(
|
||||
order.createdAt.goe(startDate)
|
||||
.and(order.createdAt.loe(endDate))
|
||||
.and(order.isActive.isTrue)
|
||||
)
|
||||
.groupBy(member.id)
|
||||
.fetch()
|
||||
.size
|
||||
}
|
||||
|
||||
fun getCalculateContentByCreator(
|
||||
startDate: LocalDateTime,
|
||||
endDate: LocalDateTime,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
): List<GetCalculateByCreatorQueryData> {
|
||||
return queryFactory
|
||||
.select(
|
||||
QGetCalculateByCreatorQueryData(
|
||||
member.email,
|
||||
member.nickname,
|
||||
order.can.sum(),
|
||||
creatorSettlementRatio.contentSettlementRatio
|
||||
)
|
||||
)
|
||||
.from(order)
|
||||
.innerJoin(order.audioContent, audioContent)
|
||||
.innerJoin(audioContent.member, member)
|
||||
.leftJoin(creatorSettlementRatio)
|
||||
.on(member.id.eq(creatorSettlementRatio.member.id))
|
||||
.where(
|
||||
order.createdAt.goe(startDate)
|
||||
.and(order.createdAt.loe(endDate))
|
||||
.and(order.isActive.isTrue)
|
||||
)
|
||||
.groupBy(member.id)
|
||||
.orderBy(member.id.desc())
|
||||
.offset(offset)
|
||||
.limit(limit)
|
||||
.fetch()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,8 +101,25 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
|
|||
val totalCount = repository.getCalculateLiveByCreatorTotalCount(startDate, endDate)
|
||||
val items = repository
|
||||
.getCalculateLiveByCreator(startDate, endDate, offset, limit)
|
||||
.map { it.toGetCalculateLiveByCreator() }
|
||||
.map { it.toGetCalculateByCreator() }
|
||||
|
||||
GetCalculateLiveByCreatorResponse(totalCount, items)
|
||||
GetCalculateByCreatorResponse(totalCount, items)
|
||||
}
|
||||
|
||||
fun getCalculateContentByCreator(
|
||||
startDateStr: String,
|
||||
endDateStr: String,
|
||||
offset: Long,
|
||||
limit: Long
|
||||
) = run {
|
||||
val startDate = startDateStr.convertLocalDateTime()
|
||||
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
|
||||
|
||||
val totalCount = repository.getCalculateContentByCreatorTotalCount(startDate, endDate)
|
||||
val items = repository
|
||||
.getCalculateContentByCreator(startDate, endDate, offset, limit)
|
||||
.map { it.toGetCalculateByCreator() }
|
||||
|
||||
GetCalculateByCreatorResponse(totalCount, items)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package kr.co.vividnext.sodalive.admin.calculate
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
|
||||
data class GetCalculateLiveByCreatorItem(
|
||||
data class GetCalculateByCreatorItem(
|
||||
@JsonProperty("email") val email: String,
|
||||
@JsonProperty("nickname") val nickname: String,
|
||||
@JsonProperty("totalCan") val totalCan: Int,
|
|
@ -4,13 +4,13 @@ import com.querydsl.core.annotations.QueryProjection
|
|||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
data class GetCalculateLiveByCreatorQueryData @QueryProjection constructor(
|
||||
data class GetCalculateByCreatorQueryData @QueryProjection constructor(
|
||||
val email: String,
|
||||
val nickname: String,
|
||||
val totalCan: Int,
|
||||
val settlementRatio: Int?
|
||||
) {
|
||||
fun toGetCalculateLiveByCreator(): GetCalculateLiveByCreatorItem {
|
||||
fun toGetCalculateByCreator(): GetCalculateByCreatorItem {
|
||||
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
|
||||
val totalKrw = BigDecimal(totalCan).multiply(BigDecimal(100))
|
||||
|
||||
|
@ -30,7 +30,7 @@ data class GetCalculateLiveByCreatorQueryData @QueryProjection constructor(
|
|||
// 입금액
|
||||
val depositAmount = settlementAmount.subtract(tax)
|
||||
|
||||
return GetCalculateLiveByCreatorItem(
|
||||
return GetCalculateByCreatorItem(
|
||||
email = email,
|
||||
nickname = nickname,
|
||||
totalCan = totalCan,
|
|
@ -0,0 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.admin.calculate
|
||||
|
||||
data class GetCalculateByCreatorResponse(
|
||||
val totalCount: Int,
|
||||
val items: List<GetCalculateByCreatorItem>
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
package kr.co.vividnext.sodalive.admin.calculate
|
||||
|
||||
data class GetCalculateLiveByCreatorResponse(
|
||||
val totalCount: Int,
|
||||
val items: List<GetCalculateLiveByCreatorItem>
|
||||
)
|
Loading…
Reference in New Issue