Skip to content

Commit

Permalink
Fix: 결제에서 유저 정보 가져오지 못하던 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Taekgil99 committed Nov 30, 2022
1 parent 807b6e1 commit 57e5687
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity find(@CurrentUser CustomUserDetails authUser) {
@PostMapping("/{order-id}")
public ResponseEntity pay(@CurrentUser CustomUserDetails authUser, @PathVariable("order-id") @Positive long orderId) {
Order order = orderRepository.findById(orderId).orElseThrow(EntityNotFoundException::new);
pointService.pay(order);
pointService.pay(order, authUser.getUser().getUserId());

return new ResponseEntity<>(HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,16 @@ public int getRestCash(User user) {
}

@Transactional
public void pay(Order order) {
public void pay(Order order, Long userId) {
log.info("service / 포인트로 상품결제 시작");
User user = order.getUser();
User user = userRepository.findById(userId).orElseThrow(() -> new BusinessLogicException(ExceptionCode.USER_NOT_FOUND));
int restCash = user.getRestCash();
int payPrice = order.getOrderTotalPrice();
if (payPrice > restCash) {
throw new BusinessLogicException(ExceptionCode.NOT_ENOUGH_POINT);

}
addCash(user, payPrice * -1, PointType.PayPoint);
orderRepository.save(order);

}

public Page<PointResponseDto> getPointList(Long userId, Pageable pageable) {
Expand Down

0 comments on commit 57e5687

Please sign in to comment.