Compare commits

..

No commits in common. "2c176825fdfbc870b305751af2d8056556415bc3" and "fae7de48d377152defa453e60c108d22a1dd3e0e" have entirely different histories.

11 changed files with 471 additions and 333 deletions

View File

@ -34,18 +34,4 @@ class AdminCalculateController(private val service: AdminCalculateService) {
@RequestParam startDateStr: String,
@RequestParam endDateStr: String
) = ApiResponse.ok(service.getCalculateContentDonationList(startDateStr, endDateStr))
@GetMapping("/community-post")
fun getCalculateCommunityPost(
@RequestParam startDateStr: String,
@RequestParam endDateStr: String,
pageable: Pageable
) = ApiResponse.ok(
service.getCalculateCommunityPost(
startDateStr,
endDateStr,
pageable.offset,
pageable.pageSize.toLong()
)
)
}

View File

@ -8,7 +8,6 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
import kr.co.vividnext.sodalive.content.QAudioContent.audioContent
import kr.co.vividnext.sodalive.content.order.QOrder.order
import kr.co.vividnext.sodalive.explorer.profile.creatorCommunity.QCreatorCommunity.creatorCommunity
import kr.co.vividnext.sodalive.live.room.QLiveRoom.liveRoom
import kr.co.vividnext.sodalive.member.QMember.member
import org.springframework.stereotype.Repository
@ -153,53 +152,4 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
.orderBy(member.id.asc(), donationFormattedDate.desc())
.fetch()
}
fun getCalculateCommunityPostTotalCount(startDate: LocalDateTime?, endDate: LocalDateTime?): Int {
val formattedDate = getFormattedDate(useCan.createdAt)
return queryFactory
.select(creatorCommunity.id)
.from(useCan)
.innerJoin(useCan.communityPost, creatorCommunity)
.innerJoin(creatorCommunity.member, member)
.where(
useCan.isRefund.isFalse
.and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST))
.and(useCan.createdAt.goe(startDate))
.and(useCan.createdAt.loe(endDate))
)
.groupBy(formattedDate, creatorCommunity.id)
.fetch()
.size
}
fun getCalculateCommunityPostList(
startDate: LocalDateTime?,
endDate: LocalDateTime?,
offset: Long,
limit: Long
): List<GetCalculateCommunityPostQueryData> {
val formattedDate = getFormattedDate(useCan.createdAt)
return queryFactory
.select(
QGetCalculateCommunityPostQueryData(
member.nickname,
Expressions.stringTemplate("substring({0}, 1, 10)", creatorCommunity.content),
formattedDate,
useCan.id.count(),
useCan.can.add(useCan.rewardCan).sum()
)
)
.from(useCan)
.innerJoin(useCan.communityPost, creatorCommunity)
.innerJoin(creatorCommunity.member, member)
.where(
useCan.isRefund.isFalse
.and(useCan.canUsage.eq(CanUsage.PAID_COMMUNITY_POST))
.and(useCan.createdAt.goe(startDate))
.and(useCan.createdAt.loe(endDate))
)
.groupBy(formattedDate, creatorCommunity.id)
.orderBy(member.id.asc(), formattedDate.desc())
.fetch()
}
}

View File

