일자별 콘텐츠 정산, 콘텐츠별 누적 현황, 후원정산, 커뮤니티 정산

- float 대신 bigdecimal로 변경
This commit is contained in:
Klaus 2024-07-02 16:47:31 +09:00
parent fded23b97d
commit 2c77143fc2
7 changed files with 68 additions and 60 deletions

View File

@ -122,12 +122,15 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
order.type,
order.can,
order.id.count(),
order.can.sum()
order.can.sum(),
creatorSettlementRatio.contentSettlementRatio
)
)
.from(order)
.innerJoin(order.audioContent, audioContent)
.innerJoin(audioContent.member, member)
.leftJoin(creatorSettlementRatio)
.on(member.id.eq(creatorSettlementRatio.member.id))
.where(order.isActive.isTrue)
.groupBy(member.id, audioContent.id, order.type, order.can)
.offset(offset)

View File

@ -1,7 +1,8 @@
package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kotlin.math.roundToInt
import java.math.BigDecimal
import java.math.RoundingMode
data class GetCalculateCommunityPostQueryData @QueryProjection constructor(
val nickname: String,
@ -13,14 +14,14 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor(
val settlementRatio: Int?
) {
fun toGetCalculateCommunityPostResponse(): GetCalculateCommunityPostResponse {
val totalKrw = totalCan * 100
val paymentFee = totalKrw * 0.066f
val totalKrw = BigDecimal(totalCan) * BigDecimal(100)
val paymentFee = totalKrw * BigDecimal(0.066)
val settlementAmount = if (settlementRatio != null) {
(totalKrw.toFloat() - paymentFee) * (settlementRatio.toFloat() / 100.0f)
(totalKrw - paymentFee) * (BigDecimal(settlementRatio) / BigDecimal(100.0))
} else {
(totalKrw.toFloat() - paymentFee) * 0.7f
(totalKrw - paymentFee) * BigDecimal(0.7)
}
val tax = settlementAmount * 0.033
val tax = settlementAmount * BigDecimal(0.033)
val depositAmount = settlementAmount - tax
return GetCalculateCommunityPostResponse(
@ -30,11 +31,11 @@ data class GetCalculateCommunityPostQueryData @QueryProjection constructor(
can = can,
numberOfPurchase = numberOfPurchase.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
totalKrw = totalKrw.toInt(),
paymentFee = paymentFee.setScale(0, RoundingMode.HALF_UP).toInt(),
settlementAmount = settlementAmount.setScale(0, RoundingMode.HALF_UP).toInt(),
tax = tax.setScale(0, RoundingMode.HALF_UP).toInt(),
depositAmount = depositAmount.setScale(0, RoundingMode.HALF_UP).toInt()
)
}
}

View File

@ -1,7 +1,8 @@
package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kotlin.math.roundToInt
import java.math.BigDecimal
import java.math.RoundingMode
data class GetCalculateContentDonationQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -21,22 +22,22 @@ data class GetCalculateContentDonationQueryData @QueryProjection constructor(
) {
fun toGetCalculateContentDonationResponse(): GetCalculateContentDonationResponse {
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
val totalKrw = BigDecimal(totalCan) * BigDecimal(100)
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
val paymentFee = totalKrw * BigDecimal(0.066)
// 정산금액
// 유료콘텐츠 (원화 - 결제수수료) 의 90%
// 무료콘텐츠 (원화 - 결제수수료) 의 70%
val settlementAmount = if (price > 0) {
(totalKrw.toFloat() - paymentFee) * 0.9
(totalKrw - paymentFee) * BigDecimal(0.9)
} else {
(totalKrw.toFloat() - paymentFee) * 0.7
(totalKrw - paymentFee) * BigDecimal(0.7)
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
val tax = settlementAmount * BigDecimal(0.033)
// 입금액
val depositAmount = settlementAmount - tax
@ -55,11 +56,11 @@ data class GetCalculateContentDonationQueryData @QueryProjection constructor(
donationDate = donationDate,
numberOfDonation = numberOfDonation.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
totalKrw = totalKrw.toInt(),
paymentFee = paymentFee.setScale(0, RoundingMode.HALF_UP).toInt(),
settlementAmount = settlementAmount.setScale(0, RoundingMode.HALF_UP).toInt(),
tax = tax.setScale(0, RoundingMode.HALF_UP).toInt(),
depositAmount = depositAmount.setScale(0, RoundingMode.HALF_UP).toInt()
)
}
}

View File

@ -2,7 +2,8 @@ package kr.co.vividnext.sodalive.admin.calculate
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.content.order.OrderType
import kotlin.math.roundToInt
import java.math.BigDecimal
import java.math.RoundingMode
data class GetCalculateContentQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -31,23 +32,14 @@ data class GetCalculateContentQueryData @QueryProjection constructor(
"소장"
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
// 정산금액 = (원화 - 결제수수료) 의 70%
val totalKrw = BigDecimal(totalCan) * BigDecimal(100)
val paymentFee = totalKrw * BigDecimal(0.066)
val settlementAmount = if (settlementRatio != null) {
(totalKrw.toFloat() - paymentFee) * (settlementRatio.toFloat() / 100.0f)
(totalKrw - paymentFee) * (BigDecimal(settlementRatio) / BigDecimal(100.0))
} else {
(totalKrw.toFloat() - paymentFee) * 0.7f
(totalKrw - paymentFee) * BigDecimal(0.7)
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
// 입금액
val tax = settlementAmount * BigDecimal(0.033)
val depositAmount = settlementAmount - tax
return GetCalculateContentResponse(
@ -59,11 +51,11 @@ data class GetCalculateContentQueryData @QueryProjection constructor(
orderPrice = orderPrice,
numberOfPeople = numberOfPeople.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
totalKrw = totalKrw.toInt(),
paymentFee = paymentFee.setScale(0, RoundingMode.HALF_UP).toInt(),
settlementAmount = settlementAmount.setScale(0, RoundingMode.HALF_UP).toInt(),
tax = tax.setScale(0, RoundingMode.HALF_UP).toInt(),
depositAmount = depositAmount.setScale(0, RoundingMode.HALF_UP).toInt()
)
}
}

View File

@ -43,20 +43,20 @@ data class GetCalculateLiveQueryData @QueryProjection constructor(
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = BigDecimal(totalAmount).multiply(BigDecimal(100))
val totalKrw = BigDecimal(totalAmount) * BigDecimal(100)
// 결제수수료 : 6.6%
val paymentFee = totalKrw.multiply(BigDecimal(0.066))
val paymentFee = totalKrw * BigDecimal(0.066)
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = if (settlementRatio != null) {
totalKrw.subtract(paymentFee).multiply(BigDecimal(settlementRatio).divide(BigDecimal(100)))
(totalKrw - paymentFee) * (BigDecimal(settlementRatio) / BigDecimal(100.0))
} else {
totalKrw.subtract(paymentFee).multiply(BigDecimal(0.7))
(totalKrw - paymentFee) * BigDecimal(0.7)
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount.multiply(BigDecimal(0.033))
val tax = settlementAmount * BigDecimal(0.033)
// 입금액
val depositAmount = settlementAmount - tax

View File

@ -3,7 +3,8 @@ package kr.co.vividnext.sodalive.admin.calculate
import com.fasterxml.jackson.annotation.JsonProperty
import com.querydsl.core.annotations.QueryProjection
import kr.co.vividnext.sodalive.content.order.OrderType
import kotlin.math.roundToInt
import java.math.BigDecimal
import java.math.RoundingMode
data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
// 등록 크리에이터 닉네임
@ -19,7 +20,9 @@ data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
// 인원
val numberOfPeople: Long,
// 합계
val totalCan: Int
val totalCan: Int,
// 정산비율
val settlementRatio: Int?
) {
fun toCumulativeSalesByContentItem(): CumulativeSalesByContentItem {
val orderTypeStr = if (orderType == OrderType.RENTAL) {
@ -29,16 +32,21 @@ data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
}
// 원화 = totalCoin * 100 ( 캔 1개 = 100원 )
val totalKrw = totalCan * 100
val totalKrw = BigDecimal(totalCan) * BigDecimal(100)
// 결제수수료 : 6.6%
val paymentFee = totalKrw * 0.066f
val paymentFee = totalKrw * BigDecimal(0.066)
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = (totalKrw.toFloat() - paymentFee) * 0.7
// 정산금액 = (원화 - 결제수수료) 의 70%
val settlementAmount = if (settlementRatio != null) {
(totalKrw - paymentFee) * (BigDecimal(settlementRatio) / BigDecimal(100.0))
} else {
(totalKrw - paymentFee) * BigDecimal(0.7)
}
// 원천세 = 정산금액의 3.3%
val tax = settlementAmount * 0.033
val tax = settlementAmount * BigDecimal(0.033)
// 입금액
val depositAmount = settlementAmount - tax
@ -51,11 +59,11 @@ data class GetCumulativeSalesByContentQueryData @QueryProjection constructor(
orderPrice = orderPrice,
numberOfPeople = numberOfPeople.toInt(),
totalCan = totalCan,
totalKrw = totalKrw,
paymentFee = paymentFee.roundToInt(),
settlementAmount = settlementAmount.roundToInt(),
tax = tax.roundToInt(),
depositAmount = depositAmount.roundToInt()
totalKrw = totalKrw.toInt(),
paymentFee = paymentFee.setScale(0, RoundingMode.HALF_UP).toInt(),
settlementAmount = settlementAmount.setScale(0, RoundingMode.HALF_UP).toInt(),
tax = tax.setScale(0, RoundingMode.HALF_UP).toInt(),
depositAmount = depositAmount.setScale(0, RoundingMode.HALF_UP).toInt()
)
}
}

View File

@ -176,12 +176,15 @@ class CreatorAdminCalculateQueryRepository(private val queryFactory: JPAQueryFac
order.type,
order.can,
order.id.count(),
order.can.sum()
order.can.sum(),
creatorSettlementRatio.contentSettlementRatio
)
)
.from(order)
.innerJoin(order.audioContent, audioContent)
.innerJoin(audioContent.member, member)
.leftJoin(creatorSettlementRatio)
.on(member.id.eq(creatorSettlementRatio.member.id))
.where(
audioContent.member.id.eq(memberId)
.and(order.isActive.isTrue)