Compare commits
No commits in common. "348936a67e69c1efd7f0bdff539b0a6380dd5fc7" and "0e9863050ffbb2a8a72ab064c6e1d62dcc23c48c" have entirely different histories.
348936a67e
...
0e9863050f
|
@ -679,15 +679,7 @@ class LiveRoomService(
|
|||
.getNotificationUserIds(room.member!!.id!!)
|
||||
.contains(member.id)
|
||||
|
||||
var isActiveRoulette = false
|
||||
val rouletteList = rouletteRepository.findByCreatorId(creatorId = room.member!!.id!!)
|
||||
|
||||
for (roulette in rouletteList) {
|
||||
if (roulette.isActive) {
|
||||
isActiveRoulette = true
|
||||
break
|
||||
}
|
||||
}
|
||||
val isActiveRoulette = rouletteRepository.findByIdOrNull(room.member!!.id!!)?.isActive ?: false
|
||||
|
||||
val donationRankingTop3UserIds = if (room.member!!.isVisibleDonationRank) {
|
||||
explorerQueryRepository
|
||||
|
|
|
@ -11,6 +11,7 @@ data class NewRoulette(
|
|||
@Indexed
|
||||
val creatorId: Long,
|
||||
var can: Int,
|
||||
@Indexed
|
||||
var isActive: Boolean,
|
||||
var items: List<RouletteItem> = mutableListOf()
|
||||
)
|
||||
|
|
|
@ -4,4 +4,5 @@ import org.springframework.data.repository.CrudRepository
|
|||
|
||||
interface NewRouletteRepository : CrudRepository<NewRoulette, Long> {
|
||||
fun findByCreatorId(creatorId: Long): List<NewRoulette>
|
||||
fun findByCreatorIdAndActive(creatorId: Long, isActive: Boolean): List<NewRoulette>
|
||||
}
|
||||
|
|
|
@ -122,28 +122,16 @@ class NewRouletteService(
|
|||
}
|
||||
|
||||
fun getRoulette(creatorId: Long, memberId: Long): GetRouletteResponse {
|
||||
val rouletteList = repository.findByCreatorId(creatorId = creatorId)
|
||||
val roulette = repository.findByCreatorIdAndActive(creatorId = creatorId, isActive = true)
|
||||
|
||||
if (rouletteList.isEmpty()) {
|
||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||
}
|
||||
|
||||
var activeRoulette: NewRoulette? = null
|
||||
for (roulette in rouletteList) {
|
||||
if (roulette.isActive) {
|
||||
activeRoulette = roulette
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (activeRoulette == null || activeRoulette.items.isEmpty()) {
|
||||
if (roulette.isEmpty() || !roulette[0].isActive || roulette[0].items.isEmpty()) {
|
||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||
}
|
||||
|
||||
return GetRouletteResponse(
|
||||
can = activeRoulette.can,
|
||||
isActive = activeRoulette.isActive,
|
||||
items = activeRoulette.items
|
||||
can = roulette[0].can,
|
||||
isActive = roulette[0].isActive,
|
||||
items = roulette[0].items
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -160,38 +148,23 @@ class NewRouletteService(
|
|||
}
|
||||
|
||||
// STEP 2 - 룰렛 데이터 가져오기
|
||||
val rouletteList = repository.findByCreatorId(creatorId = host.id!!)
|
||||
val rouletteList = repository.findByCreatorIdAndActive(creatorId = host.id!!, isActive = true)
|
||||
|
||||
if (rouletteList.isEmpty()) {
|
||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||
}
|
||||
|
||||
var activeRoulette: NewRoulette? = null
|
||||
for (roulette in rouletteList) {
|
||||
if (roulette.isActive) {
|
||||
activeRoulette = roulette
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (activeRoulette == null || activeRoulette.items.isEmpty()) {
|
||||
if (rouletteList.isEmpty() || !rouletteList[0].isActive || rouletteList[0].items.isEmpty()) {
|
||||
throw SodaException("룰렛을 사용할 수 없습니다.")
|
||||
}
|
||||
|
||||
// STEP 3 - 캔 사용
|
||||
val roulette = rouletteList[0]
|
||||
canPaymentService.spendCan(
|
||||
memberId = memberId,
|
||||
needCan = activeRoulette.can,
|
||||
needCan = roulette.can,
|
||||
canUsage = CanUsage.SPIN_ROULETTE,
|
||||
liveRoom = room,
|
||||
container = request.container
|
||||
)
|
||||
|
||||
return GetRouletteResponse(
|
||||
can = activeRoulette.can,
|
||||
isActive = activeRoulette.isActive,
|
||||
items = activeRoulette.items
|
||||
)
|
||||
return GetRouletteResponse(can = roulette.can, isActive = roulette.isActive, items = roulette.items)
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
Loading…
Reference in New Issue