commit
c1e325aadf
|
@ -52,7 +52,7 @@ interface LiveRoomQueryRepository {
|
||||||
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
|
fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom?
|
||||||
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse?
|
||||||
fun getDonationTotal(roomId: Long): Int?
|
fun getDonationTotal(roomId: Long): Int?
|
||||||
fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem>
|
fun getDonationList(roomId: Long, isLiveCreator: Boolean, memberId: Long): List<GetLiveRoomDonationItem>
|
||||||
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom>
|
||||||
fun getActiveRoomIdList(memberId: Long): Int
|
fun getActiveRoomIdList(memberId: Long): Int
|
||||||
fun getTotalHeartCount(roomId: Long): Int?
|
fun getTotalHeartCount(roomId: Long): Int?
|
||||||
|
@ -244,17 +244,17 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
.fetchOne()
|
.fetchOne()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> {
|
override fun getDonationList(roomId: Long, isLiveCreator: Boolean, memberId: Long): List<GetLiveRoomDonationItem> {
|
||||||
val where = liveRoom.id.eq(roomId)
|
val where = liveRoom.id.eq(roomId)
|
||||||
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
.and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE)))
|
||||||
.and(useCan.isRefund.isFalse)
|
.and(useCan.isRefund.isFalse)
|
||||||
|
|
||||||
val sortExpression: NumberExpression<Int> = if (isLiveCreator) {
|
val sortExpression: NumberExpression<Int> = if (isLiveCreator) {
|
||||||
useCan.can.sum().add(useCan.rewardCan.sum())
|
useCan.can.add(useCan.rewardCan)
|
||||||
} else {
|
} else {
|
||||||
CaseBuilder()
|
CaseBuilder()
|
||||||
.`when`(useCan.isSecret.isFalse)
|
.`when`(useCan.isSecret.isFalse)
|
||||||
.then(useCan.can.sum().add(useCan.rewardCan.sum()))
|
.then(useCan.can.add(useCan.rewardCan))
|
||||||
.otherwise(0)
|
.otherwise(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
).sum(),
|
).sum(),
|
||||||
Expressions.asNumber(
|
Expressions.asNumber(
|
||||||
CaseBuilder()
|
CaseBuilder()
|
||||||
.`when`(Expressions.asBoolean(isLiveCreator).isTrue)
|
.`when`(Expressions.asBoolean(isLiveCreator).isTrue.or(useCan.member.id.eq(memberId)))
|
||||||
.then(
|
.then(
|
||||||
Expressions.asNumber(
|
Expressions.asNumber(
|
||||||
CaseBuilder()
|
CaseBuilder()
|
||||||
|
@ -290,10 +290,10 @@ class LiveRoomQueryRepositoryImpl(
|
||||||
)
|
)
|
||||||
.from(useCan)
|
.from(useCan)
|
||||||
.innerJoin(useCan.room, liveRoom)
|
.innerJoin(useCan.room, liveRoom)
|
||||||
.join(useCan.member, member)
|
.innerJoin(useCan.member, member)
|
||||||
.groupBy(useCan.member.id)
|
.groupBy(useCan.member.id)
|
||||||
.where(where)
|
.where(where)
|
||||||
.orderBy(sortExpression.desc())
|
.orderBy(sortExpression.sum().desc())
|
||||||
.fetch()
|
.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1176,10 +1176,19 @@ class LiveRoomService(
|
||||||
fun getDonationStatus(roomId: Long, memberId: Long): GetLiveRoomDonationStatusResponse {
|
fun getDonationStatus(roomId: Long, memberId: Long): GetLiveRoomDonationStatusResponse {
|
||||||
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
|
val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.")
|
||||||
val isLiveCreator = room.member!!.id == memberId
|
val isLiveCreator = room.member!!.id == memberId
|
||||||
val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator)
|
|
||||||
.filter { it.secretCan > 0 || it.can > 0 }
|
val donationList = repository.getDonationList(
|
||||||
|
roomId = room.id!!,
|
||||||
|
isLiveCreator = isLiveCreator,
|
||||||
|
memberId = memberId
|
||||||
|
).filter { it.secretCan > 0 || it.can > 0 }
|
||||||
|
|
||||||
val totalCan = donationList.sumOf { it.can }
|
val totalCan = donationList.sumOf { it.can }
|
||||||
val totalSecretCan = donationList.sumOf { it.secretCan }
|
val totalSecretCan = if (isLiveCreator) {
|
||||||
|
donationList.sumOf { it.secretCan }
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
|
||||||
return GetLiveRoomDonationStatusResponse(
|
return GetLiveRoomDonationStatusResponse(
|
||||||
donationList = donationList,
|
donationList = donationList,
|
||||||
|
|
Loading…
Reference in New Issue