Merge branch 'master' of wopr.rodax-software.com:lqdvi/app2-api

This commit is contained in:
David Arranz 2019-09-03 10:32:40 +02:00
commit 3dfaf4b32c
3 changed files with 46 additions and 25 deletions

View File

@ -40,11 +40,13 @@ function send(header, body) {
}) })
request request
.then((result) => { .then((result) => {
console.log(result.body) console.log('EEEEEEEEEEEEEEEEEEEENNNNNNNNNNNNNNNNNNVIO correo>>>>');
console.log(result.body);
return result; return result;
}) })
.catch((error) => { .catch((error) => {
console.log(error.statusCode) console.log(error.statusCode);
console.log(error);
return error; return error;
}) })
}; };
@ -78,7 +80,7 @@ function sendTicket(header, values) {
"codeTicket": values.codeTicket, "codeTicket": values.codeTicket,
"eventName": values.eventName, "eventName": values.eventName,
"dateInscription": values.dateInscription, "dateInscription": values.dateInscription,
"color": values.color, "color": (values.color)? values.color : 'gray',
} }
}; };
@ -99,7 +101,7 @@ function sendListaEspera(header, values) {
"tipoEntrada": values.tipoEntrada, "tipoEntrada": values.tipoEntrada,
"eventName": values.eventName, "eventName": values.eventName,
"dateInscription": values.dateInscription, "dateInscription": values.dateInscription,
"color": values.color, "color": (values.color) ? values.color : 'gray',
} }
}; };

View File

@ -34,7 +34,7 @@ const extraControllers = {
try { try {
const result = await eventReservationService._getReservaByCode(eventId, registrationCode); const result = await eventReservationService._getReservaByCode(eventId, registrationCode);
return handleResultResponse(!!result, null, params, res, (result === null) ? httpStatus.NOT_FOUND : httpStatus.OK); return handleResultResponse(!!result, null, params, res, httpStatus.OK);
} catch(error) { } catch(error) {
return handleErrorResponse(MODULE_NAME, 'checkReservationCode', error, res) return handleErrorResponse(MODULE_NAME, 'checkReservationCode', error, res)
} }
@ -199,7 +199,7 @@ console.log('>>>>>>>>>>>>>>Voy a actualizar aforo evento');
//Esta función se puede llamar desde APP y desde WEB //Esta función se puede llamar desde APP y desde WEB
createInscription: async(req, res, next) => { createInscription: async(req, res, next) => {
const params = extractParamsFromRequest(req, res, {}); const params = extractParamsFromRequest(req, res, {});
console.log('CREATE INSCRIPTION>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< ', params);
//Iniciamos entidades relacionadas con la inscripción. //Iniciamos entidades relacionadas con la inscripción.
let dataUser = { let dataUser = {
id: (req.user) ? req.user.id : null, id: (req.user) ? req.user.id : null,
@ -391,16 +391,22 @@ console.log('actualizo confirmados de la nueva reserva');
dataInscription.validated = false; dataInscription.validated = false;
//Actualizamos aforo de la lista de espera del evento y creamos inscripcion //Actualizamos aforo de la lista de espera del evento y creamos inscripcion
if (await eventService._updateConfirmedEvent(dataInscription.event.overflow_eventId, dataInscription.inscriptionsWithoutReservationCount)) console.log('evento de lista de espera que debo actulizar sus confirmados>>>>>>>>>>>>>>>>>>>>>', dataInscription.event.overflow_eventId);
console.log('cantidad>>>>>>>>>>>>>>>>>>>>>', dataInscription.inscriptionsWithoutReservationCount);
if (await eventService._updateConfirmedEvent(dataInscription.event.overflow_eventId, dataInscription.inscriptionsWithoutReservationCount)) {
console.log('voy a crearrrrrr la inscripcion');
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,
dataInscription.validated, dataInscription.validated,
dataInscription.source, dataInscription.source,
null, null,
dataInscription.event.overflow_eventId) dataInscription.event.overflow_eventId);
else }
else {
console.log('No se ha podido actualizar el aforo del evento');
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);
}
} }
else else
return handleResultResponse("Aforo completo y no hay lista de espera", null, params, res, httpStatus.NOT_FOUND); return handleResultResponse("Aforo completo y no hay lista de espera", null, params, res, httpStatus.NOT_FOUND);
@ -444,9 +450,13 @@ console.log('actualizo confirmados de la nueva reserva');
console.log('member a añadir a mailchimp y envio correo'); console.log('member a añadir a mailchimp y envio correo');
console.log(member); console.log(member);
try
member.marketing_memberId = await eventInscriptionService._addMember(marketingListOfInscription, member); {
eventInscriptionService._updateMarketingMemberOfInscription(dataInscription.inscription.id, member.marketing_memberId); member.marketing_memberId = await eventInscriptionService._addMember(marketingListOfInscription, member);
eventInscriptionService._updateMarketingMemberOfInscription(dataInscription.inscription.id, member.marketing_memberId);
} catch (error) {
console.log('No se ha podido añadir email a mailchimp');
};
//MADAMOS MAIL CON LA ENTRADA //MADAMOS MAIL CON LA ENTRADA
@ -474,12 +484,19 @@ console.log(member);
eventName: dataInscription.event.name, eventName: dataInscription.event.name,
dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'), dateInscription: moment(dataInscription.event.init_date).format('D [de] MMMM [de] YYYY'),
} }
console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>'); console.log('Mandamos mail con entrada>>>>>>>>>>>>>>>>>>>>>>>>>>>');
console.log(headerMail, bodyMail); console.log(headerMail, bodyMail);
if (member.validated)
emailHelper.sendTicket(headerMail, bodyMail) try
else {
emailHelper.sendListaEspera(headerMail, bodyMail); if (member.validated)
emailHelper.sendTicket(headerMail, bodyMail)
else
emailHelper.sendListaEspera(headerMail, bodyMail);
} catch (error) {
console.log('No se ha podido mandar email con entrada');
};
return handleResultResponse(await dataInscription.inscription.toJSON(), null, params, res, httpStatus.CREATED) return handleResultResponse(await dataInscription.inscription.toJSON(), null, params, res, httpStatus.CREATED)
}, },

View File

@ -52,13 +52,14 @@ const extraMethods = {
confirmed: confirmed, confirmed: confirmed,
}, },
{ {
where: { id: eventId } where: { id: eventId, typeId: { [Sequelize.Op.ne]: null} }
}) })
.then(function (result) { .then(function (result) {
//const aaa = result[0]; console.log('>>>>>>>>>>>>>>>>>>>>>>>>><resultado _updateConfirmedEvent', result);
//console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaa'); if (result)
//console.log(aaa); resolve((result[0] === 1))
resolve((result[0] === 1)); else
resolve(false);
}) })
.catch(function (error) { .catch(function (error) {
reject(error) reject(error)
@ -76,10 +77,11 @@ const extraMethods = {
where: { id: eventId } where: { id: eventId }
}) })
.then(function (result) { .then(function (result) {
//const aaa = result[0]; console.log('>>>>>>>>>>>>>>>>>>>>>>>>><resultado _updateSoldOutEvent', result);
//console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaa'); if (result)
//console.log(aaa); resolve((result[0] === 1))
resolve((result[0] === 1)); else
resolve(false);
}) })
.catch(function (error) { .catch(function (error) {
reject(error) reject(error)