|
|
|
|
@@ -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(
|
|
|
|
|
|