결제 수정
This commit is contained in:
@@ -905,8 +905,16 @@ const calculateSelectedFeaturesTotal = () => {
|
||||
|
||||
// 현재 총 결제 금액 계산
|
||||
const calculateTotalPrice = () => {
|
||||
console.log('currentSubscription.value', currentSubscription.value);
|
||||
const planPrice = currentSubscription.value?.planPrice || 0;
|
||||
const activeFeatureTotal = 0; // 활성화된 기능의 월 금액 계산 (추후 구현)
|
||||
|
||||
// 활성화된 기능의 월 금액 계산
|
||||
const activeFeatureTotal = activeFeatures.value.reduce((total, feature) => {
|
||||
// 각 활성화된 기능에 대해 해당 기능의 가격 찾기
|
||||
const featureInfo = availableFeatures.value.find(f => f.id === feature.featureId);
|
||||
// 기능 정보가 있고 가격이 있으면 더하기, 없으면 0 더하기
|
||||
return total + (featureInfo?.price || 0);
|
||||
}, 0);
|
||||
|
||||
return planPrice + activeFeatureTotal;
|
||||
};
|
||||
@@ -995,8 +1003,18 @@ const totalFeaturesPrice = computed(() => {
|
||||
|
||||
// 최종 결제 금액
|
||||
const finalAmount = computed(() => {
|
||||
// 현재 구독이 없고 새로운 플랜을 선택한 경우 (신규 구독)
|
||||
if (!currentSubscription.value && selectedPlan.value) {
|
||||
// 플랜 총액 계산 (기간 할인 적용)
|
||||
const planTotal = calculatePlanTotalPrice(selectedPlan.value);
|
||||
// 추가 기능 총액
|
||||
const featuresTotal = totalFeaturesPrice.value;
|
||||
// 10원 단위로 절삭
|
||||
const amount = planTotal + featuresTotal;
|
||||
return Math.floor(amount / 10) * 10;
|
||||
}
|
||||
// 플랜 변경이 있는 경우
|
||||
if (selectedPlan.value && !isCurrentPlan(selectedPlan.value.id)) {
|
||||
else if (selectedPlan.value && !isCurrentPlan(selectedPlan.value.id)) {
|
||||
// 업그레이드이고 즉시 적용인 경우
|
||||
if (isUpgrade.value && changeOption.value === 'immediate') {
|
||||
// 3개월 이상 구독인 경우 총 금액에서 환불액을 빼야 함
|
||||
@@ -1015,7 +1033,7 @@ const finalAmount = computed(() => {
|
||||
// 10원 단위로 절삭
|
||||
return Math.floor(totalFeaturesPrice.value / 10) * 10;
|
||||
}
|
||||
// 새로운 구독인 경우 플랜 총액 계산
|
||||
// 기타 플랜 변경 케이스
|
||||
else {
|
||||
// 10원 단위로 절삭
|
||||
const amount = calculatePlanTotalPrice(selectedPlan.value) + totalFeaturesPrice.value;
|
||||
|
||||
Reference in New Issue
Block a user