feat: 구매한 콘텐츠 댓글 이벤트 추가

This commit is contained in:
Klaus 2025-05-17 18:07:02 +09:00
parent 6fc372c898
commit 1bca1b27ed
3 changed files with 35 additions and 2 deletions

View File

@ -46,6 +46,13 @@ class AudioContentCommentController(
actionType = ActionType.CONTENT_COMMENT, actionType = ActionType.CONTENT_COMMENT,
pushTokenList = pushTokenList pushTokenList = pushTokenList
) )
userActionService.recordAction(
memberId = member.id!!,
actionType = ActionType.ORDER_CONTENT_COMMENT,
contentId = request.contentId,
pushTokenList = pushTokenList
)
} catch (_: Exception) { } catch (_: Exception) {
} }

View File

@ -44,6 +44,7 @@ interface OrderQueryRepository {
fun findOrderedContent(contentIdList: List<Long>, memberId: Long): List<Long> fun findOrderedContent(contentIdList: List<Long>, memberId: Long): List<Long>
fun findEndDateByContentId(contentIdList: List<Long>, memberId: Long): List<ContentIdAndEndDateData> fun findEndDateByContentId(contentIdList: List<Long>, memberId: Long): List<ContentIdAndEndDateData>
fun findBuyerListByContentId(contentId: Long): List<ContentBuyer> fun findBuyerListByContentId(contentId: Long): List<ContentBuyer>
fun findByMemberIdAndContentId(memberId: Long, contentId: Long, createdAt: LocalDateTime): Order?
} }
@Repository @Repository
@ -280,4 +281,16 @@ class OrderQueryRepositoryImpl(
) )
.fetch() .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()
}
} }

View File

@ -3,6 +3,7 @@ package kr.co.vividnext.sodalive.useraction
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kr.co.vividnext.sodalive.content.order.OrderRepository
import kr.co.vividnext.sodalive.fcm.FcmService import kr.co.vividnext.sodalive.fcm.FcmService
import kr.co.vividnext.sodalive.point.MemberPoint import kr.co.vividnext.sodalive.point.MemberPoint
import kr.co.vividnext.sodalive.point.MemberPointRepository import kr.co.vividnext.sodalive.point.MemberPointRepository
@ -15,6 +16,7 @@ import java.time.LocalDateTime
@Service @Service
class UserActionService( class UserActionService(
private val repository: UserActionLogRepository, private val repository: UserActionLogRepository,
private val orderRepository: OrderRepository,
private val policyRepository: PointRewardPolicyRepository, private val policyRepository: PointRewardPolicyRepository,
private val grantLogRepository: PointGrantLogRepository, private val grantLogRepository: PointGrantLogRepository,
private val memberPointRepository: MemberPointRepository, private val memberPointRepository: MemberPointRepository,
@ -27,7 +29,7 @@ class UserActionService(
fun recordAction( fun recordAction(
memberId: Long, memberId: Long,
actionType: ActionType, actionType: ActionType,
orderId: Long? = null, contentId: Long? = null,
pushTokenList: List<String> = emptyList() pushTokenList: List<String> = emptyList()
) { ) {
coroutineScope.launch { coroutineScope.launch {
@ -44,6 +46,17 @@ class UserActionService(
todayAt15 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( val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
memberId = memberId, memberId = memberId,
actionType = actionType, actionType = actionType,
@ -65,7 +78,7 @@ class UserActionService(
point = policy.pointAmount, point = policy.pointAmount,
actionType = actionType, actionType = actionType,
policyId = policy.id!!, policyId = policy.id!!,
orderId = orderId orderId = order?.id
) )
) )