fix: 주문한 콘텐츠에 댓글 작성 이벤트

- 포인트 받은 현황을 조회할 때 주문 ID를 같이 조회하도록 만들어서 주문한 콘텐츠에 댓글 작성 이벤트의 경우 주문별로 참여할 수 있도록 수정
This commit is contained in:
Klaus 2025-05-19 15:08:21 +09:00
parent 6df043dfac
commit aa23d6d50f
2 changed files with 23 additions and 8 deletions

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

@ -97,7 +97,8 @@ class UserActionService(
policyTypeDailyStartDate
} else {
policy.startDate
}
},
orderId = order?.id
)
if (grantedCount >= policy.availableCount) return@execute