Compare commits
No commits in common. "c927dc4ecd0659015ebb382d52766c1d9b217d37" and "fe4ecd0ad84ee36c674461cee6130d4aa50faf13" have entirely different histories.
c927dc4ecd
...
fe4ecd0ad8
|
@ -28,10 +28,4 @@ class AdminCalculateController(private val service: AdminCalculateService) {
|
||||||
fun getCumulativeSalesByContent(pageable: Pageable) = ApiResponse.ok(
|
fun getCumulativeSalesByContent(pageable: Pageable) = ApiResponse.ok(
|
||||||
service.getCumulativeSalesByContent(pageable.offset, pageable.pageSize.toLong())
|
service.getCumulativeSalesByContent(pageable.offset, pageable.pageSize.toLong())
|
||||||
)
|
)
|
||||||
|
|
||||||
@GetMapping("/content-donation-list")
|
|
||||||
fun getCalculateContentDonationList(
|
|
||||||
@RequestParam startDateStr: String,
|
|
||||||
@RequestParam endDateStr: String
|
|
||||||
) = ApiResponse.ok(service.getCalculateContentDonationList(startDateStr, endDateStr))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.querydsl.core.types.dsl.DateTimePath
|
||||||
import com.querydsl.core.types.dsl.Expressions
|
import com.querydsl.core.types.dsl.Expressions
|
||||||
import com.querydsl.core.types.dsl.StringTemplate
|
import com.querydsl.core.types.dsl.StringTemplate
|
||||||
import com.querydsl.jpa.impl.JPAQueryFactory
|
import com.querydsl.jpa.impl.JPAQueryFactory
|
||||||
import kr.co.vividnext.sodalive.can.use.CanUsage
|
|
||||||
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
import kr.co.vividnext.sodalive.can.use.QUseCan.useCan
|
||||||
import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
import kr.co.vividnext.sodalive.can.use.QUseCanCalculate.useCanCalculate
|
||||||
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
import kr.co.vividnext.sodalive.can.use.UseCanCalculateStatus
|
||||||
|
@ -124,36 +123,4 @@ class AdminCalculateQueryRepository(private val queryFactory: JPAQueryFactory) {
|
||||||
.orderBy(member.id.desc(), audioContent.id.desc())
|
.orderBy(member.id.desc(), audioContent.id.desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalculateContentDonationList(
|
|
||||||
startDate: LocalDateTime,
|
|
||||||
endDate: LocalDateTime
|
|
||||||
): List<GetCalculateContentDonationQueryData> {
|
|
||||||
val donationFormattedDate = getFormattedDate(useCan.createdAt)
|
|
||||||
return queryFactory
|
|
||||||
.select(
|
|
||||||
QGetCalculateContentDonationQueryData(
|
|
||||||
member.nickname,
|
|
||||||
audioContent.title,
|
|
||||||
getFormattedDate(audioContent.createdAt),
|
|
||||||
donationFormattedDate,
|
|
||||||
useCan.id.count(),
|
|
||||||
useCan.can.add(useCan.rewardCan).sum()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.from(useCanCalculate)
|
|
||||||
.innerJoin(useCanCalculate.useCan, useCan)
|
|
||||||
.innerJoin(useCan.audioContent, audioContent)
|
|
||||||
.innerJoin(audioContent.member, member)
|
|
||||||
.where(
|
|
||||||
useCanCalculate.status.eq(UseCanCalculateStatus.RECEIVED)
|
|
||||||
.and(useCan.isRefund.isFalse)
|
|
||||||
.and(useCan.canUsage.eq(CanUsage.DONATION))
|
|
||||||
.and(useCan.createdAt.goe(startDate))
|
|
||||||
.and(useCan.createdAt.loe(endDate))
|
|
||||||
)
|
|
||||||
.groupBy(donationFormattedDate, audioContent.id)
|
|
||||||
.orderBy(donationFormattedDate.desc())
|
|
||||||
.fetch()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,60 +191,4 @@ class AdminCalculateService(private val repository: AdminCalculateQueryRepositor
|
||||||
|
|
||||||
return GetCumulativeSalesByContentResponse(totalCount, items)
|
return GetCumulativeSalesByContentResponse(totalCount, items)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
|
||||||
@Cacheable(
|
|
||||||
cacheNames = ["cache_ttl_3_hours"],
|
|
||||||
key = "'calculateContentDonationList:' + " + "#startDateStr + ':' + #endDateStr"
|
|
||||||
)
|
|
||||||
fun getCalculateContentDonationList(
|
|
||||||
startDateStr: String,
|
|
||||||
endDateStr: String
|
|
||||||
): List<GetCalculateContentDonationResponse> {
|
|
||||||
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
|
|
||||||
.getCalculateContentDonationList(startDate, endDate)
|
|
||||||
.asSequence()
|
|
||||||
.map {
|
|
||||||
// 원화 = 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
|
|
||||||
|
|
||||||
GetCalculateContentDonationResponse(
|
|
||||||
nickname = it.nickname,
|
|
||||||
title = it.title,
|
|
||||||
registrationDate = it.registrationDate,
|
|
||||||
donationDate = it.donationDate,
|
|
||||||
numberOfDonation = it.numberOfDonation.toInt(),
|
|
||||||
totalCan = it.totalCan,
|
|
||||||
totalKrw = totalKrw,
|
|
||||||
paymentFee = paymentFee.roundToInt(),
|
|
||||||
settlementAmount = settlementAmount.roundToInt(),
|
|
||||||
tax = tax.roundToInt(),
|
|
||||||
depositAmount = depositAmount.roundToInt()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.calculate
|
|
||||||
|
|
||||||
import com.querydsl.core.annotations.QueryProjection
|
|
||||||
|
|
||||||
data class GetCalculateContentDonationQueryData @QueryProjection constructor(
|
|
||||||
// 등록 크리에이터 닉네임
|
|
||||||
val nickname: String,
|
|
||||||
// 콘텐츠 제목
|
|
||||||
val title: String,
|
|
||||||
// 콘텐츠 등록 날짜
|
|
||||||
val registrationDate: String,
|
|
||||||
// 후원 날짜
|
|
||||||
val donationDate: String,
|
|
||||||
// 인원
|
|
||||||
val numberOfDonation: Long,
|
|
||||||
// 합계
|
|
||||||
val totalCan: Int
|
|
||||||
)
|
|
|
@ -1,17 +0,0 @@
|
||||||
package kr.co.vividnext.sodalive.admin.calculate
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
|
||||||
|
|
||||||
data class GetCalculateContentDonationResponse(
|
|
||||||
@JsonProperty("nickname") val nickname: String,
|
|
||||||
@JsonProperty("title") val title: String,
|
|
||||||
@JsonProperty("registrationDate") val registrationDate: String,
|
|
||||||
@JsonProperty("donationDate") val donationDate: String,
|
|
||||||
@JsonProperty("numberOfDonation") val numberOfDonation: Int,
|
|
||||||
@JsonProperty("totalCan") val totalCan: Int,
|
|
||||||
@JsonProperty("totalKrw") val totalKrw: Int,
|
|
||||||
@JsonProperty("paymentFee") val paymentFee: Int,
|
|
||||||
@JsonProperty("settlementAmount") val settlementAmount: Int,
|
|
||||||
@JsonProperty("tax") val tax: Int,
|
|
||||||
@JsonProperty("depositAmount") val depositAmount: Int
|
|
||||||
)
|
|
Loading…
Reference in New Issue