From a5845c90c26d496a882dd212c1f51909496e3209 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 5 Nov 2024 15:14:39 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=B0=A9=20?= =?UTF-8?q?=ED=9B=84=EC=9B=90=EB=A6=AC=EC=8A=A4=ED=8A=B8=20-=20=EB=82=B4?= =?UTF-8?q?=EA=B0=80=20=ED=9B=84=EC=9B=90=ED=95=9C=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=ED=9B=84=EC=9B=90=EC=9D=80=20=EC=A1=B0=ED=9A=8C=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/live/room/LiveRoomRepository.kt | 6 +++--- .../sodalive/live/room/LiveRoomService.kt | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt index afc8c46..0080b72 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt @@ -52,7 +52,7 @@ interface LiveRoomQueryRepository { fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom? fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? fun getDonationTotal(roomId: Long): Int? - fun getDonationList(roomId: Long, isLiveCreator: Boolean): List + fun getDonationList(roomId: Long, isLiveCreator: Boolean, memberId: Long): List fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List fun getActiveRoomIdList(memberId: Long): Int fun getTotalHeartCount(roomId: Long): Int? @@ -244,7 +244,7 @@ class LiveRoomQueryRepositoryImpl( .fetchOne() } - override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List { + override fun getDonationList(roomId: Long, isLiveCreator: Boolean, memberId: Long): List { val where = liveRoom.id.eq(roomId) .and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE))) .and(useCan.isRefund.isFalse) @@ -253,7 +253,7 @@ class LiveRoomQueryRepositoryImpl( useCan.can.sum().add(useCan.rewardCan.sum()) } else { CaseBuilder() - .`when`(useCan.isSecret.isFalse) + .`when`(useCan.isSecret.isFalse.or(useCan.member.id.eq(memberId))) .then(useCan.can.sum().add(useCan.rewardCan.sum())) .otherwise(0) } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt index a5211fd..18addd3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomService.kt @@ -1176,10 +1176,19 @@ class LiveRoomService( fun getDonationStatus(roomId: Long, memberId: Long): GetLiveRoomDonationStatusResponse { val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.") 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 totalSecretCan = donationList.sumOf { it.secretCan } + val totalSecretCan = if (isLiveCreator) { + donationList.sumOf { it.secretCan } + } else { + 0 + } return GetLiveRoomDonationStatusResponse( donationList = donationList, From 65b28f92d570f1766efa4b70fd37e81717e17eb8 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 5 Nov 2024 15:19:14 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=B0=A9=20?= =?UTF-8?q?=ED=9B=84=EC=9B=90=EB=A6=AC=EC=8A=A4=ED=8A=B8=20-=20=EB=82=B4?= =?UTF-8?q?=EA=B0=80=20=ED=9B=84=EC=9B=90=ED=95=9C=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=ED=9B=84=EC=9B=90=EC=9D=80=20=EC=A1=B0=ED=9A=8C=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt index 0080b72..c7223f8 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt @@ -253,7 +253,7 @@ class LiveRoomQueryRepositoryImpl( useCan.can.sum().add(useCan.rewardCan.sum()) } else { CaseBuilder() - .`when`(useCan.isSecret.isFalse.or(useCan.member.id.eq(memberId))) + .`when`(useCan.isSecret.isFalse) .then(useCan.can.sum().add(useCan.rewardCan.sum())) .otherwise(0) } @@ -275,7 +275,7 @@ class LiveRoomQueryRepositoryImpl( ).sum(), Expressions.asNumber( CaseBuilder() - .`when`(Expressions.asBoolean(isLiveCreator).isTrue) + .`when`(Expressions.asBoolean(isLiveCreator).isTrue.or(useCan.member.id.eq(memberId))) .then( Expressions.asNumber( CaseBuilder() From efdf1d3eed82d575aa58709e393115ed5494bdef Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 5 Nov 2024 16:00:23 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EB=9D=BC=EC=9D=B4=EB=B8=8C=EB=B0=A9=20?= =?UTF-8?q?=ED=9B=84=EC=9B=90=EB=A6=AC=EC=8A=A4=ED=8A=B8=20-=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../co/vividnext/sodalive/live/room/LiveRoomRepository.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt index c7223f8..d1fe8f2 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/room/LiveRoomRepository.kt @@ -250,11 +250,11 @@ class LiveRoomQueryRepositoryImpl( .and(useCan.isRefund.isFalse) val sortExpression: NumberExpression = if (isLiveCreator) { - useCan.can.sum().add(useCan.rewardCan.sum()) + useCan.can.add(useCan.rewardCan) } else { CaseBuilder() .`when`(useCan.isSecret.isFalse) - .then(useCan.can.sum().add(useCan.rewardCan.sum())) + .then(useCan.can.add(useCan.rewardCan)) .otherwise(0) } @@ -290,10 +290,10 @@ class LiveRoomQueryRepositoryImpl( ) .from(useCan) .innerJoin(useCan.room, liveRoom) - .join(useCan.member, member) + .innerJoin(useCan.member, member) .groupBy(useCan.member.id) .where(where) - .orderBy(sortExpression.desc()) + .orderBy(sortExpression.sum().desc()) .fetch() }