라이브 방 후원리스트
- 후원리스트에 일반후원과 비밀후원 값을 분리
This commit is contained in:
		| @@ -2,6 +2,7 @@ package kr.co.vividnext.sodalive.live.room | ||||
|  | ||||
| import com.querydsl.core.types.Projections | ||||
| import com.querydsl.core.types.dsl.CaseBuilder | ||||
| import com.querydsl.core.types.dsl.Expressions | ||||
| import com.querydsl.jpa.impl.JPAQueryFactory | ||||
| import kr.co.vividnext.sodalive.can.use.CanUsage | ||||
| import kr.co.vividnext.sodalive.can.use.QUseCan.useCan | ||||
| @@ -49,7 +50,7 @@ interface LiveRoomQueryRepository { | ||||
|     fun getLiveRoom(id: Long): LiveRoom? | ||||
|     fun getLiveRoomAndAccountId(roomId: Long, memberId: Long): LiveRoom? | ||||
|     fun getRecentRoomInfo(memberId: Long): GetRecentRoomInfoResponse? | ||||
|     fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? | ||||
|     fun getDonationTotal(roomId: Long): Int? | ||||
|     fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> | ||||
|     fun getRoomActiveAndChannelNameIsNotNull(memberId: Long): List<LiveRoom> | ||||
|     fun getActiveRoomIdList(memberId: Long): Int | ||||
| @@ -227,14 +228,11 @@ class LiveRoomQueryRepositoryImpl( | ||||
|             .fetchFirst() | ||||
|     } | ||||
|  | ||||
|     override fun getDonationTotal(roomId: Long, isLiveCreator: Boolean): Int? { | ||||
|         var where = liveRoom.id.eq(roomId) | ||||
|     override fun getDonationTotal(roomId: Long): Int? { | ||||
|         val where = liveRoom.id.eq(roomId) | ||||
|             .and(useCan.canUsage.eq(CanUsage.DONATION).or(useCan.canUsage.eq(CanUsage.SPIN_ROULETTE))) | ||||
|             .and(useCan.isRefund.isFalse) | ||||
|  | ||||
|         if (!isLiveCreator) { | ||||
|             where = where.and(useCan.isSecret.isFalse) | ||||
|         } | ||||
|             .and(useCan.isSecret.isFalse) | ||||
|  | ||||
|         return queryFactory | ||||
|             .select(useCanCalculate.can.sum()) | ||||
| @@ -246,14 +244,10 @@ class LiveRoomQueryRepositoryImpl( | ||||
|     } | ||||
|  | ||||
|     override fun getDonationList(roomId: Long, isLiveCreator: Boolean): List<GetLiveRoomDonationItem> { | ||||
|         var 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.isRefund.isFalse) | ||||
|  | ||||
|         if (!isLiveCreator) { | ||||
|             where = where.and(useCan.isSecret.isFalse) | ||||
|         } | ||||
|  | ||||
|         return queryFactory | ||||
|             .select( | ||||
|                 QGetLiveRoomDonationItem( | ||||
| @@ -263,13 +257,31 @@ class LiveRoomQueryRepositoryImpl( | ||||
|                         .prepend(cloudFrontHost), | ||||
|                     member.nickname, | ||||
|                     member.id.coalesce(0), | ||||
|                     useCan.can.sum().add(useCan.rewardCan.sum()) | ||||
|                     Expressions.asNumber( | ||||
|                         CaseBuilder() | ||||
|                             .`when`(useCan.isSecret.isFalse) | ||||
|                             .then(useCan.can.add(useCan.rewardCan)) | ||||
|                             .otherwise(0) | ||||
|                     ).sum(), | ||||
|                     Expressions.asNumber( | ||||
|                         CaseBuilder() | ||||
|                             .`when`(Expressions.asBoolean(isLiveCreator).isTrue) | ||||
|                             .then( | ||||
|                                 Expressions.asNumber( | ||||
|                                     CaseBuilder() | ||||
|                                         .`when`(useCan.isSecret.isTrue) | ||||
|                                         .then(useCan.can.add(useCan.rewardCan)) | ||||
|                                         .otherwise(0) | ||||
|                                 ).sum() | ||||
|                             ) | ||||
|                             .otherwise(0) | ||||
|                     ) | ||||
|                 ) | ||||
|             ) | ||||
|             .from(useCan) | ||||
|             .innerJoin(useCan.room, liveRoom) | ||||
|             .join(useCan.member, member) | ||||
|             .groupBy(useCan.member) | ||||
|             .groupBy(useCan.member.id) | ||||
|             .where(where) | ||||
|             .orderBy(useCan.can.sum().add(useCan.rewardCan.sum()).desc()) | ||||
|             .fetch() | ||||
|   | ||||
| @@ -973,11 +973,8 @@ class LiveRoomService( | ||||
|     } | ||||
|  | ||||
|     fun getDonationTotal(roomId: Long, memberId: Long): GetLiveRoomDonationTotalResponse { | ||||
|         val room = repository.getLiveRoom(roomId) | ||||
|             ?: return GetLiveRoomDonationTotalResponse(0) | ||||
|         val isLiveCreator = room.member!!.id == memberId | ||||
|         return GetLiveRoomDonationTotalResponse( | ||||
|             totalDonationCan = repository.getDonationTotal(roomId = roomId, isLiveCreator = isLiveCreator) ?: 0 | ||||
|             totalDonationCan = repository.getDonationTotal(roomId = roomId) ?: 0 | ||||
|         ) | ||||
|     } | ||||
|  | ||||
| @@ -1180,7 +1177,7 @@ class LiveRoomService( | ||||
|         val room = repository.getLiveRoom(roomId) ?: throw SodaException("잘못된 요청입니다.") | ||||
|         val isLiveCreator = room.member!!.id == memberId | ||||
|         val donationList = repository.getDonationList(roomId = room.id!!, isLiveCreator = isLiveCreator) | ||||
|         val totalCan = donationList.sumOf { it.can } | ||||
|         val totalCan = donationList.sumOf { it.can + it.secretCan } | ||||
|  | ||||
|         return GetLiveRoomDonationStatusResponse( | ||||
|             donationList = donationList, | ||||
|   | ||||
| @@ -12,5 +12,6 @@ data class GetLiveRoomDonationItem @QueryProjection constructor( | ||||
|     val profileImage: String, | ||||
|     val nickname: String, | ||||
|     val userId: Long, | ||||
|     val can: Int | ||||
|     val can: Int, | ||||
|     val secretCan: Int | ||||
| ) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user