Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package life.mosu.mosuserver.application.notify;

import life.mosu.mosuserver.application.notify.dto.ApplicationGuestNotifyRequest;
import life.mosu.mosuserver.application.notify.dto.ApplicationNotifyRequest;
import life.mosu.mosuserver.application.notify.dto.Exam1DayBeforeNotifyRequest;
import life.mosu.mosuserver.application.notify.dto.Exam1WeekBeforeNotifyRequest;
Expand Down Expand Up @@ -39,6 +40,8 @@ public LunaNotificationVariable create(LunaNotificationEvent event) {
case REFUND_SUCCESS -> createRefundVariable(event.targetId()); //
case APPLICATION_SUCCESS ->
createApplicationVariable(event.targetId()); // examApplicationId
case APPLICATION_GUEST_SUCCESS ->
createApplicationGuestVariable(event.targetId()); // examApplicationId
case EXAM_1WEEK_BEFORE_REMINDER_INFO ->
createExam1WeekBeforeVariable(event.targetId()); // examApplicationId
case EXAM_3DAY_BEFORE_REMINDER_INFO ->
Expand Down Expand Up @@ -81,6 +84,14 @@ private LunaNotificationVariable createApplicationVariable(Long targetId) {
return ApplicationNotifyRequest.from(projection);
}

private LunaNotificationVariable createApplicationGuestVariable(Long targetId) {
ExamApplicationNotifyProjection projection = examApplicationRepository.findExamAndPaymentByExamApplicationId(
targetId)
.orElseThrow(
() -> new CustomRuntimeException(ErrorCode.EXAM_APPLICATION_NOT_FOUND));
return ApplicationGuestNotifyRequest.from(projection);
}
Comment on lines +87 to +93

Choose a reason for hiding this comment

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

medium

새로 추가된 createApplicationGuestVariable 메소드의 내용은 createApplicationVariable 메소드(79-85행)와 거의 동일합니다. 코드 중복은 유지보수성을 저해할 수 있으므로, 공통 로직( ExamApplicationNotifyProjection 조회)을 별도의 private 메소드로 추출하여 중복을 제거하는 것을 고려해 보시는 것이 좋겠습니다.


private LunaNotificationVariable createExam1WeekBeforeVariable(Long targetId) {
ExamInfoProjection examInfo = examApplicationRepository.findExamInfo(targetId)
.orElseThrow(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package life.mosu.mosuserver.application.notify.dto;


import static life.mosu.mosuserver.infra.notify.constant.NotifyRedirectUrlConstants.WARNING_PAGE;

import java.time.LocalDate;
import java.util.Map;
import life.mosu.mosuserver.domain.examapplication.projection.ExamApplicationNotifyProjection;
import life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationButtonUrls;
import life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationButtonUrls.NotificationButtonUrl;
import life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationVariable;

public record ApplicationGuestNotifyRequest(
String paymentKey,
LocalDate examDate,
String schoolName,
String lunch
) implements LunaNotificationVariable {

public static ApplicationGuestNotifyRequest from(
ExamApplicationNotifyProjection examApplication) {

return new ApplicationGuestNotifyRequest(examApplication.paymentKey(),
examApplication.examDate(), examApplication.schoolName(),
examApplication.isLunchChecked() ? examApplication.lunchName()
: "선택 안 함");

Choose a reason for hiding this comment

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

medium

하드코딩된 문자열 "선택 안 함"은 상수로 정의하여 사용하는 것이 좋습니다. 이렇게 하면 가독성이 향상되고 향후 값을 변경해야 할 때 유지보수가 용이해집니다. 예를 들어, record 내부에 private static final String LUNCH_NOT_SELECTED = "선택 안 함";과 같이 상수를 선언하고 사용할 수 있습니다.

}

@Override
public LunaNotificationButtonUrls getNotificationButtonUrls() {
return LunaNotificationButtonUrls.of(
NotificationButtonUrl.of(WARNING_PAGE, WARNING_PAGE)
);
}

@Override
public Map<String, String> toMap() {
return Map.of(
"paymentKey", paymentKey,
"examDate", examDate.toString(),
"schoolName", schoolName,
"lunch", lunch
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void handle(DepositSuccessEvent event) {
() -> new CustomRuntimeException(ErrorCode.EXAM_APPLICATION_NOT_FOUND));

LunaNotificationEvent lunaNotificationEvent = LunaNotificationEvent.create(
LunaNotificationStatus.APPLICATION_SUCCESS,
LunaNotificationStatus.APPLICATION_GUEST_SUCCESS,
exam.getUserId(), exam.getId());

notifier.notify(lunaNotificationEvent);
sendMail(log, event.getFormattedCreatedAt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,6 @@ public void changePassword(String newPassword) {
}

public String getPhoneNumber() {
return phoneNumber.replaceFirst("^.", "");
return phoneNumber.replaceFirst("^[UG]", "");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package life.mosu.mosuserver.infra.notify.component.luna;

import static life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationStatus.APPLICATION_GUEST_SUCCESS;
import static life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationStatus.APPLICATION_SUCCESS;
import static life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationStatus.EXAM_1DAY_BEFORE_REMINDER_INFO;
import static life.mosu.mosuserver.infra.notify.dto.luna.LunaNotificationStatus.EXAM_1WEEK_BEFORE_REMINDER_INFO;
Expand All @@ -23,6 +24,7 @@
@Component
@NotifyStrategyMapping({
APPLICATION_SUCCESS,
APPLICATION_GUEST_SUCCESS,
REFUND_SUCCESS,
EXAM_1DAY_BEFORE_REMINDER_INFO,
EXAM_3DAY_BEFORE_REMINDER_INFO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public enum LunaNotificationStatus {
// 성공 알림
SIGN_UP_SUCCESS("회원 가입 완료", LunaNotifyTemplateCode.SIGN_UP),
APPLICATION_SUCCESS("신청 완료", LunaNotifyTemplateCode.APPLICATION),
APPLICATION_GUEST_SUCCESS("게스트 신청 완료", LunaNotifyTemplateCode.APPLICATION_GUEST),

REFUND_SUCCESS("환불 완료", LunaNotifyTemplateCode.REFUND),
INQUIRY_ANSWER_SUCCESS("문의 답변 완료", LunaNotifyTemplateCode.INQUIRY_ANSWER),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public enum LunaNotifyTemplateCode {
"notify.exam.application.complete.alimtalk",
"notify.exam.application.complete.sms"
),
APPLICATION_GUEST(
50051,
"notify.exam.guest.application.complete.alimtalk",
"notify.exam.guest.application.complete.sms"
),
EXAM_1DAY_BEFORE(
50047,
"notify.exam.oneday.reminder.alimtalk",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import jakarta.validation.Valid;
import life.mosu.mosuserver.application.payment.PaymentConfirmService;
import life.mosu.mosuserver.application.payment.PaymentPrepareService;
import life.mosu.mosuserver.application.payment.cron.PaymentFailureLogDomainArchiveExecutor;
import life.mosu.mosuserver.global.annotation.UserId;
import life.mosu.mosuserver.global.util.ApiResponseWrapper;
import life.mosu.mosuserver.presentation.payment.dto.PaymentPrepareResponse;
Expand All @@ -23,12 +24,13 @@ public class PaymentWidgetController {

private final PaymentPrepareService prepareService;
private final PaymentConfirmService confirmService;
private final PaymentFailureLogDomainArchiveExecutor paymentFailureLogDomainArchiveExecutor;

/**
* 결제 준비 요청
* <p>
* 결제 준비 요청은 결제 시작을 위한 준비 단계로, 결제 금액과 주문 ID를 생성합니다.
* 이 단계에서는 실제 결제가 이루어지지 않으며, 결제 승인 요청을 위한 정보를 반환합니다.
* 결제 준비 요청은 결제 시작을 위한 준비 단계로, 결제 금액과 주문 ID를 생성합니다. 이 단계에서는 실제 결제가 이루어지지 않으며, 결제 승인 요청을 위한 정보를
* 반환합니다.
*
* @param userId 사용자 ID
* @param request 결제 준비 요청 정보
Expand Down Expand Up @@ -59,4 +61,12 @@ public ApiResponseWrapper<Void> confirm(
confirmService.confirm(userId, request);
return ApiResponseWrapper.success(HttpStatus.CREATED, "결제 승인 성공");
}


@PostMapping("/cleanup")
@PreAuthorize("isAuthenticated() and hasRole('ADMIN')")
public ApiResponseWrapper<Void> archivePaymentFailureLogs() {
paymentFailureLogDomainArchiveExecutor.archive();
return ApiResponseWrapper.success(HttpStatus.CREATED, "게스트 결제 승인 성공");

Choose a reason for hiding this comment

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

medium

archivePaymentFailureLogs 메소드는 결제 실패 로그를 아카이빙하는 기능을 수행하지만, API 성공 응답 메시지가 "게스트 결제 승인 성공"으로 되어 있어 기능과 일치하지 않습니다. 혼란을 방지하기 위해 메시지를 "결제 실패 로그 아카이빙 성공"과 같이 실제 기능에 맞게 수정하는 것이 좋겠습니다.

Suggested change
return ApiResponseWrapper.success(HttpStatus.CREATED, "게스트 결제 승인 성공");
return ApiResponseWrapper.success(HttpStatus.CREATED, "결제 실패 로그 아카이빙 성공");

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package life.mosu.mosuserver.presentation.refund;

import life.mosu.mosuserver.application.refund.RefundService;
import life.mosu.mosuserver.application.refund.cron.RefundFailureLogDomainArchiveExecutor;
import life.mosu.mosuserver.global.annotation.UserId;
import life.mosu.mosuserver.global.util.ApiResponseWrapper;
import life.mosu.mosuserver.presentation.refund.dto.MergedRefundRequest;
Expand All @@ -26,6 +27,7 @@
public class RefundController {

private final RefundService refundService;
private final RefundFailureLogDomainArchiveExecutor refundFailureLogDomainArchiveExecutor;

@GetMapping()
ResponseEntity<ApiResponseWrapper<RefundAmountResponse>> getRefundAmount(
Expand All @@ -46,4 +48,11 @@ ResponseEntity<ApiResponseWrapper<Void>> process(
refundService.doProcess(userId, request);
return ResponseEntity.ok(ApiResponseWrapper.success(HttpStatus.OK, "결제 취소 성공"));
}

@PostMapping("/cleanup")
@PreAuthorize("isAuthenticated() and hasRole('ADMIN')")
public ApiResponseWrapper<Void> archiveRefundFailureLogs() {
refundFailureLogDomainArchiveExecutor.archive();
return ApiResponseWrapper.success(HttpStatus.CREATED, "게스트 결제 승인 성공");

Choose a reason for hiding this comment

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

medium

archiveRefundFailureLogs 메소드는 환불 실패 로그를 아카이빙하는 기능을 수행하지만, API 성공 응답 메시지가 "게스트 결제 승인 성공"으로 되어 있어 기능과 일치하지 않습니다. 혼란을 방지하기 위해 메시지를 "환불 실패 로그 아카이빙 성공"과 같이 실제 기능에 맞게 수정하는 것이 좋겠습니다.

Suggested change
return ApiResponseWrapper.success(HttpStatus.CREATED, "게스트 결제 승인 성공");
return ApiResponseWrapper.success(HttpStatus.CREATED, "환불 실패 로그 아카이빙 성공");

}
}
15 changes: 15 additions & 0 deletions src/main/resources/messages_ko.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ notify.exam.application.complete.sms=\
\uB9C8\uC774\uD398\uC774\uC9C0 \uBC14\uB85C\uAC00\uAE30: https://www.mosuedu.com/mypage\n\n\
\uC2DC\uD5D8 1\uC8FC\uC77C \uC804,\uC2DC\uD5D8 \uAD00\uB828 \uC720\uC758\uC0AC\uD56D\uACFC \uC218\uD5D8\uD45C \uC548\uB0B4 \uB9AC\uB9C8\uC778\uB4DC \uC54C\uB9BC\uC774 \uBC1C\uC1A1\uB420 \uC608\uC815\uC785\uB2C8\uB2E4.\n\
\uC720\uC758\uC0AC\uD56D \uBC14\uB85C\uAC00\uAE30: https://www.mosuedu.com/warning
notify.exam.guest.application.complete.alimtalk=\
[\uBAA8\uC218] \uBAA8\uC758\uC218\uB2A5 \uC2E0\uCCAD\uC774 \uC644\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4!\n\n\
\u25A0 \uACB0\uC81C\uBC88\uD638: #{paymentKey}\n\
\u25A0 \uC751\uC2DC\uC77C\uC790: #{examDate}\n\
\u25A0 \uC2DC\uD5D8\uC7A5\uC18C: #{schoolName}\n\
\u25A0 \uB3C4\uC2DC\uB77D: #{lunch}\n\n\
\uC2DC\uD5D8 1\uC8FC\uC77C \uC804, \uC2DC\uD5D8 \uAD00\uB828 \uC720\uC758\uC0AC\uD56D\uACFC \uC218\uD5D8\uD45C \uC548\uB0B4 \uB9AC\uB9C8\uC778\uB4DC \uC54C\uB9BC\uC774 \uBC1C\uC1A1\uB420 \uC608\uC815\uC785\uB2C8\uB2E4.
notify.exam.guest.application.complete.sms=\
[\uBAA8\uC218] \uBAA8\uC758\uC218\uB2A5 \uC2E0\uCCAD\uC774 \uC644\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4!\n\n\
\u25A0 \uACB0\uC81C\uBC88\uD638: #{paymentKey}\n\
\u25A0 \uC751\uC2DC\uC77C\uC790: #{examDate}\n\
\u25A0 \uC2DC\uD5D8\uC7A5\uC18C: #{schoolName}\n\
\u25A0 \uB3C4\uC2DC\uB77D: #{lunch}\n\n\
\uC2DC\uD5D8 1\uC8FC\uC77C \uC804, \uC2DC\uD5D8 \uAD00\uB828 \uC720\uC758\uC0AC\uD56D\uACFC \uC218\uD5D8\uD45C \uC548\uB0B4 \uB9AC\uB9C8\uC778\uB4DC \uC54C\uB9BC\uC774 \uBC1C\uC1A1\uB420 \uC608\uC815\uC785\uB2C8\uB2E4.\n\n\
\uC720\uC758\uC0AC\uD56D \uBC14\uB85C\uAC00\uAE30 : https://www.mosuedu.com/warning

Choose a reason for hiding this comment

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

medium

메시지의 일관성을 위해 콜론(:) 앞에 있는 공백을 제거하는 것이 좋겠습니다. 다른 알림톡 메시지에서는 바로가기:와 같이 공백 없이 사용되고 있습니다.

\uC720\uC758\uC0AC\uD56D \uBC14\uB85C\uAC00\uAE30: https://www.mosuedu.com/warning

notify.exam.oneweek.reminder.alimtalk=\
[\uBAA8\uC218] \uBAA8\uC758\uC218\uB2A5\uC774 1\uC8FC\uC77C \uC55E\uC73C\uB85C \uB2E4\uAC00\uC654\uC2B5\uB2C8\uB2E4!\n\n\
\u25A0 \uC2DC\uD5D8\uC77C\uC790: #{examDate}\n\
Expand Down