|
5 | 5 | import java.util.Collections; |
6 | 6 | import java.util.List; |
7 | 7 |
|
8 | | -import camp.woowak.lab.cart.domain.vo.CartItem; |
9 | 8 | import camp.woowak.lab.customer.domain.Customer; |
10 | | -import camp.woowak.lab.menu.exception.NotEnoughStockException; |
11 | 9 | import camp.woowak.lab.order.domain.vo.OrderItem; |
12 | | -import camp.woowak.lab.order.exception.EmptyCartException; |
13 | | -import camp.woowak.lab.order.exception.MinimumOrderPriceNotMetException; |
14 | | -import camp.woowak.lab.order.exception.MultiStoreOrderException; |
15 | | -import camp.woowak.lab.order.exception.NotFoundMenuException; |
16 | | -import camp.woowak.lab.payaccount.exception.InsufficientBalanceException; |
17 | | -import camp.woowak.lab.payaccount.exception.NotFoundAccountException; |
18 | 10 | import camp.woowak.lab.store.domain.Store; |
19 | | -import camp.woowak.lab.store.exception.NotFoundStoreException; |
20 | 11 | import camp.woowak.lab.vendor.domain.Vendor; |
21 | 12 | import jakarta.persistence.CollectionTable; |
22 | 13 | import jakarta.persistence.ElementCollection; |
@@ -54,37 +45,12 @@ public class Order { |
54 | 45 |
|
55 | 46 | private LocalDateTime createdAt; |
56 | 47 |
|
57 | | - /** |
58 | | - * @throws EmptyCartException 카트가 비어 있는 경우 |
59 | | - * @throws NotFoundStoreException 가게가 조회되지 않는 경우 |
60 | | - * @throws MultiStoreOrderException 여러 가게의 메뉴를 주문한 경우 |
61 | | - * @throws NotEnoughStockException 메뉴의 재고가 부족한 경우 |
62 | | - * @throws NotFoundMenuException 주문한 메뉴가 조회되지 않는 경우 |
63 | | - * @throws MinimumOrderPriceNotMetException 가게의 최소 주문금액보다 적은 금액을 주문한 경우 |
64 | | - * @throws NotFoundAccountException 구매자의 계좌가 조회되지 않는 경우 |
65 | | - * @throws InsufficientBalanceException 구매자의 계좌에 잔액이 충분하지 않은 경우 |
66 | | - */ |
67 | | - public Order(Customer requester, List<CartItem> cartItems, |
68 | | - SingleStoreOrderValidator singleStoreOrderValidator, |
69 | | - StockRequester stockRequester, PriceChecker priceChecker, WithdrawPointService withdrawPointService, |
70 | | - LocalDateTime createdAt) { |
71 | | - Store store = singleStoreOrderValidator.check(cartItems); |
72 | | - |
73 | | - List<CartItem> stockDecreaseSuccessCartItems = null; |
74 | | - try { |
75 | | - stockDecreaseSuccessCartItems = stockRequester.request(cartItems); |
76 | | - List<OrderItem> orderItems = priceChecker.check(store, cartItems); |
77 | | - withdrawPointService.withdraw(requester, orderItems); |
78 | | - this.requester = requester; |
79 | | - this.store = store; |
80 | | - this.orderItems = orderItems; |
81 | | - this.createdAt = createdAt; |
82 | | - } catch (Exception e) { |
83 | | - if (stockDecreaseSuccessCartItems != null) { |
84 | | - stockRequester.rollback(stockDecreaseSuccessCartItems); |
85 | | - } |
86 | | - throw e; |
87 | | - } |
| 48 | + public Order(Customer requester |
| 49 | + , Store store, List<OrderItem> orderItems, LocalDateTime createdAt) { |
| 50 | + this.requester = requester; |
| 51 | + this.store = store; |
| 52 | + this.orderItems = orderItems; |
| 53 | + this.createdAt = createdAt; |
88 | 54 | } |
89 | 55 |
|
90 | 56 | public Customer getRequester() { |
|
0 commit comments