fix: 구매하지 않은 콘텐츠에 댓글을 써도 ORDER_CONTENT_COMMENT 이벤트가 있으면 유저 행동 데이터에 기록되는 버그 수정
This commit is contained in:
parent
af352256e9
commit
dc13053825
|
@ -5,6 +5,7 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kr.co.vividnext.sodalive.content.order.OrderRepository
|
||||
import kr.co.vividnext.sodalive.fcm.FcmService
|
||||
import kr.co.vividnext.sodalive.point.MemberPoint
|
||||
|
@ -48,6 +49,35 @@ class UserActionService(
|
|||
) {
|
||||
coroutineScope.launch {
|
||||
val now = LocalDateTime.now()
|
||||
val policy = policyRepository.findByActionTypeAndIsActiveTrue(actionType, now)
|
||||
if (policy != null) {
|
||||
val policyType = policy.policyType
|
||||
val todayAt15 = now.toLocalDate().atTime(15, 0)
|
||||
val policyTypeDailyStartDate = if (now.toLocalTime().isBefore(todayAt15.toLocalTime())) {
|
||||
now.toLocalDate().minusDays(1).atTime(15, 0)
|
||||
} else {
|
||||
todayAt15
|
||||
}
|
||||
|
||||
val isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate =
|
||||
policyType == PolicyType.DAILY && policyTypeDailyStartDate >= policy.startDate
|
||||
val order = if (contentId != null) {
|
||||
orderRepository.findByMemberIdAndContentId(
|
||||
memberId = memberId,
|
||||
contentId = contentId,
|
||||
createdAt = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
|
||||
policyTypeDailyStartDate
|
||||
} else {
|
||||
policy.startDate
|
||||
}
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
if (actionType == ActionType.ORDER_CONTENT_COMMENT && order == null) return@launch
|
||||
}
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
transactionTemplate.execute {
|
||||
repository.save(
|
||||
UserActionLog(
|
||||
|
@ -58,16 +88,18 @@ class UserActionService(
|
|||
)
|
||||
repository.flush()
|
||||
}
|
||||
}
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
if (isAuth) {
|
||||
try {
|
||||
transactionTemplate.execute {
|
||||
entityManager.clear()
|
||||
val policy = policyRepository.findByActionTypeAndIsActiveTrue(actionType, now)
|
||||
if (policy != null) {
|
||||
val policyType = policy.policyType
|
||||
val todayAt15 = now.toLocalDate().atTime(15, 0)
|
||||
val policyTypeDailyStartDate = if (now.toLocalTime().isBefore(todayAt15.toLocalTime())) {
|
||||
val policyTypeDailyStartDate =
|
||||
if (now.toLocalTime().isBefore(todayAt15.toLocalTime())) {
|
||||
now.toLocalDate().minusDays(1).atTime(15, 0)
|
||||
} else {
|
||||
todayAt15
|
||||
|
@ -155,6 +187,7 @@ class UserActionService(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
fun onDestroy() {
|
||||
|
|
Loading…
Reference in New Issue