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