From 890639f6a7b21eab9e1d4dbbd9f90a353c80132c Mon Sep 17 00:00:00 2001 From: yang Date: Sun, 3 Mar 2024 03:06:04 +0900 Subject: [PATCH] =?UTF-8?q?RAC-304=20fix=20:=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EA=B0=B1=EC=8B=A0=EC=8B=9C=20update=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/usecase/MentoringManageUseCase.java | 6 +++--- .../mentoring/domain/service/MentoringGetService.java | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java index 04c0e193..a23069b9 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java +++ b/src/main/java/com/postgraduate/domain/mentoring/application/usecase/MentoringManageUseCase.java @@ -143,11 +143,11 @@ public void updateAutoCancel() { @Transactional public void updateCancelWithAuto(Mentoring mentoring) { try { - Mentoring cancelMentoring = mentoringGetService.byMentoringId(mentoring.getMentoringId()); + paymentManageUseCase.refundPayByUser(mentoring.getUser(), mentoring.getPayment().getOrderId()); + Mentoring cancelMentoring = mentoringGetService.byMentoringIdWithLazy(mentoring.getMentoringId()); mentoringUpdateService.updateStatus(cancelMentoring, CANCEL); Refuse refuse = RefuseMapper.mapToRefuse(mentoring); refuseSaveService.save(refuse); - paymentManageUseCase.refundPayByUser(mentoring.getUser(), mentoring.getPayment().getOrderId()); log.info("mentoringId : {} 자동 취소", mentoring.getMentoringId()); } catch (Exception ex) { log.error("mentoringId : {} 자동 취소 실패", mentoring.getMentoringId()); @@ -175,7 +175,7 @@ public void updateAutoDone() { @Transactional public void updateDoneWithAuto(Mentoring mentoring) { try { - Mentoring doneMentoring = mentoringGetService.byMentoringId(mentoring.getMentoringId()); + Mentoring doneMentoring = mentoringGetService.byMentoringIdWithLazy(mentoring.getMentoringId()); mentoringUpdateService.updateStatus(doneMentoring, DONE); Senior senior = mentoring.getSenior(); Salary salary = salaryGetService.bySenior(senior); diff --git a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java index d1795dc0..bae74802 100644 --- a/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java +++ b/src/main/java/com/postgraduate/domain/mentoring/domain/service/MentoringGetService.java @@ -48,6 +48,11 @@ public Mentoring byMentoringId(Long mentoringId) { .orElseThrow(MentoringNotFoundException::new); } + public Mentoring byMentoringIdWithLazy(Long mentoringId) { + return mentoringRepository.findById(mentoringId) + .orElseThrow(MentoringNotFoundException::new); + } + public List byStatusAndCreatedAt(Status status, LocalDateTime now) { return mentoringRepository.findAllByStatusAndCreatedAtIsBefore(status, now); }