Merge pull request 'test' (#159) from test into main

Reviewed-on: #159
This commit is contained in:
klaus 2024-04-03 06:27:26 +00:00
commit 1d8d1ec9a5
2 changed files with 126 additions and 131 deletions

View File

@ -60,6 +60,7 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac
useCan.isRefund.isFalse useCan.isRefund.isFalse
.and(liveRoom.beginDateTime.goe(startDate)) .and(liveRoom.beginDateTime.goe(startDate))
.and(liveRoom.beginDateTime.loe(endDate)) .and(liveRoom.beginDateTime.loe(endDate))
.and(liveRoom.member.id.eq(memberId))
) )
.groupBy(liveRoom.id, useCan.canUsage) .groupBy(liveRoom.id, useCan.canUsage)
.orderBy(liveRoom.id.desc(), useCan.canUsage.desc(), formattedDate.desc()) .orderBy(liveRoom.id.desc(), useCan.canUsage.desc(), formattedDate.desc())

View File

@ -2,10 +2,9 @@ package kr.co.vividnext.sodalive.creator.admin.calculate
import kr.co.vividnext.sodalive.admin.calculate.CumulativeSalesByContentItem import kr.co.vividnext.sodalive.admin.calculate.CumulativeSalesByContentItem
import kr.co.vividnext.sodalive.admin.calculate.GetCalculateContentDonationResponse 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.GetCalculateLiveResponse
import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentResponse import kr.co.vividnext.sodalive.admin.calculate.GetCumulativeSalesByContentResponse
import kr.co.vividnext.sodalive.can.use.CanUsage import kr.co.vividnext.sodalive.common.SodaException
import kr.co.vividnext.sodalive.content.order.OrderType import kr.co.vividnext.sodalive.content.order.OrderType
import kr.co.vividnext.sodalive.member.Member import kr.co.vividnext.sodalive.member.Member
import org.springframework.cache.annotation.Cacheable import org.springframework.cache.annotation.Cacheable
@ -19,86 +18,80 @@ import kotlin.math.roundToInt
@Service @Service
class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) { class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) {
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(
cacheNames = ["default"],
key = "'creatorCalculateLive:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr"
)
fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> { fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List<GetCalculateLiveResponse> {
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") throw SodaException("점검중입니다.")
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) // val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
.atZone(ZoneId.of("Asia/Seoul")) // val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.withZoneSameInstant(ZoneId.of("UTC")) // .atZone(ZoneId.of("Asia/Seoul"))
.toLocalDateTime() // .withZoneSameInstant(ZoneId.of("UTC"))
// .toLocalDateTime()
return repository //
.getCalculateLive(startDate, endDate, member.id!!) // val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59)
.asSequence() // .atZone(ZoneId.of("Asia/Seoul"))
.map { // .withZoneSameInstant(ZoneId.of("UTC"))
val canUsageStr = when (it.canUsage) { // .toLocalDateTime()
CanUsage.LIVE -> { //
"유료" // return repository
} // .getCalculateLive(startDate, endDate, member.id!!)
// .asSequence()
CanUsage.SPIN_ROULETTE -> { // .map {
"룰렛" // val canUsageStr = when (it.canUsage) {
} // CanUsage.LIVE -> {
// "유료"
else -> { // }
"후원" //
} // CanUsage.SPIN_ROULETTE -> {
} // "룰렛"
// }
val numberOfPeople = if (it.canUsage == CanUsage.LIVE) { //
it.memberCount.toInt() // else -> {
} else { // "후원"
0 // }
} // }
//
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 ) // val numberOfPeople = if (it.canUsage == CanUsage.LIVE) {
val totalKrw = it.totalAmount * 100 // it.memberCount.toInt()
// } else {
// 결제수수료 : 6.6% // 0
val paymentFee = totalKrw * 0.066f // }
//
// 정산금액 = (원화 - 결제수수료) 의 70% // // 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7 // val totalKrw = it.totalAmount * 100
//
// 원천세 = 정산금액의 3.3% // // 결제수수료 : 6.6%
val tax = settlementAmount * 0.033 // val paymentFee = totalKrw * 0.066f
//
// 입금액 // // 정산금액 = (원화 - 결제수수료) 의 70%
val depositAmount = settlementAmount - tax // val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
//
GetCalculateLiveResponse( // // 원천세 = 정산금액의 3.3%
email = it.email, // val tax = settlementAmount * 0.033
nickname = it.nickname, //
date = it.date, // // 입금액
title = it.title, // val depositAmount = settlementAmount - tax
entranceFee = it.entranceFee, //
canUsageStr = canUsageStr, // GetCalculateLiveResponse(
numberOfPeople = numberOfPeople, // email = it.email,
totalAmount = it.totalAmount, // nickname = it.nickname,
totalKrw = totalKrw, // date = it.date,
paymentFee = paymentFee.roundToInt(), // title = it.title,
settlementAmount = settlementAmount.roundToInt(), // entranceFee = it.entranceFee,
tax = tax.roundToInt(), // canUsageStr = canUsageStr,
depositAmount = depositAmount.roundToInt() // numberOfPeople = numberOfPeople,
) // totalAmount = it.totalAmount,
} // totalKrw = totalKrw,
.toList() // paymentFee = paymentFee.roundToInt(),
// settlementAmount = settlementAmount.roundToInt(),
// tax = tax.roundToInt(),
// depositAmount = depositAmount.roundToInt()
// )
// }
// .toList()
return listOf()
} }
@Transactional(readOnly = true) @Transactional(readOnly = true)
@Cacheable(
cacheNames = ["cache_ttl_3_hours"],
key = "'creatorCalculateContentList:' + " +
"#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit"
)
fun getCalculateContentList( fun getCalculateContentList(
startDateStr: String, startDateStr: String,
endDateStr: String, endDateStr: String,
@ -106,61 +99,62 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate
offset: Long, offset: Long,
limit: Long limit: Long
): GetCalculateContentListResponse { ): GetCalculateContentListResponse {
val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") throw SodaException("점검중입니다.")
val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) // val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
.atZone(ZoneId.of("Asia/Seoul")) // val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0)
.withZoneSameInstant(ZoneId.of("UTC")) // .atZone(ZoneId.of("Asia/Seoul"))
.toLocalDateTime() // .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)
// .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()
val endDate = LocalDate.parse(endDateStr, dateTimeFormatter).atTime(23, 59, 59) return GetCalculateContentListResponse(0, listOf())
.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)
.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)
} }
@Transactional(readOnly = true) @Transactional(readOnly = true)