Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✏️ 쿠폰 발급완료 사용여부 수정, 쿠폰조회 중복 수정 #53

Merged
merged 5 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/kr/bb/store/client/ProductFeignClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ default CommonResponse<StoreSubscriptionProductId> getSubscriptionProductIdFallb
log.warn("{}'s Request of '{}' failed. request will return fallback data",
"ProductFeignClient", "getSubscriptionProductIdFallback");
return CommonResponse.<StoreSubscriptionProductId>builder()
.data(null)
.data(StoreSubscriptionProductId.builder()
.subscriptionProductId(null)
.build()
)
.message("data from circuit")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void useCoupons(ProcessOrderDto processOrderDto) {
Long userId = processOrderDto.getUserId();
String phoneNumber = processOrderDto.getPhoneNumber();
orderStatusSQSPublisher.publish(userId, phoneNumber, NotificationKind.INVALID_COUPON);
throw e;
log.error("coupon use failed with cause of {}", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,10 @@ public List<CouponWithIssueStatusDto> findStoreCouponsForUser(Long userId, Long
.where(
issuedCoupon.id.couponId.eq(coupon.id),
issuedCoupon.id.userId.eq(userId),
issuedCoupon.isUsed.isFalse(),
coupon.isDeleted.isFalse()
)
))
.from(coupon)
.leftJoin(issuedCoupon)
.on(coupon.id.eq(issuedCoupon.id.couponId))
.where(
coupon.store.id.eq(storeId),
isCouponUnexpired(now),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ public Integer getMyAvailableCouponCount(Long userId, LocalDate now) {
}

public void validateCouponPrice(List<ValidatePriceDto> validatePriceDtos) {
validatePriceDtos.forEach(dto -> {
Coupon coupon = couponReader.read(dto.getCouponId());
Long receivedPaymentPrice = dto.getActualAmount();
Long receivedDiscountPrice = dto.getCouponAmount();
if(!coupon.isRightPrice(receivedPaymentPrice, receivedDiscountPrice)) {
throw new CouponInconsistencyException();
}
validatePriceDtos.stream()
.filter(dto -> dto.getCouponId() != null)
.forEach(dto -> {
Coupon coupon = couponReader.read(dto.getCouponId());
Long receivedPaymentPrice = dto.getActualAmount();
Long receivedDiscountPrice = dto.getCouponAmount();
if(!coupon.isRightPrice(receivedPaymentPrice, receivedDiscountPrice)) {
throw new CouponInconsistencyException();
}
});
}

Expand Down
Loading