clubId수정
This commit is contained in:
@@ -1487,6 +1487,29 @@ exports.addEventParticipant = async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 입력 상태/결제값을 DB Enum에 맞추어 정규화
|
||||
const normalizeStatus = (s) => {
|
||||
if (!s) return undefined;
|
||||
const map = {
|
||||
'참가예정': 'pending',
|
||||
'참가확정': 'confirmed',
|
||||
'취소': 'canceled',
|
||||
};
|
||||
return ['pending', 'confirmed', 'canceled'].includes(s) ? s : (map[s] || undefined);
|
||||
};
|
||||
const normalizePayment = (p) => {
|
||||
if (!p) return undefined;
|
||||
const map = {
|
||||
'미납': 'unpaid',
|
||||
'납부완료': 'paid',
|
||||
'완납': 'paid',
|
||||
};
|
||||
return ['unpaid', 'paid'].includes(p) ? p : (map[p] || undefined);
|
||||
};
|
||||
|
||||
const normStatus = normalizeStatus(status);
|
||||
const normPayment = normalizePayment(paymentStatus);
|
||||
|
||||
let participant;
|
||||
let isUpdate = false;
|
||||
if (existingParticipant) {
|
||||
@@ -1496,8 +1519,8 @@ exports.addEventParticipant = async (req, res) => {
|
||||
eventId,
|
||||
memberId,
|
||||
clubId,
|
||||
status: status || existingParticipant.status,
|
||||
paymentStatus: paymentStatus || existingParticipant.paymentStatus,
|
||||
status: normStatus || existingParticipant.status,
|
||||
paymentStatus: normPayment || existingParticipant.paymentStatus,
|
||||
comment: comment || existingParticipant.comment
|
||||
});
|
||||
participant = await EventParticipant.findOne({
|
||||
@@ -1515,8 +1538,8 @@ exports.addEventParticipant = async (req, res) => {
|
||||
participant = await EventParticipant.create({
|
||||
eventId,
|
||||
memberId,
|
||||
status: status || '참가예정',
|
||||
paymentStatus: paymentStatus || '미납',
|
||||
status: normStatus || 'pending',
|
||||
paymentStatus: normPayment || 'unpaid',
|
||||
comment: comment || null,
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date()
|
||||
|
||||
Reference in New Issue
Block a user