- 추가 슬롯 구매 기능 추가
This commit is contained in:
2024-07-25 21:53:29 +09:00
parent abb60f5743
commit 766d9668c2
3 changed files with 56 additions and 1 deletions

View File

@@ -1,9 +1,16 @@
package kr.co.vividnext.sodalive.alarm
import kr.co.vividnext.sodalive.can.payment.CanPaymentService
import kr.co.vividnext.sodalive.can.use.CanUsage
import kr.co.vividnext.sodalive.common.SodaException
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
@Service
class AlarmService(private val repository: AlarmRepository) {
class AlarmService(
private val canPaymentService: CanPaymentService,
private val repository: AlarmRepository
) {
fun getSlotQuantityAndPrice(memberId: Long): GetSlotQuantityAndPriceResponse {
val slotQuantity = repository.getSlotQuantity(memberId)
@@ -28,4 +35,33 @@ class AlarmService(private val repository: AlarmRepository) {
}
)
}
@Transactional
fun buyExtraSlot(memberId: Long, container: String) {
val slotQuantity = repository.getSlotQuantity(memberId)
val needCan = when (slotQuantity) {
0 -> {
30
}
1 -> {
60
}
2 -> {
100
}
else -> {
throw SodaException("이미 구매하셨습니다")
}
}
canPaymentService.spendCan(
memberId = memberId,
needCan = needCan,
canUsage = CanUsage.ALARM_SLOT,
container = container
)
}
}