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

View File

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

View File

@ -8,21 +8,35 @@ import java.time.LocalDateTime
interface PointGrantLogRepository : JpaRepository<PointGrantLog, Long>, 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(
private val queryFactory: JPAQueryFactory
) : 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
.select(pointGrantLog.id)
.from(pointGrantLog)
.where(
pointGrantLog.memberId.eq(memberId),
pointGrantLog.policyId.eq(policyId),
pointGrantLog.createdAt.goe(startDate)
)
.where(where)
.fetch()
.size
}

View File

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

View File

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