결제 수정
This commit is contained in:
@@ -755,7 +755,7 @@ exports.getRecentMeetings = async (req, res) => {
|
|||||||
// 사용자 클럽 목록 조회
|
// 사용자 클럽 목록 조회
|
||||||
exports.getUserClubs = async (req, res) => {
|
exports.getUserClubs = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
// 사용자가 속한 클럽 목록 조회 (Member 테이블 조인)
|
const { userId } = req.body;
|
||||||
// admin이면 모든 클럽을, 아니면 자신의 클럽만 조회
|
// admin이면 모든 클럽을, 아니면 자신의 클럽만 조회
|
||||||
const hasAdminAccess = isAdmin(req.user);
|
const hasAdminAccess = isAdmin(req.user);
|
||||||
|
|
||||||
@@ -768,7 +768,7 @@ exports.getUserClubs = async (req, res) => {
|
|||||||
queryOptions.include = [{
|
queryOptions.include = [{
|
||||||
model: Member,
|
model: Member,
|
||||||
where: {
|
where: {
|
||||||
userId: req.user.id
|
userId: userId
|
||||||
},
|
},
|
||||||
attributes: ['memberType']
|
attributes: ['memberType']
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ Club.associate = (models) => {
|
|||||||
through: models.ClubFeature,
|
through: models.ClubFeature,
|
||||||
foreignKey: 'clubId',
|
foreignKey: 'clubId',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Member와의 관계 추가
|
||||||
|
Club.hasMany(models.Member, { foreignKey: 'clubId' });
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Club;
|
module.exports = Club;
|
||||||
|
|||||||
+10
-3
@@ -130,7 +130,7 @@ const ownerName = ref('');
|
|||||||
const isRouterReady = ref(false);
|
const isRouterReady = ref(false);
|
||||||
const userRole = computed(() => user.value?.role || '');
|
const userRole = computed(() => user.value?.role || '');
|
||||||
const isAdmin = computed(() => userRole.value === 'admin' || userRole.value === 'superadmin');
|
const isAdmin = computed(() => userRole.value === 'admin' || userRole.value === 'superadmin');
|
||||||
const userClubRole = ref(localStorage.getItem('userClubRole') || '');
|
const userClubRole = computed(() => localStorage.getItem('userClubRole') || '');
|
||||||
|
|
||||||
// 화면 크기 변경 감지
|
// 화면 크기 변경 감지
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
@@ -187,14 +187,20 @@ const fetchClubs = async () => {
|
|||||||
...club,
|
...club,
|
||||||
memberType: club.memberType || ''
|
memberType: club.memberType || ''
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 첫 번째 클럽의 memberType을 localStorage에 저장
|
// 첫 번째 클럽의 memberType을 localStorage에 저장
|
||||||
if (clubs.value.length > 0 && !selectedClubId.value) {
|
if ((clubs.value.length > 0 && !selectedClubId.value) || clubs.value.length === 1) {
|
||||||
selectedClubId.value = clubs.value[0].id;
|
selectedClubId.value = clubs.value[0].id;
|
||||||
await setSelectedClub(clubs.value[0]);
|
await setSelectedClub(clubs.value[0]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('클럽 목록 로드 실패:', error);
|
console.error('클럽 목록 로드 실패:', error);
|
||||||
|
|
||||||
|
// 클럽 목록을 가져오지 못했거나 클럽이 없는 경우
|
||||||
|
const userRole = localStorage.getItem('userRole');
|
||||||
|
// 관리자가 아닌 경우에만 클럽 생성 페이지로 리다이렉트
|
||||||
|
if (userRole !== 'admin' && userRole !== 'superadmin') {
|
||||||
|
router.push('/club/create');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -341,6 +347,7 @@ const loadUserData = async () => {
|
|||||||
try {
|
try {
|
||||||
const response = await authService.getCurrentUser();
|
const response = await authService.getCurrentUser();
|
||||||
user.value = response.data;
|
user.value = response.data;
|
||||||
|
localStorage.setItem('userRole', response.data.role);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('사용자 정보 로드 실패:', error);
|
console.error('사용자 정보 로드 실패:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import apiClient from '../services/api';
|
import apiClient from '@/services/api';
|
||||||
|
import router from '@/router';
|
||||||
|
|
||||||
export const useClubStore = defineStore('club', {
|
export const useClubStore = defineStore('club', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
@@ -37,9 +38,18 @@ export const useClubStore = defineStore('club', {
|
|||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
const userClubRole = localStorage.getItem('userClubRole');
|
||||||
console.error('구독 정보를 가져오는 중 오류가 발생했습니다:', error);
|
console.error('구독 정보를 가져오는 중 오류가 발생했습니다:', error);
|
||||||
this.subscription = null;
|
this.subscription = null;
|
||||||
this.subscriptionFeatures = [];
|
this.subscriptionFeatures = [];
|
||||||
|
// 사용자 권한 확인
|
||||||
|
if (userClubRole === '모임장' || userClubRole === '운영진') {
|
||||||
|
// 구독 페이지로 이동
|
||||||
|
setTimeout(() => {
|
||||||
|
router.push('/club/subscription');
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -905,8 +905,16 @@ const calculateSelectedFeaturesTotal = () => {
|
|||||||
|
|
||||||
// 현재 총 결제 금액 계산
|
// 현재 총 결제 금액 계산
|
||||||
const calculateTotalPrice = () => {
|
const calculateTotalPrice = () => {
|
||||||
|
console.log('currentSubscription.value', currentSubscription.value);
|
||||||
const planPrice = currentSubscription.value?.planPrice || 0;
|
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;
|
return planPrice + activeFeatureTotal;
|
||||||
};
|
};
|
||||||
@@ -995,8 +1003,18 @@ const totalFeaturesPrice = computed(() => {
|
|||||||
|
|
||||||
// 최종 결제 금액
|
// 최종 결제 금액
|
||||||
const finalAmount = 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') {
|
if (isUpgrade.value && changeOption.value === 'immediate') {
|
||||||
// 3개월 이상 구독인 경우 총 금액에서 환불액을 빼야 함
|
// 3개월 이상 구독인 경우 총 금액에서 환불액을 빼야 함
|
||||||
@@ -1015,7 +1033,7 @@ const finalAmount = computed(() => {
|
|||||||
// 10원 단위로 절삭
|
// 10원 단위로 절삭
|
||||||
return Math.floor(totalFeaturesPrice.value / 10) * 10;
|
return Math.floor(totalFeaturesPrice.value / 10) * 10;
|
||||||
}
|
}
|
||||||
// 새로운 구독인 경우 플랜 총액 계산
|
// 기타 플랜 변경 케이스
|
||||||
else {
|
else {
|
||||||
// 10원 단위로 절삭
|
// 10원 단위로 절삭
|
||||||
const amount = calculatePlanTotalPrice(selectedPlan.value) + totalFeaturesPrice.value;
|
const amount = calculatePlanTotalPrice(selectedPlan.value) + totalFeaturesPrice.value;
|
||||||
|
|||||||
Reference in New Issue
Block a user