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

[#46] 경매 상품 결제(포인트) 기능 추가 #47

Merged
merged 8 commits into from
Dec 1, 2024
Merged

Conversation

JIWON27
Copy link
Collaborator

@JIWON27 JIWON27 commented Nov 23, 2024

경매 상품 결제(포인트) 기능 추가

@JIWON27 JIWON27 self-assigned this Nov 23, 2024
@JIWON27 JIWON27 linked an issue Nov 23, 2024 that may be closed by this pull request
Copy link
Collaborator

@f-lab-moony f-lab-moony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니다 ~
피드백 확인 부탁드려요 ~

}

// 포인트 사용
@PostMapping("/deduct")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거는 말씀하신거처럼 배치에서 낙찰자 판단하고 거기서 차감하는게 맞지 않을까 싶네요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 그러네요!! 필요없는 API네용.. 삭제하겠습니다!


}

private static void validateDeductPoint(PointAmount pointAmount, User user, Point point) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

배치에서 차감을 한다고 할 때, 이 사람이 다른 경매도 참여해서 실제 결제시에는 포인트가 부족할 수도 있겠네요!
그거에 대한 생각도 해보면 좋을 것 같아요!

Copy link
Collaborator Author

@JIWON27 JIWON27 Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

경매 입찰 시도할때 가격만큼 포인트에서 차감을 시킨 다음에 낙찰받지 못하면 다시 포인트 돌려주는 방식으로 포인트 부족 문제를 해결할 수 있을꺼같은데 이 방식은 어떤지 궁금합니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요건 저번 멘토링때 얘기 나눴던 것 같네요! 전 좋은 방법 같습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 감사합니다!

}

// 포인트 충전
public int chargePoint(CustomUserDetails userDetails, PointAmount pointAmount) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

트랜잭션이 안 걸린 것 같아요 ~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 자꾸... ㅠㅠ
추가하도록 하겠습니다!

@@ -77,8 +77,7 @@ private Long processBid(CustomUserDetails user, BidRequest bidRequest, Long prod
throw new BiddingFailException(user.getUser().getUserId(), bidRequest.getBiddingPrice(), productId);
}
// 포인트 돌려주기
PointAmount pointAmount = new PointAmount(userIdAndCurrentPrice.getSecond().intValue());
pointService.chargePoint(user, pointAmount);
pointService.rollbackPoint(userIdAndCurrentPrice.getFirst(), userIdAndCurrentPrice.getSecond().intValue());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis 최고가 정보 변경 전에 포인트를 롤백해주도록 추가했습니다.
이러면 실제 결제 시 포인트 부족 문제를 해결할 수 있을 것 같습니다!
혹시 제가 놓치고 있는 부분이 있을까요?!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

지금은 괜찮아보여요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 감사합니다~!

@@ -83,6 +86,9 @@ private void isBiddingAvailable(CustomUserDetails user, BidRequest bidRequest, L
if (biddingRequestTime.isAfter(product.getCloseDate())) {
throw new BiddingFailException(user.getUser().getUserId(), bidRequest.getBiddingPrice(), productId);
}

PointAmount pointAmount = new PointAmount(bidRequest.getBiddingPrice());
pointService.deductPoint(user, pointAmount);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

경매 입찰이 가능한지 검증하는 메서드쪽에 포인트 차감하는 코드를 추가했습니다

Copy link

sonarcloud bot commented Nov 26, 2024

Copy link
Collaborator

@f-lab-moony f-lab-moony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생 많으셨습니다 ~ 이번 PR은 머지하도록 할게요!

@f-lab-moony f-lab-moony merged commit 4163bea into main Dec 1, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚨 경매 상품 결제(포인트)
2 participants