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); }