From 0e0114a7d1dbfdaba034a003922afb082d55bda4 Mon Sep 17 00:00:00 2001 From: Klaus Date: Tue, 2 Jul 2024 21:14:15 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A3=B0=EB=A0=9B=20=ED=95=A9=EA=B3=84=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20-=20Float=20=EA=B0=92=EC=9D=B4=EB=9D=BC=20?= =?UTF-8?q?=EC=A0=95=ED=99=95=ED=9E=88=20100.0=EC=9D=B4=20=EB=82=98?= =?UTF-8?q?=EC=98=A4=EC=A7=80=20=EC=95=8A=EC=9C=BC=EB=AF=80=EB=A1=9C=20tot?= =?UTF-8?q?alPercentage=EA=B0=80=2099.9=EB=B3=B4=EB=8B=A4=20=ED=81=AC?= =?UTF-8?q?=EA=B3=A0=20100.1=EB=B3=B4=EB=8B=A4=20=EC=9E=91=EC=9C=BC?= =?UTF-8?q?=EB=A9=B4=20=ED=86=B5=EA=B3=BC=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vividnext/sodalive/live/roulette/v2/RouletteService.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/live/roulette/v2/RouletteService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/live/roulette/v2/RouletteService.kt index 84ad0bc..1b92053 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/live/roulette/v2/RouletteService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/live/roulette/v2/RouletteService.kt @@ -23,7 +23,6 @@ import kr.co.vividnext.sodalive.member.MemberRole import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import java.math.BigDecimal import java.util.concurrent.locks.ReentrantReadWriteLock import kotlin.concurrent.write import kotlin.random.Random @@ -237,8 +236,8 @@ class RouletteService( throw SodaException("룰렛 옵션은 최소 2개, 최대 10개까지 설정할 수 있습니다.") } - val totalPercentage = items.map { BigDecimal(it.percentage.toDouble()) }.reduce(BigDecimal::plus) - if (totalPercentage != BigDecimal(100.0)) { + val totalPercentage = items.map { it.percentage }.sum() + if (totalPercentage > 100.1f || totalPercentage < 99.9f) { throw SodaException("확률이 100%가 아닙니다") } }