참가마감 처리

This commit is contained in:
2025-11-13 19:28:29 +09:00
parent 56e9b4e97a
commit 0ba1d9df8d
+14 -1
View File
@@ -282,6 +282,10 @@ exports.registerPublicParticipant = async (req, res) => {
if (!event) return res.status(404).json({ message: '이벤트를 찾을 수 없습니다.' });
if (event.status === 'canceled') return res.status(403).json({ message: '취소된 이벤트입니다.' });
// 참가 마감시간 체크: 마감 후에는 신규 참가 불가, 기존 참가자 수정만 허용
const now = new Date();
const regDeadline = event.registrationDeadline ? new Date(event.registrationDeadline) : null;
// 입력값 정규화 및 검증
const toInt = (v) => {
if (v === undefined || v === null || v === '') return null;
@@ -317,6 +321,10 @@ exports.registerPublicParticipant = async (req, res) => {
participant = await EventParticipant.findOne({ where: { id: pid, memberId: member.id } });
}
if (!participant) {
// 신규 생성 전에 마감 체크 수행
if (regDeadline && now > regDeadline) {
return res.status(403).json({ message: '참가 신청이 마감되었습니다. 기존 참가 정보만 수정할 수 있습니다.' });
}
// 중복 참가 방지: 동일 eventId/memberId의 취소되지 않은 레코드가 있으면 업데이트로 처리
const existing = await EventParticipant.findOne({ where: { eventId: event.id, memberId: member.id, status: { [Op.ne]: 'canceled' } } });
if (existing) {
@@ -342,6 +350,12 @@ exports.addPublicGuest = async (req, res) => {
const event = await Event.findOne({ where: { publicHash } });
if (!event) return res.status(404).json({ message: '이벤트를 찾을 수 없습니다.' });
if (event.status === '취소') return res.status(403).json({ message: '취소된 이벤트입니다.' });
// 참가 마감시간 체크: 마감 후에는 게스트 추가 불가
const now = new Date();
const regDeadline = event.registrationDeadline ? new Date(event.registrationDeadline) : null;
if (regDeadline && now > regDeadline) {
return res.status(403).json({ message: '참가 신청이 마감되었습니다. 게스트를 추가할 수 없습니다.' });
}
// 클럽의 회원 수와 구독 플랜의 최대 회원 수 확인
const memberCount = await Member.count({ where: { clubId: event.clubId } });
@@ -358,7 +372,6 @@ exports.addPublicGuest = async (req, res) => {
});
// 구독이 없거나 만료된 경우 접근 제한
const now = new Date();
if (!clubSubscription || new Date(clubSubscription.endDate) < now) {
return res.status(403).json({ message: '클럽의 구독이 만료되어 이벤트에 접근할 수 없습니다. 클럽 관리자에게 문의하세요.' });
}