알람
- 추가 슬롯 구매 기능 추가
This commit is contained in:
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user