-
Notifications
You must be signed in to change notification settings - Fork 2
prod : 환불 처리 및 신청 #306
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
prod : 환불 처리 및 신청 #306
Changes from all commits
9716879
37b8e9c
04fe08c
0fc0ead
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||||||||||||||||||||||
| package life.mosu.mosuserver.application.refund; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import life.mosu.mosuserver.application.refund.processor.TossRefundProcessor; | ||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.payment.entity.PaymentJpaEntity; | ||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.payment.entity.PaymentStatus; | ||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.payment.projection.PaymentWithLunchProjection; | ||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.payment.repository.PaymentJpaRepository; | ||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.refund.entity.RefundJpaEntity; | ||||||||||||||||||||||||||
|
|
@@ -48,14 +50,23 @@ public void doProcess(Long userId, MergedRefundRequest request) { | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| PaymentWithLunchProjection targetPayment = findPaymentOrThrow(paymentKey, | ||||||||||||||||||||||||||
| examApplicationId); | ||||||||||||||||||||||||||
| log.info("target payment log : {}", targetPayment); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| int totalQuantity = getTotalPaymentCount(paymentKey); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| log.info("total quantity log : {}", totalQuantity); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| int refundAmount = calculateRefundAmount(totalQuantity, targetPayment.lunchChecked()); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RefundJpaEntity refundEntity = processRefund(request, refundAmount, | ||||||||||||||||||||||||||
| targetPayment.examApplicationId()); | ||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||
| refundJpaRepository.save(refundEntity); | ||||||||||||||||||||||||||
| PaymentJpaEntity payment = paymentJpaRepository.findByExamApplicationId( | ||||||||||||||||||||||||||
| targetPayment.examApplicationId()) | ||||||||||||||||||||||||||
| .orElseThrow(() -> new CustomRuntimeException(ErrorCode.PAYMENT_NOT_FOUND)); | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| payment.changeStatus(PaymentStatus.ABORTED); | ||||||||||||||||||||||||||
|
Comment on lines
64
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good practice to fetch required entities and perform validations before making state changes like saving a new entity. By fetching the
Suggested change
|
||||||||||||||||||||||||||
| eventTxService.publishSuccessEvent(refundEntity.getTransactionKey(), refundAmount, | ||||||||||||||||||||||||||
| userId, targetPayment.examId(), examApplicationId); | ||||||||||||||||||||||||||
| } catch (Exception e) { | ||||||||||||||||||||||||||
|
|
@@ -75,7 +86,8 @@ private PaymentWithLunchProjection findPaymentOrThrow(String paymentKey, | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private int getTotalPaymentCount(String paymentKey) { | ||||||||||||||||||||||||||
| return paymentJpaRepository.findByPaymentKey(paymentKey).size(); | ||||||||||||||||||||||||||
| return paymentJpaRepository.findByPaymentKeyAndPaymentStatus(paymentKey, PaymentStatus.DONE) | ||||||||||||||||||||||||||
| .size(); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private int calculateRefundAmount(int totalQuantity, boolean lunchChecked) { | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These log statements appear to be for debugging. It's recommended to use the
DEBUGlevel for such detailed tracing to avoid clutteringINFOlogs in production environments.INFOlogs are generally reserved for significant application state changes.