@ -1,10 +1,14 @@
package kr.co.vividnext.sodalive.admin.calculate
import kr.co.vividnext.sodalive.creator.admin.calculate.GetCreatorCalculateCommunityPostResponse
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.content.order.OrderType
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import kotlin.math.roundToInt
@Service
class AdminCalculateService(private val repository: AdminCalculateQueryRepository) {
@ -14,12 +18,73 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
key = "'calculateLive:' + " + "#startDateStr + ':' + #endDateStr"
)
fun getCalculateLive(startDateStr: String, endDateStr: String): List<GetCalculateLiveResponse> {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
return repository
.getCalculateLive(startDate, endDate)
.map { it.toGetCalculateLiveResponse() }
.asSequence()
.map {
val canUsageStr = when (it.canUsage) {
CanUsage.LIVE -> {
"유료"
}
CanUsage.SPIN_ROULETTE -> {
"룰렛"
}
else -> {
"후원"
}
}
val numberOfPeople = if (it.canUsage == CanUsage.LIVE) {
it.memberCount.toInt()
} else {
0
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalAmount * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateLiveResponse(
email = it.email,
nickname = it.nickname,
date = it.date,
title = it.title,
entranceFee = it.entranceFee,
canUsageStr = canUsageStr,
numberOfPeople = numberOfPeople,
totalAmount = it.totalAmount,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
}
@Transactional(readOnly = true)
@ -28,12 +93,59 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
key = "'calculateContent:' + " + "#startDateStr + ':' + #endDateStr"
)
fun getCalculateContentList(startDateStr: String, endDateStr: String): List<GetCalculateContentResponse> {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
return repository
.getCalculateContentList(startDate, endDate)
.map { it.toGetCalculateContentResponse() }
.asSequence()
.map {
val orderTypeStr = if (it.orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateContentResponse(
nickname = it.nickname,
title = it.title,
registrationDate = it.registrationDate,
saleDate = it.saleDate,
orderType = orderTypeStr,
orderPrice = it.orderPrice,
numberOfPeople = it.numberOfPeople.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
}
@Transactional(readOnly = true)
@ -45,7 +157,45 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
val totalCount = repository.getCumulativeSalesByContentTotalCount()
val items = repository
.getCumulativeSalesByContent(offset, limit)
.map { it.toCumulativeSalesByContentItem() }
.asSequence()
.map {
val orderTypeStr = if (it.orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
CumulativeSalesByContentItem(
nickname = it.nickname,
title = it.title,
registrationDate = it.registrationDate,
orderType = orderTypeStr,
orderPrice = it.orderPrice,
numberOfPeople = it.numberOfPeople.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
return GetCumulativeSalesByContentResponse(totalCount, items)
}
@ -59,28 +209,61 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
startDateStr: String,
endDateStr: String
): List<GetCalculateContentDonationResponse> {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
return repository
.getCalculateContentDonationList(startDate, endDate)
.map { it.toGetCalculateContentDonationResponse() }
}
.asSequence()
.map {
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
fun getCalculateCommunityPost(
startDateStr: String,
endDateStr: String,
offset: Long,
limit: Long
): GetCreatorCalculateCommunityPostResponse {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
val totalCount = repository.getCalculateCommunityPostTotalCount(startDate, endDate)
val items = repository
.getCalculateCommunityPostList(startDate, endDate, offset, limit)
.map { it.toGetCalculateCommunityPostResponse() }
// 정산금액
// 유료콘텐츠 (원화 - 결제수수료) 의 90%
// 무료콘텐츠 (원화 - 결제수수료) 의 70%
val settlementAmount = if (it.price > 0) {
(totalKrw.toFloat() - paymentFee) * 0.9
} else {
(totalKrw.toFloat() - paymentFee) * 0.7
}
return GetCreatorCalculateCommunityPostResponse(totalCount, items)
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateContentDonationResponse(
nickname = it.nickname,
title = it.title,
paidOrFree = if (it.price > 0) {
"유료"
} else {
"무료"
},
registrationDate = it.registrationDate,
donationDate = it.donationDate,
numberOfDonation = it.numberOfDonation.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
}
}

View File

@ -1,7 +1,6 @@
package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kotlin.math.roundToInt
data class GetCalculateCommunityPostQueryData @QueryProjection constructor(
val nickname: String,
@ -9,25 +8,4 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor(
val date: String,
val numberOfPurchase: Long,
val totalCan: Int
) {
fun toGetCalculateCommunityPostResponse(): GetCalculateCommunityPostResponse {
val totalKrw = totalCan * 100
val paymentFee = totalKrw * 0.066f
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
val tax = settlementAmount * 0.033
val depositAmount = settlementAmount - tax
return GetCalculateCommunityPostResponse(
nickname = nickname,
title = title,
date = date,
numberOfPurchase = numberOfPurchase.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
}
)

View File

@ -1,7 +1,6 @@
package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kotlin.math.roundToInt
data class GetCalculateContentDonationQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -18,48 +17,4 @@ data class GetCalculateContentDonationQueryData @QueryProjection constructor(
val numberOfDonation: Long,
// 합계
val totalCan: Int
) {
fun toGetCalculateContentDonationResponse(): GetCalculateContentDonationResponse {
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액
// 유료콘텐츠 (원화 - 결제수수료) 의 90%
// 무료콘텐츠 (원화 - 결제수수료) 의 70%
val settlementAmount = if (price > 0) {
(totalKrw.toFloat() - paymentFee) * 0.9
} else {
(totalKrw.toFloat() - paymentFee) * 0.7
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
val paidOrFree = if (price > 0) {
"유료"
} else {
"무료"
}
return GetCalculateContentDonationResponse(
nickname = nickname,
title = title,
paidOrFree = paidOrFree,
registrationDate = registrationDate,
donationDate = donationDate,
numberOfDonation = numberOfDonation.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
}
)

View File

@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.content.order.OrderType
import kotlin.math.roundToInt
data class GetCalculateContentQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -21,43 +20,4 @@ data class GetCalculateContentQueryData @QueryProjection constructor(
val numberOfPeople: Long,
// 합계
val totalCan: Int
) {
fun toGetCalculateContentResponse(): GetCalculateContentResponse {
val orderTypeStr = if (orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
return GetCalculateContentResponse(
nickname = nickname,
title = title,
registrationDate = registrationDate,
saleDate = saleDate,
orderType = orderTypeStr,
orderPrice = orderPrice,
numberOfPeople = numberOfPeople.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
}
)

View File

@ -2,7 +2,6 @@ package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.can.use.CanUsage
import kotlin.math.roundToInt
data class GetCalculateLiveQueryData @QueryProjection constructor(
val email: String,
@ -17,57 +16,4 @@ data class GetCalculateLiveQueryData @QueryProjection constructor(
val memberCount: Long,
// 합계
val totalAmount: Int
) {
fun toGetCalculateLiveResponse(): GetCalculateLiveResponse {
val canUsageStr = when (canUsage) {
CanUsage.LIVE -> {
"유료"
}
CanUsage.SPIN_ROULETTE -> {
"룰렛"
}
else -> {
"후원"
}
}
val numberOfPeople = if (canUsage == CanUsage.LIVE) {
memberCount.toInt()
} else {
0
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalAmount * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
return GetCalculateLiveResponse(
email = email,
nickname = nickname,
date = date,
title = title,
entranceFee = entranceFee,
canUsageStr = canUsageStr,
numberOfPeople = numberOfPeople,
totalAmount = totalAmount,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
}
)

View File

@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.admin.calculate
import com.fasterxml.jackson.annotation.JsonProperty
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.content.order.OrderType
import kotlin.math.roundToInt
data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -20,45 +19,7 @@ data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
val numberOfPeople: Long,
// 합계
val totalCan: Int
) {
fun toCumulativeSalesByContentItem(): CumulativeSalesByContentItem {
val orderTypeStr = if (orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
return CumulativeSalesByContentItem(
nickname = nickname,
title = title,
registrationDate = registrationDate,
orderType = orderTypeStr,
orderPrice = orderPrice,
numberOfPeople = numberOfPeople.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
}
)
data class GetCumulativeSalesByContentResponse(
@JsonProperty("totalCount") val totalCount: Int,

View File

@ -31,7 +31,17 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac
endDate: LocalDateTime,
memberId: Long
): List<GetCalculateLiveQueryData> {
val formattedDate = getFormattedDate(liveRoom.beginDateTime)
val formattedDate = Expressions.stringTemplate(
"DATE_FORMAT({0}, {1})",
Expressions.dateTimeTemplate(
LocalDateTime::class.java,
"CONVERT_TZ({0},{1},{2})",
liveRoom.beginDateTime,
"UTC",
"Asia/Seoul"
),
"%Y-%m-%d"
)
return queryFactory
.select(

View File

@ -1,12 +1,21 @@
package kr.co.vividnext.sodalive.creator.admin.calculate
import kr.co.vividnext.sodalive.admin.calculate.CumulativeSalesByContentItem
import kr.co.vividnext.sodalive.admin.calculate.GetCalculateCommunityPostResponse
import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentDonationResponse
import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentResponse
import kr.co.vividnext.sodalive.admin.calculate.GetCalculateLiveResponse
import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentResponse
import kr.co.vividnext.sodalive.extensions.convertLocalDateTime
import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.content.order.OrderType
import kr.co.vividnext.sodalive.member.Member
import org.springframework.cache.annotation.Cacheable
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDate
import java.time.ZoneId
import java.time.format.DateTimeFormatter
import kotlin.math.roundToInt
@Service
class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) {
@ -16,12 +25,73 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
key = "'creatorCalculateLive:v20240403_01:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr"
)
fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
return repository
.getCalculateLive(startDate, endDate, member.id!!)
.map { it.toGetCalculateLiveResponse() }
.asSequence()
.map {
val canUsageStr = when (it.canUsage) {
CanUsage.LIVE -> {
"유료"
}
CanUsage.SPIN_ROULETTE -> {
"룰렛"
}
else -> {
"후원"
}
}
val numberOfPeople = if (it.canUsage == CanUsage.LIVE) {
it.memberCount.toInt()
} else {
0
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalAmount * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateLiveResponse(
email = it.email,
nickname = it.nickname,
date = it.date,
title = it.title,
entranceFee = it.entranceFee,
canUsageStr = canUsageStr,
numberOfPeople = numberOfPeople,
totalAmount = it.totalAmount,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
}
@Transactional(readOnly = true)
@ -37,12 +107,59 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
offset: Long,
limit: Long
): GetCalculateContentListResponse {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val totalCount = repository.getCalculateContentListTotalCount(startDate, endDate, memberId)
val items = repository.getCalculateContentList(startDate, endDate, memberId, offset, limit)
.map { it.toGetCalculateContentResponse() }
.asSequence()
.map {
val orderTypeStr = if (it.orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateContentResponse(
nickname = it.nickname,
title = it.title,
registrationDate = it.registrationDate,
saleDate = it.saleDate,
orderType = orderTypeStr,
orderPrice = it.orderPrice,
numberOfPeople = it.numberOfPeople.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
return GetCalculateContentListResponse(totalCount, items)
}
@ -56,7 +173,45 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
val totalCount = repository.getCumulativeSalesByContentTotalCount(memberId)
val items = repository
.getCumulativeSalesByContent(memberId, offset, limit)
.map { it.toCumulativeSalesByContentItem() }
.asSequence()
.map {
val orderTypeStr = if (it.orderType == OrderType.RENTAL) {
"대여"
} else {
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
CumulativeSalesByContentItem(
nickname = it.nickname,
title = it.title,
registrationDate = it.registrationDate,
orderType = orderTypeStr,
orderPrice = it.orderPrice,
numberOfPeople = it.numberOfPeople.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
return GetCumulativeSalesByContentResponse(totalCount, items)
}
@ -74,23 +229,67 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
offset: Long,
limit: Long
): GetCreatorCalculateContentDonationResponse {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val totalCount = repository.getCalculateContentDonationListTotalCount(startDate, endDate, memberId)
val items = repository
.getCalculateContentDonationList(startDate, endDate, memberId, offset, limit)
.map { it.toGetCalculateContentDonationResponse() }
.asSequence()
.map {
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = it.totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액
// 유료콘텐츠 (원화 - 결제수수료) 의 90%
// 무료콘텐츠 (원화 - 결제수수료) 의 70%
val settlementAmount = if (it.price > 0) {
(totalKrw.toFloat() - paymentFee) * 0.9
} else {
(totalKrw.toFloat() - paymentFee) * 0.7
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val depositAmount = settlementAmount - tax
GetCalculateContentDonationResponse(
nickname = it.nickname,
title = it.title,
paidOrFree = if (it.price > 0) {
"유료"
} else {
"무료"
},
registrationDate = it.registrationDate,
donationDate = it.donationDate,
numberOfDonation = it.numberOfDonation.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
.toList()
return GetCreatorCalculateContentDonationResponse(totalCount, items)
}
@Transactional(readOnly = true)
@Cacheable(
cacheNames = ["cache_ttl_3_hours"],
key = "'creatorCalculateCommunityPost:' + " +
"#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit"
)
fun getCalculateCommunityPost(
startDateStr: String,
endDateStr: String,
@ -98,13 +297,40 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
offset: Long,
limit: Long
): GetCreatorCalculateCommunityPostResponse {
val startDate = startDateStr.convertLocalDateTime()
val endDate = endDateStr.convertLocalDateTime(hour = 23, minute = 59, second = 59)
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.atZone(ZoneId.of("Asia/Seoul"))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
val totalCount = repository.getCalculateCommunityPostTotalCount(startDate, endDate, memberId)
val items = repository
.getCalculateCommunityPostList(startDate, endDate, memberId, offset, limit)
.map { it.toGetCalculateCommunityPostResponse() }
.map {
val totalKrw = it.totalCan * 100
val paymentFee = totalKrw * 0.066f
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
val tax = settlementAmount * 0.033
val depositAmount = settlementAmount - tax
GetCalculateCommunityPostResponse(
nickname = it.nickname,
title = it.title,
date = it.date,
numberOfPurchase = it.numberOfPurchase.toInt(),
totalCan = it.totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
)
}
return GetCreatorCalculateCommunityPostResponse(totalCount, items)
}

View File

@ -1,26 +1,9 @@
package kr.co.vividnext.sodalive.extensions
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter
fun String.convertLocalDateTime(format: String): LocalDateTime {
val dateTimeFormatter = DateTimeFormatter.ofPattern(format)
return LocalDateTime.parse(this, dateTimeFormatter)
}
fun String.convertLocalDateTime(
format: String = "yyyy-MM-dd",
currentTimeZoneStr: String = "Asia/Seoul",
hour: Int = 0,
minute: Int = 0,
second: Int = 0
): LocalDateTime {
val dateTimeFormatter = DateTimeFormatter.ofPattern(format)
return LocalDate.parse(this, dateTimeFormatter)
.atTime(hour, minute, second)
.atZone(ZoneId.of(currentTimeZoneStr))
.withZoneSameInstant(ZoneId.of("UTC"))
.toLocalDateTime()
}