fix: 캔 가격, Payment의 price 타입 Int, Double -> BigDecimal로 변경

This commit is contained in:
2025-10-01 20:37:53 +09:00
parent 78ff13a654
commit 0c17ea2dcd
18 changed files with 56 additions and 56 deletions

View File

@@ -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()}"

View File

@@ -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

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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<Double>): NumberExpression<Double> {
return Expressions.numberTemplate(
Double::class.java,
"ROUND({0}, {1})",
valueExpression,
2
)
}
}

View File

@@ -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
)

View File

@@ -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()

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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)

View File

@@ -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,

View File

@@ -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)
)

View File

@@ -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
)

View File

@@ -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)

View File

@@ -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
}

View File

@@ -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(),

View File

@@ -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
)