diff --git a/helpers/mail.helper.js b/helpers/mail.helper.js index e973fce..8c1b905 100644 --- a/helpers/mail.helper.js +++ b/helpers/mail.helper.js @@ -40,11 +40,13 @@ function send(header, body) { }) request .then((result) => { - console.log(result.body) + console.log('EEEEEEEEEEEEEEEEEEEENNNNNNNNNNNNNNNNNNVIO correo>>>>'); + console.log(result.body); return result; }) .catch((error) => { - console.log(error.statusCode) + console.log(error.statusCode); + console.log(error); return error; }) }; @@ -78,7 +80,7 @@ function sendTicket(header, values) { "codeTicket": values.codeTicket, "eventName": values.eventName, "dateInscription": values.dateInscription, - "color": values.color, + "color": (values.color)? values.color : 'gray', } }; @@ -99,7 +101,7 @@ function sendListaEspera(header, values) { "tipoEntrada": values.tipoEntrada, "eventName": values.eventName, "dateInscription": values.dateInscription, - "color": values.color, + "color": (values.color) ? values.color : 'gray', } }; diff --git a/modules/events/event.controller.js b/modules/events/event.controller.js index 4b3f734..5430dce 100644 --- a/modules/events/event.controller.js +++ b/modules/events/event.controller.js @@ -34,7 +34,7 @@ const extraControllers = { try { 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) { 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 createInscription: async(req, res, next) => { const params = extractParamsFromRequest(req, res, {}); - +console.log('CREATE INSCRIPTION>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>< ', params); //Iniciamos entidades relacionadas con la inscripción. let dataUser = { id: (req.user) ? req.user.id : null, @@ -391,16 +391,22 @@ console.log('actualizo confirmados de la nueva reserva'); dataInscription.validated = false; //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, dataUser.userResult.user.id, dataInscription.type, dataInscription.validated, dataInscription.source, null, - dataInscription.event.overflow_eventId) - else + dataInscription.event.overflow_eventId); + } + 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); + } } else 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); - - member.marketing_memberId = await eventInscriptionService._addMember(marketingListOfInscription, member); - eventInscriptionService._updateMarketingMemberOfInscription(dataInscription.inscription.id, member.marketing_memberId); + try + { + 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 @@ -474,12 +484,19 @@ console.log(member); 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); - if (member.validated) - emailHelper.sendTicket(headerMail, bodyMail) - else - emailHelper.sendListaEspera(headerMail, bodyMail); + + try + { + 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) }, diff --git a/modules/events/event.service.js b/modules/events/event.service.js index f4a4a6d..1df0cee 100644 --- a/modules/events/event.service.js +++ b/modules/events/event.service.js @@ -52,13 +52,14 @@ const extraMethods = { confirmed: confirmed, }, { - where: { id: eventId } + where: { id: eventId, typeId: { [Sequelize.Op.ne]: null} } }) .then(function (result) { - //const aaa = result[0]; - //console.log('aaaaaaaaaaaaaaaaaaaaaaaaaaa'); - //console.log(aaa); - resolve((result[0] === 1)); +console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>