Merge branch 'master' of wopr.rodax-software.com:lqdvi/app2-api
This commit is contained in:
commit
f428464139
@ -108,6 +108,29 @@ function sendListaEspera(header, values) {
|
|||||||
return send(header, body);
|
return send(header, body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function sendCancelacion(header, values) {
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
"TemplateID": 978886,
|
||||||
|
"TemplateLanguage": true,
|
||||||
|
"TemplateErrorDeliver": true,
|
||||||
|
"TemplateErrorReporting": {
|
||||||
|
"Email": "info@rodax-software.com",
|
||||||
|
"Name": "Air traffic control"
|
||||||
|
},
|
||||||
|
"Variables": {
|
||||||
|
"tipoEntrada": values.tipoEntrada,
|
||||||
|
"eventName": values.eventName,
|
||||||
|
"dateInscription": values.dateInscription,
|
||||||
|
"color": (values.color) ? values.color : 'gray',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return send(header, body);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enviar un email
|
* Enviar un email
|
||||||
* @header
|
* @header
|
||||||
@ -135,5 +158,6 @@ module.exports = {
|
|||||||
sendMail,
|
sendMail,
|
||||||
sendTicket,
|
sendTicket,
|
||||||
sendListaEspera,
|
sendListaEspera,
|
||||||
|
sendCancelacion,
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -226,8 +226,8 @@ console.log(params, req.user.level);
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
||||||
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion a Validar:');
|
//console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion a Validar:');
|
||||||
console.log(inscription);
|
//console.log(inscription);
|
||||||
|
|
||||||
//Si la inscripcion no existe o ya está validada no hago nada
|
//Si la inscripcion no existe o ya está validada no hago nada
|
||||||
if (!inscription)
|
if (!inscription)
|
||||||
@ -266,7 +266,6 @@ console.log('>>>>>>>>>>>>>>><NewConfirmedEvent: ', NewConfirmedEvent);
|
|||||||
return handleResultResponse("Error al validad inscripción, no puedo cambiar confirmados al evento", null, params, res, httpStatus.NOT_FOUND);
|
return handleResultResponse("Error al validad inscripción, no puedo cambiar confirmados al evento", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var member = generateMemberInscription(inscription.user, inscription, inscription.reservation);
|
var member = generateMemberInscription(inscription.user, inscription, inscription.reservation);
|
||||||
console.log('generamos member>>>>>>>>>>>>>>>>>>>>> ', member);
|
console.log('generamos member>>>>>>>>>>>>>>>>>>>>> ', member);
|
||||||
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
||||||
@ -346,39 +345,18 @@ console.log('>>>>>>>>>>>>>> ', NewConfirmed);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Eliminamos miembro de la lista de mailchimp a la que está asociado
|
//Desinscribimos de mailchimp y mandamos correo de confirmacion de desinscripcion
|
||||||
|
var member = generateMemberInscription(inscription.user, inscription, inscription.reservation);
|
||||||
|
console.log('generamos member para mailchimp y correo>>>>>>>>>>>>>>>>>>>>> ', member);
|
||||||
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
||||||
|
member.qrConfig = generateQRConfig(member);
|
||||||
/*Mandar correo de confirmacion de desinscripcion
|
member.qrCode = await QRHelper.getInscriptionQRCode(member.qrConfig);
|
||||||
var headerMail = {
|
|
||||||
to: user.email,
|
|
||||||
name: user.name + ' ' + user.surname,
|
|
||||||
subject: ((member.validated) ? 'Entrada' : 'Lista de espera') + ' para el congreso ' + dataInscription.event.name + ' confirmada'
|
|
||||||
}
|
|
||||||
|
|
||||||
var bodyMail = {
|
|
||||||
tipoEntrada: (member.validated) ? 'Entrada' : 'Lista de espera',
|
|
||||||
descriptionEntrada: member.description,
|
|
||||||
qrCode: qrCode,
|
|
||||||
color: qrConfig.color,
|
|
||||||
codeTicket: member.code_ticket,
|
|
||||||
eventName: dataInscription.event.name,
|
|
||||||
dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'),
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
|
|
||||||
console.log(headerMail, bodyMail);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (member.validated)
|
emailHelper.sendCancelacion(generateHeaderMail(member), generateBodyMail(member))
|
||||||
emailHelper.sendTicket(headerMail, bodyMail)
|
|
||||||
else
|
|
||||||
emailHelper.sendListaEspera(headerMail, bodyMail);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('No se ha podido mandar email con entrada');
|
console.log('No se ha podido mandar email con entrada');
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return handleResultResponse("Inscripción eliminada", null, params, res, httpStatus.DELETEOK);
|
return handleResultResponse("Inscripción eliminada", null, params, res, httpStatus.DELETEOK);
|
||||||
@ -413,7 +391,7 @@ console.log('CREATE INSCRIPTION>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< ', params);
|
|||||||
type: (req.body.code) ? 'reservation' : 'regular',
|
type: (req.body.code) ? 'reservation' : 'regular',
|
||||||
source: (req.user) ? 'app' : 'web', //En el caso de tener ya usuario viene por APP sino viene por web
|
source: (req.user) ? 'app' : 'web', //En el caso de tener ya usuario viene por APP sino viene por web
|
||||||
validated: null, //si no esta validado la inscripción es a la lista de espera
|
validated: null, //si no esta validado la inscripción es a la lista de espera
|
||||||
inscriptionsWithoutReservationCount: null, //nº total de inscritos sin reserva asignada
|
inscriptionsWithoutReservationAndOverflowCount: null, //nº total de inscritos sin reserva y sin overflow asignada
|
||||||
inscriptionsWithReservationCount: null, //nº total de inscritos a la reserva asignada
|
inscriptionsWithReservationCount: null, //nº total de inscritos a la reserva asignada
|
||||||
event: null,
|
event: null,
|
||||||
reservation: null,
|
reservation: null,
|
||||||
@ -569,15 +547,15 @@ console.log('actualizo confirmados de la nueva reserva');
|
|||||||
}
|
}
|
||||||
//SIN CODIGO DE RESERVA SE MODIFICA EL CONFIRMED DEL EVENTO, YA QUE SE DESCONTARA DEL AFORO DEL EVENTO
|
//SIN CODIGO DE RESERVA SE MODIFICA EL CONFIRMED DEL EVENTO, YA QUE SE DESCONTARA DEL AFORO DEL EVENTO
|
||||||
else {
|
else {
|
||||||
dataInscription.inscriptionsWithoutReservationCount = await eventInscriptionService._getCountInscriptionsWithoutReservationAndOverflow(dataInscription.event.id);
|
dataInscription.inscriptionsWithoutReservationAndOverflowCount = await eventInscriptionService._getCountInscriptionsWithoutReservationAndOverflow(dataInscription.event.id);
|
||||||
++dataInscription.inscriptionsWithoutReservationCount;
|
++dataInscription.inscriptionsWithoutReservationAndOverflowCount;
|
||||||
|
|
||||||
|
|
||||||
//COMPROBAMOS SI ES VALIDO O HAY QUE APUNTARLE A LA LISTA DE ESPERA DEL EVENTO
|
//COMPROBAMOS SI ES VALIDO O HAY QUE APUNTARLE A LA LISTA DE ESPERA DEL EVENTO
|
||||||
if ((dataInscription.event.sold_out == 0) && (dataInscription.event.assistants >= dataInscription.inscriptionsWithoutReservationCount)) {
|
if ((dataInscription.event.sold_out == 0) && (dataInscription.event.assistants >= dataInscription.inscriptionsWithoutReservationAndOverflowCount)) {
|
||||||
dataInscription.validated = true;
|
dataInscription.validated = true;
|
||||||
//Actualizamos aforo del evento y creamos inscripcion
|
//Actualizamos aforo del evento y creamos inscripcion
|
||||||
if (await eventService._updateConfirmedEvent(dataInscription.event.id, dataInscription.inscriptionsWithoutReservationCount))
|
if (await eventService._updateConfirmedEvent(dataInscription.event.id, dataInscription.inscriptionsWithoutReservationAndOverflowCount))
|
||||||
dataInscription.inscription = await eventInscriptionService._createInscription(dataInscription.event.id,
|
dataInscription.inscription = await eventInscriptionService._createInscription(dataInscription.event.id,
|
||||||
dataUser.userResult.user.id,
|
dataUser.userResult.user.id,
|
||||||
dataInscription.type,
|
dataInscription.type,
|
||||||
@ -589,7 +567,7 @@ console.log('actualizo confirmados de la nueva reserva');
|
|||||||
return handleResultResponse("No se ha podido actualizar el aforo del evento", null, params, res, httpStatus.NOT_FOUND);
|
return handleResultResponse("No se ha podido actualizar el aforo del evento", null, params, res, httpStatus.NOT_FOUND);
|
||||||
|
|
||||||
//Ponemos el evento en SOLD_OUT
|
//Ponemos el evento en SOLD_OUT
|
||||||
if (dataInscription.event.assistants == dataInscription.inscriptionsWithoutReservationCount)
|
if (dataInscription.event.assistants == dataInscription.inscriptionsWithoutReservationAndOverflowCount)
|
||||||
await eventService._updateSoldOutEvent(dataInscription.event.id, true);
|
await eventService._updateSoldOutEvent(dataInscription.event.id, true);
|
||||||
}
|
}
|
||||||
// APUNTARSE A la lista de espera si se puede
|
// APUNTARSE A la lista de espera si se puede
|
||||||
@ -601,7 +579,7 @@ console.log('actualizo confirmados de la nueva reserva');
|
|||||||
console.log('evento de lista de espera que debo actulizar sus confirmados>>>>>>>>>>>>>>>>>>>>>', dataInscription.event.overflow_eventId);
|
console.log('evento de lista de espera que debo actulizar sus confirmados>>>>>>>>>>>>>>>>>>>>>', dataInscription.event.overflow_eventId);
|
||||||
//recuperamos la cantidad de apuntados al evento overflow a lista de espera
|
//recuperamos la cantidad de apuntados al evento overflow a lista de espera
|
||||||
const ConfirmedWaitList = await eventInscriptionService._getCountInscriptionsWithOverflowEventId(dataInscription.event.overflow_eventId);
|
const ConfirmedWaitList = await eventInscriptionService._getCountInscriptionsWithOverflowEventId(dataInscription.event.overflow_eventId);
|
||||||
console.log('cantidad apuntados al evento padre>>>>>>>>>>>>>>>>>>>>>', dataInscription.inscriptionsWithoutReservationCount);
|
console.log('cantidad apuntados al evento padre>>>>>>>>>>>>>>>>>>>>>', dataInscription.inscriptionsWithoutReservationAndOverflowCount);
|
||||||
console.log('cantidad apuntados al evento de lista de espera asociado>>>>>>>>>>>>>>>>>>>>>', ConfirmedWaitList);
|
console.log('cantidad apuntados al evento de lista de espera asociado>>>>>>>>>>>>>>>>>>>>>', ConfirmedWaitList);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user