diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/can/AdminCanRequest.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/can/AdminCanRequest.kt index 5fa6811..597f5b9 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/can/AdminCanRequest.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/can/AdminCanRequest.kt @@ -3,11 +3,12 @@ package kr.co.vividnext.sodalive.admin.can import kr.co.vividnext.sodalive.can.Can import kr.co.vividnext.sodalive.can.CanStatus import kr.co.vividnext.sodalive.extensions.moneyFormat +import java.math.BigDecimal data class AdminCanRequest( val can: Int, val rewardCan: Int, - val price: Double + val price: BigDecimal ) { fun toEntity(): Can { var title = "${can.moneyFormat()} 캔" diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt index 345ba64..cc6d4ca 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/AdminChargeStatusService.kt @@ -20,11 +20,10 @@ class AdminChargeStatusService(val repository: AdminChargeStatusQueryRepository) .withZoneSameInstant(ZoneId.of("UTC")) .toLocalDateTime() - var totalChargeAmount = 0.toDouble() + var totalChargeAmount = 0.toBigDecimal() var totalChargeCount = 0L val chargeStatusList = repository.getChargeStatus(startDate, endDate) - .asSequence() .map { val chargeAmount = if (it.paymentGateWay == PaymentGateway.PG) { it.pgChargeAmount diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusDetailQueryDto.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusDetailQueryDto.kt index fe28627..3164e91 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusDetailQueryDto.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusDetailQueryDto.kt @@ -1,13 +1,14 @@ package kr.co.vividnext.sodalive.admin.charge import com.querydsl.core.annotations.QueryProjection +import java.math.BigDecimal data class GetChargeStatusDetailQueryDto @QueryProjection constructor( val memberId: Long, val nickname: String, val method: String, - val appleChargeAmount: Double, - val pgChargeAmount: Double, + val appleChargeAmount: BigDecimal, + val pgChargeAmount: BigDecimal, val locale: String, val datetime: String ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt index 53c581f..5d4c6a4 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusQueryDto.kt @@ -2,11 +2,12 @@ package kr.co.vividnext.sodalive.admin.charge import com.querydsl.core.annotations.QueryProjection import kr.co.vividnext.sodalive.can.payment.PaymentGateway +import java.math.BigDecimal data class GetChargeStatusQueryDto @QueryProjection constructor( val date: String, - val appleChargeAmount: Double, - val pgChargeAmount: Double, + val appleChargeAmount: BigDecimal, + val pgChargeAmount: BigDecimal, val chargeCount: Long, val paymentGateWay: PaymentGateway ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt index e532b23..75dffcb 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/charge/GetChargeStatusResponse.kt @@ -1,8 +1,10 @@ package kr.co.vividnext.sodalive.admin.charge +import java.math.BigDecimal + data class GetChargeStatusResponse( val date: String, - val chargeAmount: Double, + val chargeAmount: BigDecimal, val chargeCount: Long, val pg: String ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/AdminAdStatisticsRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/AdminAdStatisticsRepository.kt index 4485152..f7f55ce 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/AdminAdStatisticsRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/AdminAdStatisticsRepository.kt @@ -3,7 +3,6 @@ package kr.co.vividnext.sodalive.admin.statistics.ad import com.querydsl.core.types.dsl.CaseBuilder import com.querydsl.core.types.dsl.DateTimePath import com.querydsl.core.types.dsl.Expressions -import com.querydsl.core.types.dsl.NumberExpression import com.querydsl.core.types.dsl.StringTemplate import com.querydsl.jpa.impl.JPAQueryFactory import kr.co.vividnext.sodalive.marketing.AdTrackingHistoryType @@ -67,7 +66,7 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) { val firstPaymentTotalAmount = CaseBuilder() .`when`(adTrackingHistory.type.eq(AdTrackingHistoryType.FIRST_PAYMENT)) .then(adTrackingHistory.price) - .otherwise(Expressions.constant(0.0)) + .otherwise(0.toBigDecimal()) .sum() val repeatPaymentCount = CaseBuilder() @@ -79,7 +78,7 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) { val repeatPaymentTotalAmount = CaseBuilder() .`when`(adTrackingHistory.type.eq(AdTrackingHistoryType.REPEAT_PAYMENT)) .then(adTrackingHistory.price) - .otherwise(Expressions.constant(0.0)) + .otherwise(0.toBigDecimal()) .sum() val allPaymentCount = CaseBuilder() @@ -97,7 +96,7 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) { .or(adTrackingHistory.type.eq(AdTrackingHistoryType.REPEAT_PAYMENT)) ) .then(adTrackingHistory.price) - .otherwise(Expressions.constant(0.0)) + .otherwise(0.toBigDecimal()) .sum() return queryFactory @@ -111,11 +110,11 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) { loginCount, signUpCount, firstPaymentCount, - roundedValueDecimalPlaces2(firstPaymentTotalAmount), + firstPaymentTotalAmount, repeatPaymentCount, - roundedValueDecimalPlaces2(repeatPaymentTotalAmount), + repeatPaymentTotalAmount, allPaymentCount, - roundedValueDecimalPlaces2(allPaymentTotalAmount) + allPaymentTotalAmount ) ) .from(adTrackingHistory) @@ -148,13 +147,4 @@ class AdminAdStatisticsRepository(private val queryFactory: JPAQueryFactory) { "%Y-%m-%d" ) } - - private fun roundedValueDecimalPlaces2(valueExpression: NumberExpression): NumberExpression { - return Expressions.numberTemplate( - Double::class.java, - "ROUND({0}, {1})", - valueExpression, - 2 - ) - } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/GetAdminAdStatisticsResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/GetAdminAdStatisticsResponse.kt index 2c9627b..b968e3e 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/GetAdminAdStatisticsResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/admin/statistics/ad/GetAdminAdStatisticsResponse.kt @@ -1,6 +1,7 @@ package kr.co.vividnext.sodalive.admin.statistics.ad import com.querydsl.core.annotations.QueryProjection +import java.math.BigDecimal data class GetAdminAdStatisticsResponse( val totalCount: Int, @@ -16,9 +17,9 @@ data class GetAdminAdStatisticsItem @QueryProjection constructor( val loginCount: Int, val signUpCount: Int, val firstPaymentCount: Int, - val firstPaymentTotalAmount: Double, + val firstPaymentTotalAmount: BigDecimal, val repeatPaymentCount: Int, - val repeatPaymentTotalAmount: Double, + val repeatPaymentTotalAmount: BigDecimal, val allPaymentCount: Int, - val allPaymentTotalAmount: Double + val allPaymentTotalAmount: BigDecimal ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/Can.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/Can.kt index 64f5f3c..11528c6 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/Can.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/Can.kt @@ -1,6 +1,7 @@ package kr.co.vividnext.sodalive.can import kr.co.vividnext.sodalive.common.BaseEntity +import java.math.BigDecimal import javax.persistence.Entity import javax.persistence.EnumType import javax.persistence.Enumerated @@ -10,7 +11,7 @@ data class Can( var title: String, var can: Int, var rewardCan: Int, - var price: Double, + var price: BigDecimal, @Enumerated(value = EnumType.STRING) var status: CanStatus ) : BaseEntity() diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanResponse.kt index f655f13..37eb80d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/CanResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/CanResponse.kt @@ -1,11 +1,12 @@ package kr.co.vividnext.sodalive.can import com.querydsl.core.annotations.QueryProjection +import java.math.BigDecimal data class CanResponse @QueryProjection constructor( val id: Long, val title: String, val can: Int, val rewardCan: Int, - val price: Double + val price: BigDecimal ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeCompleteResponse.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeCompleteResponse.kt index 066cd8f..8083f13 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeCompleteResponse.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeCompleteResponse.kt @@ -1,7 +1,9 @@ package kr.co.vividnext.sodalive.can.charge +import java.math.BigDecimal + data class ChargeCompleteResponse( - val price: Double, + val price: BigDecimal, val currencyCode: String, val isFirstCharged: Boolean ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt index acb2493..73948f3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt @@ -168,8 +168,7 @@ class ChargeController( memberId = member.id!!, chargeId = chargeId, productId = request.productId, - purchaseToken = request.purchaseToken, - paymentGateway = request.paymentGateway + purchaseToken = request.purchaseToken ) trackingCharge(member, response) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeData.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeData.kt index a6785c4..f2b159c 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeData.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeData.kt @@ -21,14 +21,14 @@ data class VerifyResult( val method: String, val pg: String, val status: Int, - val price: Double + val price: BigDecimal ) data class AppleChargeRequest( val title: String, val chargeCan: Int, val paymentGateway: PaymentGateway, - var price: Double? = null, + var price: BigDecimal? = null, var locale: String? = null ) @@ -39,7 +39,7 @@ data class AppleVerifyResponse(val status: Int) data class GoogleChargeRequest( val title: String, val chargeCan: Int, - val price: Double, + val price: BigDecimal, val currencyCode: String, val productId: String, val purchaseToken: String, diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt index 271f11b..73beb86 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt @@ -33,7 +33,6 @@ import org.springframework.retry.annotation.Retryable import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.math.BigDecimal -import java.math.RoundingMode import java.time.LocalDateTime import java.time.format.DateTimeFormatter @@ -106,7 +105,7 @@ class ChargeService( ) val isAmountMatch = request.requestAmount.compareTo( - BigDecimal.valueOf(charge.payment!!.price) + charge.payment!!.price ) == 0 val isSuccess = request.resultStatus == "SUCCESS" && @@ -225,13 +224,13 @@ class ChargeService( charge.can = can val payment = Payment(paymentGateway = PaymentGateway.PAYVERSE) - payment.price = can.price.toDouble() + payment.price = can.price charge.payment = payment val savedCharge = chargeRepository.save(charge) val chargeId = savedCharge.id!! - val amount = BigDecimal(savedCharge.payment!!.price) + val amount = savedCharge.payment!!.price val reqDate = savedCharge.createdAt!!.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")) val sign = DigestUtils.sha512Hex( String.format("||%s||%s||%s||%s||%s||", payverseSecretKey, payverseMid, chargeId, amount, reqDate) @@ -315,7 +314,7 @@ class ChargeService( ) return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) @@ -330,7 +329,7 @@ class ChargeService( PaymentStatus.COMPLETE -> { // 이미 결제가 완료된 경우, 동일한 데이터로 즉시 반환 return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) @@ -353,7 +352,7 @@ class ChargeService( charge.can = can val payment = Payment(paymentGateway = request.paymentGateway) - payment.price = can.price.toDouble() + payment.price = can.price charge.payment = payment chargeRepository.save(charge) @@ -392,7 +391,7 @@ class ChargeService( ) return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) @@ -442,7 +441,7 @@ class ChargeService( ) return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) @@ -467,7 +466,7 @@ class ChargeService( payment.price = if (request.price != null) { request.price!! } else { - 0.toDouble() + 0.toBigDecimal() } payment.locale = request.locale @@ -502,7 +501,7 @@ class ChargeService( ) return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) @@ -519,7 +518,7 @@ class ChargeService( member: Member, title: String, chargeCan: Int, - price: Double, + price: BigDecimal, currencyCode: String, productId: String, purchaseToken: String, @@ -547,8 +546,7 @@ class ChargeService( memberId: Long, chargeId: Long, productId: String, - purchaseToken: String, - paymentGateway: PaymentGateway + purchaseToken: String ): ChargeCompleteResponse { val charge = chargeRepository.findByIdOrNull(id = chargeId) ?: throw SodaException("결제정보에 오류가 있습니다.") @@ -570,7 +568,7 @@ class ChargeService( ) return ChargeCompleteResponse( - price = BigDecimal(charge.payment!!.price).setScale(2, RoundingMode.HALF_UP).toDouble(), + price = charge.payment!!.price, currencyCode = charge.payment!!.locale?.takeLast(3) ?: "KRW", isFirstCharged = chargeRepository.isFirstCharged(memberId) ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempRequest.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempRequest.kt index d24f907..5afdfa8 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempRequest.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempRequest.kt @@ -1,9 +1,10 @@ package kr.co.vividnext.sodalive.can.charge.temp import kr.co.vividnext.sodalive.can.payment.PaymentGateway +import java.math.BigDecimal data class ChargeTempRequest( val can: Int, - val price: Int, + val price: BigDecimal, val paymentGateway: PaymentGateway ) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt index c94dc7d..3f2f1aa 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt @@ -41,7 +41,7 @@ class ChargeTempService( charge.member = member val payment = Payment(paymentGateway = request.paymentGateway) - payment.price = request.price.toDouble() + payment.price = request.price charge.payment = payment chargeRepository.save(charge) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/payment/Payment.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/payment/Payment.kt index 2c0c527..cc18f08 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/payment/Payment.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/payment/Payment.kt @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.can.payment import kr.co.vividnext.sodalive.can.charge.Charge import kr.co.vividnext.sodalive.common.BaseEntity +import java.math.BigDecimal import javax.persistence.Column import javax.persistence.Entity import javax.persistence.EnumType @@ -25,7 +26,7 @@ data class Payment( var receiptId: String? = null var method: String? = null - var price: Double = 0.toDouble() + var price: BigDecimal = 0.toBigDecimal() var locale: String? = null var orderId: String? = null } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingHistory.kt b/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingHistory.kt index ee5615f..51b6a11 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingHistory.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingHistory.kt @@ -1,5 +1,6 @@ package kr.co.vividnext.sodalive.marketing +import java.math.BigDecimal import java.time.LocalDateTime import javax.persistence.Entity import javax.persistence.EnumType @@ -19,7 +20,7 @@ data class AdTrackingHistory( val pidName: String, @Enumerated(value = EnumType.STRING) val type: AdTrackingHistoryType, - val price: Double = 0.toDouble(), + val price: BigDecimal = 0.toBigDecimal(), val locale: String? = null, val memberId: Long, val createdAt: LocalDateTime = LocalDateTime.now(), diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingService.kt index 99b6c9b..538b8db 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/marketing/AdTrackingService.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.springframework.stereotype.Service +import java.math.BigDecimal @Service class AdTrackingService( @@ -17,7 +18,7 @@ class AdTrackingService( pid: String, type: AdTrackingHistoryType, memberId: Long, - price: Double? = null, + price: BigDecimal? = null, locale: String? = null ) { coroutineScope.launch { @@ -30,7 +31,7 @@ class AdTrackingService( pid = pid, pidName = mediaPartner.pidName, type = type, - price = price ?: 0.toDouble(), + price = price ?: 0.toBigDecimal(), locale = locale, memberId = memberId )