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);
|
||||
};
|
||||
|
||||
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
|
||||
* @header
|
||||
@ -135,5 +158,6 @@ module.exports = {
|
||||
sendMail,
|
||||
sendTicket,
|
||||
sendListaEspera,
|
||||
sendCancelacion,
|
||||
|
||||
};
|
||||
@ -226,8 +226,8 @@ console.log(params, req.user.level);
|
||||
|
||||
try {
|
||||
const inscription = await eventInscriptionService._getInscriptionById(inscriptionId);
|
||||
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion a Validar:');
|
||||
console.log(inscription);
|
||||
//console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>><Inscripcion a Validar:');
|
||||
//console.log(inscription);
|
||||
|
||||
//Si la inscripcion no existe o ya está validada no hago nada
|
||||
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);
|
||||
|
||||
|
||||
|
||||
var member = generateMemberInscription(inscription.user, inscription, inscription.reservation);
|
||||
console.log('generamos member>>>>>>>>>>>>>>>>>>>>> ', member);
|
||||
//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
|
||||
await eventInscriptionService._deleteMember(marketingListId, inscription.marketing_memberId);
|
||||
|
||||
/*Mandar correo de confirmacion de desinscripcion
|
||||
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);
|
||||
//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);
|
||||
member.qrConfig = generateQRConfig(member);
|
||||
member.qrCode = await QRHelper.getInscriptionQRCode(member.qrConfig);
|
||||
|
||||
try {
|
||||
if (member.validated)
|
||||
emailHelper.sendTicket(headerMail, bodyMail)
|
||||
else
|
||||
emailHelper.sendListaEspera(headerMail, bodyMail);
|
||||
emailHelper.sendCancelacion(generateHeaderMail(member), generateBodyMail(member))
|
||||
} catch (error) {
|
||||
console.log('No se ha podido mandar email con entrada');
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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',
|
||||
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
|
||||
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
|
||||
event: 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
|
||||
else {
|
||||
dataInscription.inscriptionsWithoutReservationCount = await eventInscriptionService._getCountInscriptionsWithoutReservationAndOverflow(dataInscription.event.id);
|
||||
++dataInscription.inscriptionsWithoutReservationCount;
|
||||
dataInscription.inscriptionsWithoutReservationAndOverflowCount = await eventInscriptionService._getCountInscriptionsWithoutReservationAndOverflow(dataInscription.event.id);
|
||||
++dataInscription.inscriptionsWithoutReservationAndOverflowCount;
|
||||
|
||||
|
||||
//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;
|
||||
//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,
|
||||
dataUser.userResult.user.id,
|
||||
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);
|
||||
|
||||
//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);
|
||||
}
|
||||
// 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);
|
||||
//recuperamos la cantidad de apuntados al evento overflow a lista de espera
|
||||
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);
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user