test #316
|
@ -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
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ class UserActionService(
|
|||
policyTypeDailyStartDate
|
||||
} else {
|
||||
policy.startDate
|
||||
}
|
||||
},
|
||||
orderId = order?.id
|
||||
)
|
||||
if (grantedCount >= policy.availableCount) return@execute
|
||||
|
||||
|
|
Loading…
Reference in New Issue