체험 계정도 업그레이드 승인되도록 수정
This commit is contained in:
+28
-6
@@ -148,10 +148,20 @@ export async function approveUpgradeRequest(
|
||||
});
|
||||
|
||||
// Re-verify upgrade direction at approval time (maestro AccountType may have changed since request)
|
||||
const isRequestedPaid = (PAID_ACCOUNT_TYPE_VALUES as readonly number[]).includes(
|
||||
request!.RequestedAccountType
|
||||
);
|
||||
const isCurrentPaid = (PAID_ACCOUNT_TYPE_VALUES as readonly number[]).includes(
|
||||
request!.maestro.AccountType
|
||||
);
|
||||
const isApprovalTrial = request!.maestro.ActivateStatus === ACTIVATE_STATUSES.TRIAL;
|
||||
const isStillValidUpgrade = isApprovalTrial
|
||||
? request!.RequestedAccountType >= request!.maestro.AccountType
|
||||
: request!.RequestedAccountType > request!.maestro.AccountType;
|
||||
const isStillValidUpgrade =
|
||||
isRequestedPaid &&
|
||||
(!isCurrentPaid
|
||||
? true
|
||||
: isApprovalTrial
|
||||
? request!.RequestedAccountType >= request!.maestro.AccountType
|
||||
: request!.RequestedAccountType > request!.maestro.AccountType);
|
||||
if (!isStillValidUpgrade) {
|
||||
throw new ApiError(
|
||||
"마에스트로의 현재 요금제 기준으로 유효하지 않은 업그레이드입니다. 신청 내용을 확인해 주세요.",
|
||||
@@ -214,10 +224,22 @@ export async function createUpgradeRequest(
|
||||
throw new ApiError("마에스트로를 찾을 수 없습니다.", 404);
|
||||
}
|
||||
|
||||
const isRequestedPaid = (PAID_ACCOUNT_TYPE_VALUES as readonly number[]).includes(
|
||||
requestedAccountType
|
||||
);
|
||||
if (!isRequestedPaid) {
|
||||
throw new ApiError("업그레이드 대상은 유료 요금제여야 합니다.", 400);
|
||||
}
|
||||
|
||||
const isCurrentPaid = (PAID_ACCOUNT_TYPE_VALUES as readonly number[]).includes(
|
||||
maestro.AccountType
|
||||
);
|
||||
const isTrial = maestro.ActivateStatus === ACTIVATE_STATUSES.TRIAL;
|
||||
const isValidUpgrade = isTrial
|
||||
? requestedAccountType >= maestro.AccountType
|
||||
: requestedAccountType > maestro.AccountType;
|
||||
const isValidUpgrade = !isCurrentPaid
|
||||
? true
|
||||
: isTrial
|
||||
? requestedAccountType >= maestro.AccountType
|
||||
: requestedAccountType > maestro.AccountType;
|
||||
|
||||
if (!isValidUpgrade) {
|
||||
throw new ApiError(
|
||||
|
||||
Reference in New Issue
Block a user