Merge pull request '.' (#160) from test into main

Reviewed-on: #160
This commit is contained in:
klaus 2024-04-03 06:49:36 +00:00
commit d693c397ea
1 changed files with 131 additions and 125 deletions

View File

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