From 3b59d6c5469ad46bb0e8a4a98f46d3a87b778691 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 3 Apr 2024 15:08:48 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EA=B4=80=EB=A6=AC=EC=9E=90=20=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EB=B8=8C=20=EC=A0=95=EC=82=B0=20-=20=EB=B3=B8=EC=9D=B8=20?= =?UTF-8?q?=EA=B2=83=20=EC=99=B8=EC=97=90=20=EB=B3=B4=EC=9D=B4=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/calculate/CreatorAdminCalculateQueryRepository.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateQueryRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateQueryRepository.kt index ef91a4f..40b83c0 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateQueryRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateQueryRepository.kt @@ -60,6 +60,7 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac useCan.isRefund.isFalse .and(liveRoom.beginDateTime.goe(startDate)) .and(liveRoom.beginDateTime.loe(endDate)) + .and(liveRoom.member.id.eq(memberId)) ) .groupBy(liveRoom.id, useCan.canUsage) .orderBy(liveRoom.id.desc(), useCan.canUsage.desc(), formattedDate.desc()) -- 2.40.1 From 8d185c274a6ddaaef6f7c1b34a9eb2f747494a05 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 3 Apr 2024 15:15:50 +0900 Subject: [PATCH 2/3] test --- .../creator/admin/calculate/CreatorAdminCalculateService.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt index 46901ec..96e0df9 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt @@ -6,6 +6,7 @@ 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.can.use.CanUsage +import kr.co.vividnext.sodalive.common.SodaException import kr.co.vividnext.sodalive.content.order.OrderType import kr.co.vividnext.sodalive.member.Member import org.springframework.cache.annotation.Cacheable @@ -24,6 +25,8 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate key = "'creatorCalculateLive:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr" ) fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List { + throw SodaException("점검중입니다.") + val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) .atZone(ZoneId.of("Asia/Seoul")) @@ -106,6 +109,8 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate offset: Long, limit: Long ): GetCalculateContentListResponse { + throw SodaException("점검중입니다.") + val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd") val startDate = LocalDate.parse(startDateStr, dateTimeFormatter).atTime(0, 0, 0) .atZone(ZoneId.of("Asia/Seoul")) -- 2.40.1 From aad4f8dbb59cba560e7bb07c90f5c5a10f4a0ac3 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 3 Apr 2024 15:22:56 +0900 Subject: [PATCH 3/3] test --- .../calculate/CreatorAdminCalculateService.kt | 255 +++++++++--------- 1 file changed, 122 insertions(+), 133 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt index 96e0df9..c83eafa 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/creator/admin/calculate/CreatorAdminCalculateService.kt @@ -2,10 +2,8 @@ package kr.co.vividnext.sodalive.creator.admin.calculate import kr.co.vividnext.sodalive.admin.calculate.CumulativeSalesByContentItem 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.can.use.CanUsage import kr.co.vividnext.sodalive.common.SodaException import kr.co.vividnext.sodalive.content.order.OrderType import kr.co.vividnext.sodalive.member.Member @@ -20,88 +18,80 @@ import kotlin.math.roundToInt @Service class CreatorAdminCalculateService(private val repository: CreatorAdminCalculateQueryRepository) { @Transactional(readOnly = true) - @Cacheable( - cacheNames = ["default"], - key = "'creatorCalculateLive:' + " + "#member + ':' + #startDateStr + ':' + #endDateStr" - ) fun getCalculateLive(startDateStr: String, endDateStr: String, member: Member): List { 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 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!!) - .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() +// 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!!) +// .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() + return listOf() } @Transactional(readOnly = true) - @Cacheable( - cacheNames = ["cache_ttl_3_hours"], - key = "'creatorCalculateContentList:' + " + - "#startDateStr + ':' + #endDateStr + ':' + #memberId + ':' + #offset + ':' + #limit" - ) fun getCalculateContentList( startDateStr: String, endDateStr: String, @@ -110,62 +100,61 @@ class CreatorAdminCalculateService(private val repository: CreatorAdminCalculate limit: Long ): GetCalculateContentListResponse { 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 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 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) - .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) + return GetCalculateContentListResponse(0, listOf()) } @Transactional(readOnly = true) -- 2.40.1