fix: 캔 가격, Payment의 price 타입 Int, Double -> BigDecimal로 변경
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user