diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt index c7b5834..b3e4ad3 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/comment/AudioContentCommentController.kt @@ -46,6 +46,13 @@ class AudioContentCommentController( actionType = ActionType.CONTENT_COMMENT, pushTokenList = pushTokenList ) + + userActionService.recordAction( + memberId = member.id!!, + actionType = ActionType.ORDER_CONTENT_COMMENT, + contentId = request.contentId, + pushTokenList = pushTokenList + ) } catch (_: Exception) { } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt index 566cc27..d66760d 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/order/OrderRepository.kt @@ -44,6 +44,7 @@ interface OrderQueryRepository { fun findOrderedContent(contentIdList: List, memberId: Long): List fun findEndDateByContentId(contentIdList: List, memberId: Long): List fun findBuyerListByContentId(contentId: Long): List + fun findByMemberIdAndContentId(memberId: Long, contentId: Long, createdAt: LocalDateTime): Order? } @Repository @@ -280,4 +281,16 @@ class OrderQueryRepositoryImpl( ) .fetch() } + + override fun findByMemberIdAndContentId(memberId: Long, contentId: Long, createdAt: LocalDateTime): Order? { + return queryFactory + .selectFrom(order) + .where( + order.isActive.isTrue, + order.member.id.eq(memberId), + order.audioContent.id.eq(contentId), + order.createdAt.after(createdAt) + ) + .fetchFirst() + } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt index f6919ac..f9d3143 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt @@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.useraction import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import kr.co.vividnext.sodalive.content.order.OrderRepository import kr.co.vividnext.sodalive.fcm.FcmService import kr.co.vividnext.sodalive.point.MemberPoint import kr.co.vividnext.sodalive.point.MemberPointRepository @@ -15,6 +16,7 @@ import java.time.LocalDateTime @Service class UserActionService( private val repository: UserActionLogRepository, + private val orderRepository: OrderRepository, private val policyRepository: PointRewardPolicyRepository, private val grantLogRepository: PointGrantLogRepository, private val memberPointRepository: MemberPointRepository, @@ -27,7 +29,7 @@ class UserActionService( fun recordAction( memberId: Long, actionType: ActionType, - orderId: Long? = null, + contentId: Long? = null, pushTokenList: List = emptyList() ) { coroutineScope.launch { @@ -44,6 +46,17 @@ class UserActionService( todayAt15 } + val order = if (contentId != null) { + orderRepository.findByMemberIdAndContentId( + memberId = memberId, + contentId = contentId, + createdAt = if (policyType == PolicyType.DAILY) policyTypeDailyStartDate else policy.startDate + ) + } else { + null + } + if (actionType == ActionType.ORDER_CONTENT_COMMENT && order == null) return@launch + val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween( memberId = memberId, actionType = actionType, @@ -65,7 +78,7 @@ class UserActionService( point = policy.pointAmount, actionType = actionType, policyId = policy.id!!, - orderId = orderId + orderId = order?.id ) )