Compare commits
No commits in common. "c4e58890eaf02211f2c7253fbeceb8e857d9d959" and "87000307076d5157aa5bef1527ce808d1ca9fd69" have entirely different histories.
c4e58890ea
...
8700030707
|
@ -48,18 +48,4 @@ class AdminCalculateController(private val service: AdminCalculateService) {
|
||||||
pageable.pageSize.toLong()
|
pageable.pageSize.toLong()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@GetMapping("/live-by-creator")
|
|
||||||
fun getCalculateLiveByCreator(
|
|
||||||
@RequestParam startDateStr: String,
|
|
||||||
@RequestParam endDateStr: String,
|
|
||||||
pageable: Pageable
|
|
||||||
) = ApiResponse.ok(
|
|
||||||
service.getCalculateLiveByCreator(
|
|
||||||
startDateStr,
|
|
||||||
endDateStr,
|
|
||||||
pageable.offset,
|
|
||||||
pageable.pageSize.toLong()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,44 +224,4 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalculateLiveByCreatorTotalCount(startDate: LocalDateTime, endDate: LocalDateTime): Int {
|
|
||||||
return queryFactory
|
|
||||||
.select(member.id)
|
|
||||||
.from(useCan)
|
|
||||||
.innerJoin(useCan.room, liveRoom)
|
|
||||||
.innerJoin(liveRoom.member, member)
|
|
||||||
.leftJoin(creatorSettlementRatio)
|
|
||||||
.on(member.id.eq(creatorSettlementRatio.member.id))
|
|
||||||
.groupBy(member.id)
|
|
||||||
.fetch()
|
|
||||||
.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCalculateLiveByCreator(
|
|
||||||
startDate: LocalDateTime,
|
|
||||||
endDate: LocalDateTime,
|
|
||||||
offset: Long,
|
|
||||||
limit: Long
|
|
||||||
): List<GetCalculateLiveByCreatorQueryData> {
|
|
||||||
return queryFactory
|
|
||||||
.select(
|
|
||||||
QGetCalculateLiveByCreatorQueryData(
|
|
||||||
member.email,
|
|
||||||
member.nickname,
|
|
||||||
useCan.can.add(useCan.rewardCan).sum(),
|
|
||||||
creatorSettlementRatio.liveSettlementRatio
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(useCan)
|
|
||||||
.innerJoin(useCan.room, liveRoom)
|
|
||||||
.innerJoin(liveRoom.member, member)
|
|
||||||
.leftJoin(creatorSettlementRatio)
|
|
||||||
.on(member.id.eq(creatorSettlementRatio.member.id))
|
|
||||||
.groupBy(member.id)
|
|
||||||
.orderBy(useCan.can.add(useCan.rewardCan).desc())
|
|
||||||
.offset(offset)
|
|
||||||
.limit(limit)
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.springframework.transaction.annotation.Transactional
|
||||||
class AdminCalculateService(private val repository: AdminCalculateQueryRepository) {
|
class AdminCalculateService(private val repository: AdminCalculateQueryRepository) {
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
@Cacheable(
|
@Cacheable(
|
||||||
cacheNames = ["cache_ttl_3_hours"],
|
cacheNames = ["default"],
|
||||||
key = "'calculateLive:' + " + "#startDateStr + ':' + #endDateStr"
|
key = "'calculateLive:' + " + "#startDateStr + ':' + #endDateStr"
|
||||||
)
|
)
|
||||||
fun getCalculateLive(startDateStr: String, endDateStr: String): List<GetCalculateLiveResponse> {
|
fun getCalculateLive(startDateStr: String, endDateStr: String): List<GetCalculateLiveResponse> {
|
||||||
|
@ -67,11 +67,6 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
|
||||||
.map { it.toGetCalculateContentDonationResponse() }
|
.map { it.toGetCalculateContentDonationResponse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
@Cacheable(
|
|
||||||
cacheNames = ["cache_ttl_3_hours"],
|
|
||||||
key = "'calculateCommunityPost:' + " + "#startDateStr + ':' + #endDateStr + ':' + #offset"
|
|
||||||
)
|
|
||||||
fun getCalculateCommunityPost(
|
fun getCalculateCommunityPost(
|
||||||
startDateStr: String,
|
startDateStr: String,
|
||||||
endDateStr: String,
|
endDateStr: String,
|
||||||
|
@ -88,21 +83,4 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
|
||||||
|
|
||||||
return GetCreatorCalculateCommunityPostResponse(totalCount, items)
|
return GetCreatorCalculateCommunityPostResponse(totalCount, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalculateLiveByCreator(
|
|
||||||
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.getCalculateLiveByCreatorTotalCount(startDate, endDate)
|
|
||||||
val items = repository
|
|
||||||
.getCalculateLiveByCreator(startDate, endDate, offset, limit)
|
|
||||||
.map { it.toGetCalculateLiveByCreator() }
|
|
||||||
|
|
||||||
GetCalculateLiveByCreatorResponse(totalCount, items)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.calculate
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
|
||||||
|
|
||||||
data class GetCalculateLiveByCreatorItem(
|
|
||||||
@JsonProperty("email") val email: String,
|
|
||||||
@JsonProperty("nickname") val nickname: String,
|
|
||||||
@JsonProperty("totalCan") val totalCan: Int,
|
|
||||||
@JsonProperty("totalKrw") val totalKrw: Int,
|
|
||||||
@JsonProperty("paymentFee") val paymentFee: Int,
|
|
||||||
@JsonProperty("settlementAmount") val settlementAmount: Int,
|
|
||||||
@JsonProperty("tax") val tax: Int,
|
|
||||||
@JsonProperty("depositAmount") val depositAmount: Int
|
|
||||||
)
|
|
|
@ -1,44 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.calculate
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
import java.math.BigDecimal
|
|
||||||
import java.math.RoundingMode
|
|
||||||
|
|
||||||
data class GetCalculateLiveByCreatorQueryData @QueryProjection constructor(
|
|
||||||
val email: String,
|
|
||||||
val nickname: String,
|
|
||||||
val totalCan: Int,
|
|
||||||
val settlementRatio: Int?
|
|
||||||
) {
|
|
||||||
fun toGetCalculateLiveByCreator(): GetCalculateLiveByCreatorItem {
|
|
||||||
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
|
|
||||||
val totalKrw = BigDecimal(totalCan).multiply(BigDecimal(100))
|
|
||||||
|
|
||||||
// 결제수수료 : 6.6%
|
|
||||||
val paymentFee = totalKrw.multiply(BigDecimal(0.066))
|
|
||||||
|
|
||||||
// 정산금액 = (원화 - 결제수수료) 의 70%
|
|
||||||
val settlementAmount = if (settlementRatio != null) {
|
|
||||||
totalKrw.subtract(paymentFee).multiply(BigDecimal(settlementRatio).divide(BigDecimal(100.0)))
|
|
||||||
} else {
|
|
||||||
totalKrw.subtract(paymentFee).multiply(BigDecimal(0.7))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 원천세 = 정산금액의 3.3%
|
|
||||||
val tax = settlementAmount.multiply(BigDecimal(0.033))
|
|
||||||
|
|
||||||
// 입금액
|
|
||||||
val depositAmount = settlementAmount.subtract(tax)
|
|
||||||
|
|
||||||
return GetCalculateLiveByCreatorItem(
|
|
||||||
email = email,
|
|
||||||
nickname = nickname,
|
|
||||||
totalCan = totalCan,
|
|
||||||
totalKrw = totalKrw.toInt(),
|
|
||||||
paymentFee = paymentFee.setScale(0, RoundingMode.HALF_UP).toInt(),
|
|
||||||
settlementAmount = settlementAmount.setScale(0, RoundingMode.HALF_UP).toInt(),
|
|
||||||
tax = tax.setScale(0, RoundingMode.HALF_UP).toInt(),
|
|
||||||
depositAmount = depositAmount.setScale(0, RoundingMode.HALF_UP).toInt()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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