Skip to content

Commit 381d674

Browse files
committed
fix: 환급쿠폰 조회/발급시 -> 만료 조건 추가
1 parent 7c51148 commit 381d674

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/main/java/com/appcenter/marketplace/domain/member_payback/repository/MemberPaybackRepositoryCustomImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public boolean existCouponByMemberId(Long memberId, Long paybackId) {
3333
return jpaQueryFactory.selectFrom(memberPayback)
3434
.where(memberPayback.member.id.eq(memberId)
3535
.and(memberPayback.payback.id.eq(paybackId))
36-
.and(memberPayback.isPayback.eq(false))) // 사용하지 않은 쿠폰만 체크
36+
.and(memberPayback.isPayback.eq(false)) // 사용하지 않은 쿠폰 체크
37+
.and(memberPayback.isExpired.eq(false))) // 만료되지 않은 쿠폰 체크
3738
.fetchFirst() != null;
3839
}
3940

src/main/java/com/appcenter/marketplace/domain/payback/repository/PaybackRepositoryCustomImpl.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ public List<PaybackRes> findCouponsForMembersByMarketId(Long marketId, Long memb
5656
payback.description,
5757
Expressions.asEnum(CouponType.PAYBACK),
5858
memberId != null ?
59-
paybackCoupon.id.isNotNull().and(paybackCoupon.isPayback.eq(false)) :
60-
Expressions.FALSE))
59+
paybackCoupon.id.isNotNull() // true -> 발급 불가능
60+
.and(paybackCoupon.isPayback.eq(false)) // 환급 진행중 or 미사용
61+
.and(paybackCoupon.isExpired.eq(false)): // 만료 전
62+
Expressions.FALSE)) // false -> 발급 가능
6163
.from(payback)
6264
.join(market).on(payback.market.id.eq(market.id))
6365
.leftJoin(memberPayback).on(payback.eq(memberPayback.payback))
@@ -201,7 +203,9 @@ public List<CouponRes> findLatestPaybackList(Long memberId, LocalDateTime lastCr
201203
market.thumbnail,
202204
Expressions.TRUE, // Payback은 항상 available
203205
memberId != null ?
204-
savedPayback.id.isNotNull().and(savedPayback.isPayback.eq(false)) : // 다시 발급 받을 수 있음
206+
savedPayback.id.isNotNull()
207+
.and(savedPayback.isPayback.eq(false)) // 환급 진행중 or 미사용
208+
.and(savedPayback.isExpired.eq(false)): // 만료 전
205209
Expressions.FALSE,
206210
payback.createdAt,
207211
Expressions.asEnum(CouponType.PAYBACK)
@@ -236,7 +240,9 @@ public List<CouponRes> findPopularPaybackList(Long memberId, Integer lastOrderNo
236240
market.thumbnail,
237241
Expressions.TRUE, // Payback은 항상 available
238242
memberId != null ?
239-
savedPayback.id.isNotNull().and(savedPayback.isPayback.eq(false)) :
243+
savedPayback.id.isNotNull()
244+
.and(savedPayback.isPayback.eq(false)) // 환급 진행 중 or 미사용상태
245+
.and(savedPayback.isExpired.eq(false)) : // 만료전
240246
Expressions.FALSE,
241247
issuedPayback.id.count(),
242248
market.orderNo, // orderNo 추가

0 commit comments

Comments
 (0)