Compare commits
3 Commits
c46d6621ec
...
cc695c115b
Author | SHA1 | Date |
---|---|---|
|
cc695c115b | |
|
86dac7e2b4 | |
|
52ddefa631 |
|
@ -170,6 +170,14 @@ class AudioContentService(
|
|||
|
||||
if (request.price in 1..4) throw SodaException("콘텐츠의 최소금액은 5캔 입니다.")
|
||||
|
||||
val isOnlyRental = if (request.limited != null && request.limited > 0) {
|
||||
false
|
||||
} else if (request.purchaseOption == PurchaseOption.RENT_ONLY) {
|
||||
true
|
||||
} else {
|
||||
request.isOnlyRental
|
||||
}
|
||||
|
||||
// DB에 값 추가
|
||||
val audioContent = AudioContent(
|
||||
title = request.title,
|
||||
|
@ -185,7 +193,7 @@ class AudioContentService(
|
|||
isAdult = request.isAdult,
|
||||
purchaseOption = request.purchaseOption,
|
||||
isGeneratePreview = request.isGeneratePreview,
|
||||
isOnlyRental = if (request.limited != null && request.limited > 0) false else request.isOnlyRental,
|
||||
isOnlyRental = isOnlyRental,
|
||||
isCommentAvailable = request.isCommentAvailable
|
||||
)
|
||||
audioContent.theme = theme
|
||||
|
|
|
@ -5,6 +5,7 @@ import kr.co.vividnext.sodalive.can.use.CanUsage
|
|||
import kr.co.vividnext.sodalive.common.SodaException
|
||||
import kr.co.vividnext.sodalive.content.AudioContent
|
||||
import kr.co.vividnext.sodalive.content.AudioContentRepository
|
||||
import kr.co.vividnext.sodalive.content.PurchaseOption
|
||||
import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
|
||||
import kr.co.vividnext.sodalive.content.like.AudioContentLikeRepository
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
|
@ -31,7 +32,7 @@ class OrderService(
|
|||
fun order(contentId: Long, orderType: OrderType, container: String, member: Member) {
|
||||
val content = audioContentRepository.findByIdAndActive(contentId)
|
||||
?: throw SodaException("잘못된 콘텐츠 입니다\n다시 시도해 주세요.")
|
||||
validateOrder(memberId = member.id!!, content = content)
|
||||
validateOrder(memberId = member.id!!, content = content, orderType = orderType)
|
||||
|
||||
val order = if (content.limited != null && content.remaining != null) {
|
||||
if (content.remaining!! <= 0) throw SodaException("해당 콘텐츠가 매진되었습니다.")
|
||||
|
@ -75,11 +76,17 @@ class OrderService(
|
|||
return order
|
||||
}
|
||||
|
||||
private fun validateOrder(memberId: Long, content: AudioContent) {
|
||||
private fun validateOrder(memberId: Long, content: AudioContent, orderType: OrderType) {
|
||||
if (memberId == content.member!!.id!!) throw SodaException("자신이 올린 콘텐츠는 구매할 수 없습니다.")
|
||||
if (repository.isExistOrdered(memberId = memberId, contentId = content.id!!)) {
|
||||
throw SodaException("이미 구매한 콘텐츠 입니다.")
|
||||
}
|
||||
|
||||
val existOrdered = repository.isExistOrdered(memberId = memberId, contentId = content.id!!)
|
||||
if (existOrdered) throw SodaException("이미 구매한 콘텐츠 입니다.")
|
||||
|
||||
val isOnlyRental = content.purchaseOption == PurchaseOption.RENT_ONLY || content.isOnlyRental
|
||||
if (isOnlyRental && orderType == OrderType.KEEP) throw SodaException("대여만 가능한 콘텐츠 입니다.")
|
||||
|
||||
val isOnlyBuy = content.purchaseOption == PurchaseOption.BUY_ONLY && orderType == OrderType.RENTAL
|
||||
if (isOnlyBuy) throw SodaException("소장만 가능한 콘텐츠 입니다.\n앱 업데이트 후 구매해 주세요.")
|
||||
}
|
||||
|
||||
fun getAudioContentOrderList(
|
||||
|
|
Loading…
Reference in New Issue