From aa23d6d50f042abdad6824e9df57cf73f18c5563 Mon Sep 17 00:00:00 2001 From: Klaus Date: Mon, 19 May 2025 15:08:21 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A3=BC=EB=AC=B8=ED=95=9C=20=EC=BD=98?= =?UTF-8?q?=ED=85=90=EC=B8=A0=EC=97=90=20=EB=8C=93=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20-=20=ED=8F=AC?= =?UTF-8?q?=EC=9D=B8=ED=8A=B8=20=EB=B0=9B=EC=9D=80=20=ED=98=84=ED=99=A9?= =?UTF-8?q?=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=A0=20=EB=95=8C=20=EC=A3=BC?= =?UTF-8?q?=EB=AC=B8=20ID=EB=A5=BC=20=EA=B0=99=EC=9D=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=A7=8C=EB=93=A4?= =?UTF-8?q?=EC=96=B4=EC=84=9C=20=EC=A3=BC=EB=AC=B8=ED=95=9C=20=EC=BD=98?= =?UTF-8?q?=ED=85=90=EC=B8=A0=EC=97=90=20=EB=8C=93=EA=B8=80=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=EC=9D=98=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=A3=BC=EB=AC=B8=EB=B3=84=EB=A1=9C=20=EC=B0=B8?= =?UTF-8?q?=EC=97=AC=ED=95=A0=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/point/PointGrantLogRepository.kt | 28 ++++++++++++++----- .../sodalive/useraction/UserActionService.kt | 3 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/point/PointGrantLogRepository.kt b/src/main/kotlin/kr/co/vividnext/sodalive/point/PointGrantLogRepository.kt index 8862ab6..52a57c4 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/point/PointGrantLogRepository.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/point/PointGrantLogRepository.kt @@ -8,21 +8,35 @@ import java.time.LocalDateTime interface PointGrantLogRepository : JpaRepository, 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 } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt index 8e8d913..a0e92f5 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/useraction/UserActionService.kt @@ -97,7 +97,8 @@ class UserActionService( policyTypeDailyStartDate } else { policy.startDate - } + }, + orderId = order?.id ) if (grantedCount >= policy.availableCount) return@execute