Skip to content

Commit

Permalink
fix: payment fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeongh00 committed Aug 6, 2024
1 parent 253e473 commit 48a7231
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public void approval(String accessToken, ApprovalRequest request) {

Long m = value.getId();
Menu menu = menuQueryService.findMenuById(m);
int quantity = request.amount() / menu.getPrice();
Cart cart = cartQueryService.findCartByMenuId(menu.getId());
int quantity = cart.getQuantity();

final OrderItem orderItem = OrderItem.builder().order(order).menu(menu).quantity(quantity).build();
orderQueryService.saveOrderItem(orderItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public interface CartRepository extends JpaRepository<Cart, Long> {

Cart findCartByUserUserIdAndMenuId(Long userId, Long menuId);

Cart findCartByMenuId(Long menuId);

int countCartsByUserUserIdAndMenuId(Long userId, Long menuId);

Cart findCartByUserUserIdAndId(Long userId, Long cartId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public void saveCart(Cart cart) {
cartRepository.save(cart);
}

public Cart findCartByMenuId(Long menuId) {
return cartRepository.findCartByMenuId(menuId);
}

public Cart findCartById(Long cartId) {
return cartRepository.findById(cartId).orElseThrow(() -> new CartException(CartErrorCode.NO_CART_INFO));
}
Expand Down

0 comments on commit 48a7231

Please sign in to comment.