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

Refactor: 포인트관련 로직을 포인트 서비스계층으로 통합, 개별 트랜잭션 적용, 테스트 코드 개선 #132

Merged
merged 10 commits into from
Nov 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,25 @@ private void earnPointForSinitto(Long sinittoMemberId) {
}

@Scheduled(cron = "0 */10 * * * *")
@Transactional
public void changeOldPendingCompleteToCompleteByPolicy() {

LocalDateTime referenceDateTimeForComplete = LocalDateTime.now().minusDays(DAYS_FOR_AUTO_COMPLETE);

List<Callback> callbacks = callbackRepository.findAllByStatusAndPendingCompleteTimeBefore(Callback.Status.PENDING_COMPLETE, referenceDateTimeForComplete);

for (Callback callback : callbacks) {

earnPointForSinitto(callback.getAssignedMemberId());
callback.changeStatusToComplete();
completeCallbackIndividually(callback);
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

transaction의 크기를 줄일 수 있어서 좋은 것 같습니다!!

@Transactional
public void completeCallbackIndividually(Callback callback) {

earnPointForSinitto(callback.getAssignedMemberId());
callback.changeStatusToComplete();

}

@Transactional
public void cancelCallbackAssignmentBySinitto(Long memberId, Long callbackId) {

Expand Down