feat: 포인트 사용 로직 구현 (만료일 순 + 10포인트 단위 차감)
This commit is contained in:
@@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository
|
||||
import kr.co.vividnext.sodalive.content.like.AudioContentLikeRepository
|
||||
import kr.co.vividnext.sodalive.content.main.GetAudioContentMainItem
|
||||
import kr.co.vividnext.sodalive.member.Member
|
||||
import kr.co.vividnext.sodalive.point.PointUsageService
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
@@ -19,6 +20,7 @@ import java.time.LocalDateTime
|
||||
@Transactional(readOnly = true)
|
||||
class OrderService(
|
||||
private val repository: OrderRepository,
|
||||
private val pointUsageService: PointUsageService,
|
||||
private val canPaymentService: CanPaymentService,
|
||||
private val audioContentRepository: AudioContentRepository,
|
||||
private val audioContentCommentQueryRepository: AudioContentCommentRepository,
|
||||
@@ -41,9 +43,16 @@ class OrderService(
|
||||
orderContent(orderType, content, member)
|
||||
}
|
||||
|
||||
val usedPoint = if (order.type == OrderType.RENTAL) {
|
||||
pointUsageService.usePoint(member.id!!, order.can)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
order.point = usedPoint
|
||||
|
||||
canPaymentService.spendCan(
|
||||
memberId = member.id!!,
|
||||
needCan = order.can,
|
||||
needCan = order.can - (usedPoint / 10),
|
||||
canUsage = CanUsage.ORDER_CONTENT,
|
||||
order = order,
|
||||
container = container
|
||||
|
Reference in New Issue
Block a user