Compare commits

..

3 Commits

Author SHA1 Message Date
Klaus aa23d6d50f fix: 주문한 콘텐츠에 댓글 작성 이벤트
- 포인트 받은 현황을 조회할 때 주문 ID를 같이 조회하도록 만들어서 주문한 콘텐츠에 댓글 작성 이벤트의 경우 주문별로 참여할 수 있도록 수정
2025-05-19 15:08:21 +09:00
Klaus 6df043dfac fix: 콘텐츠 댓글 작성시 유저 행동 데이터에 댓글 ID를 같이 기록하도록 수정 2025-05-19 15:05:31 +09:00
Klaus fe84292483 fix: 포인트 지급 요소 계산시 정책 시작 날짜 이후의 유저 행동들만 반영하도록 수정 2025-05-19 14:43:50 +09:00
5 changed files with 45 additions and 16 deletions

View File

@ -29,7 +29,7 @@ class AudioContentCommentController(
) = run { ) = run {
if (member == null) throw SodaException("로그인 정보를 확인해주세요.") if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
service.registerComment( val commentId = service.registerComment(
comment = request.comment, comment = request.comment,
audioContentId = request.contentId, audioContentId = request.contentId,
parentId = request.parentId, parentId = request.parentId,
@ -44,6 +44,7 @@ class AudioContentCommentController(
userActionService.recordAction( userActionService.recordAction(
memberId = member.id!!, memberId = member.id!!,
actionType = ActionType.CONTENT_COMMENT, actionType = ActionType.CONTENT_COMMENT,
commentId = commentId,
pushTokenList = pushTokenList pushTokenList = pushTokenList
) )
@ -51,6 +52,7 @@ class AudioContentCommentController(
memberId = member.id!!, memberId = member.id!!,
actionType = ActionType.ORDER_CONTENT_COMMENT, actionType = ActionType.ORDER_CONTENT_COMMENT,
contentId = request.contentId, contentId = request.contentId,
commentId = commentId,
pushTokenList = pushTokenList pushTokenList = pushTokenList
) )
} catch (_: Exception) { } catch (_: Exception) {

View File

@ -33,7 +33,7 @@ class AudioContentCommentService(
audioContentId: Long, audioContentId: Long,
parentId: Long? = null, parentId: Long? = null,
isSecret: Boolean = false isSecret: Boolean = false
) { ): Long {
val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId) val audioContent = audioContentRepository.findByIdOrNull(id = audioContentId)
?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.") ?: throw SodaException("잘못된 콘텐츠 입니다.\n다시 시도해 주세요.")
@ -64,7 +64,7 @@ class AudioContentCommentService(
audioContentComment.parent = parent audioContentComment.parent = parent
} }
repository.save(audioContentComment) val savedContentComment = repository.save(audioContentComment)
applicationEventPublisher.publishEvent( applicationEventPublisher.publishEvent(
FcmEvent( FcmEvent(
@ -84,6 +84,8 @@ class AudioContentCommentService(
myMemberId = member.id myMemberId = member.id
) )
) )
return savedContentComment.id!!
} }
@Transactional @Transactional

View File

@ -8,21 +8,35 @@ import java.time.LocalDateTime
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, PointGrantLogQueryRepository
interface PointGrantLogQueryRepository { interface PointGrantLogQueryRepository {
fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int fun countByMemberIdAndPolicyIdAndStartDate(
memberId: Long,
policyId: Long,
startDate: LocalDateTime,
orderId: Long? = null
): Int
} }
class PointGrantLogQueryRepositoryImpl( class PointGrantLogQueryRepositoryImpl(
private val queryFactory: JPAQueryFactory private val queryFactory: JPAQueryFactory
) : PointGrantLogQueryRepository { ) : PointGrantLogQueryRepository {
override fun countByMemberIdAndPolicyIdAndStartDate(memberId: Long, policyId: Long, startDate: LocalDateTime): Int { override fun countByMemberIdAndPolicyIdAndStartDate(
memberId: Long,
policyId: Long,
startDate: LocalDateTime,
orderId: Long?
): Int {
var where = pointGrantLog.memberId.eq(memberId)
.and(pointGrantLog.policyId.eq(policyId))
.and(pointGrantLog.createdAt.goe(startDate))
if (orderId != null) {
where = where.and(pointGrantLog.orderId.eq(orderId))
}
return queryFactory return queryFactory
.select(pointGrantLog.id) .select(pointGrantLog.id)
.from(pointGrantLog) .from(pointGrantLog)
.where( .where(where)
pointGrantLog.memberId.eq(memberId),
pointGrantLog.policyId.eq(policyId),
pointGrantLog.createdAt.goe(startDate)
)
.fetch() .fetch()
.size .size
} }

View File

@ -9,5 +9,6 @@ import javax.persistence.Enumerated
data class UserActionLog( data class UserActionLog(
val memberId: Long, val memberId: Long,
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
val actionType: ActionType val actionType: ActionType,
val commentId: Long? = null
) : BaseEntity() ) : BaseEntity()

View File

@ -33,12 +33,19 @@ class UserActionService(
memberId: Long, memberId: Long,
actionType: ActionType, actionType: ActionType,
contentId: Long? = null, contentId: Long? = null,
commentId: Long? = null,
pushTokenList: List<String> = emptyList() pushTokenList: List<String> = emptyList()
) { ) {
coroutineScope.launch { coroutineScope.launch {
val now = LocalDateTime.now() val now = LocalDateTime.now()
transactionTemplate.execute { transactionTemplate.execute {
repository.save(UserActionLog(memberId, actionType)) repository.save(
UserActionLog(
memberId = memberId,
actionType = actionType,
commentId = commentId
)
)
repository.flush() repository.flush()
} }
@ -54,11 +61,13 @@ class UserActionService(
todayAt15 todayAt15
} }
val isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate =
policyType == PolicyType.DAILY && policyTypeDailyStartDate >= policy.startDate
val order = if (contentId != null) { val order = if (contentId != null) {
orderRepository.findByMemberIdAndContentId( orderRepository.findByMemberIdAndContentId(
memberId = memberId, memberId = memberId,
contentId = contentId, contentId = contentId,
createdAt = if (policyType == PolicyType.DAILY) { createdAt = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
@ -72,7 +81,7 @@ class UserActionService(
val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween( val actionCount = repository.countByMemberIdAndActionTypeAndCreatedAtBetween(
memberId = memberId, memberId = memberId,
actionType = actionType, actionType = actionType,
startDate = if (policyType == PolicyType.DAILY) { startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
@ -84,11 +93,12 @@ class UserActionService(
val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate( val grantedCount = grantLogRepository.countByMemberIdAndPolicyIdAndStartDate(
memberId, memberId,
policy.id!!, policy.id!!,
startDate = if (policyType == PolicyType.DAILY) { startDate = if (isValidPolicyTypeDailyAndDailyStartDateAfterPolicyStartDate) {
policyTypeDailyStartDate policyTypeDailyStartDate
} else { } else {
policy.startDate policy.startDate
} },
orderId = order?.id
) )
if (grantedCount >= policy.availableCount) return@execute if (grantedCount >= policy.availableCount) return@execute