Skip to content

Commit a1c38fd

Browse files
committed
refactor: 쿠폰 사용 코드 단순화
1 parent acc965b commit a1c38fd

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/application/order/OrderFacade.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,12 @@ public OrderInfo placeOrder(OrderPlaceCommand command) {
5959
Long couponId = command.couponId();
6060

6161
if (couponId != null) {
62-
try {
63-
Coupon coupon = couponService.getCouponWithOptimisticLock(couponId);
64-
couponService.validateCouponUsable(coupon, user);
65-
66-
discountAmount = coupon.calculateDiscount(totalAmount);
67-
coupon.use();
68-
couponService.save(coupon);
69-
} catch (ObjectOptimisticLockingFailureException e) {
70-
throw new CoreException(ErrorType.CONFLICT,
71-
"쿠폰이 이미 사용 중입니다. 잠시 후 다시 시도해주세요.");
72-
}
62+
Coupon coupon = couponService.getCouponWithOptimisticLock(couponId);
63+
couponService.validateCouponUsable(coupon, user);
64+
65+
discountAmount = coupon.calculateDiscount(totalAmount);
66+
coupon.use();
67+
couponService.save(coupon);
7368
}
7469
long finalAmount = totalAmount - discountAmount;
7570
pointService.usePointWithLock(user.getUserIdValue(), finalAmount);

0 commit comments

Comments
 (0)