.
This commit is contained in:
parent
c22a469ae5
commit
5f4b7fc3f9
@ -147,23 +147,19 @@ const extraControllers = {
|
||||
const userId = req.user.id;
|
||||
var result = null;
|
||||
|
||||
//console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', params, req.user.level);
|
||||
if (!eventId)
|
||||
return handleResultResponse("Es necesario el ID del evento", null, params, res, httpStatus.NOT_FOUND);
|
||||
|
||||
|
||||
try {
|
||||
if (req.user.level === 8) result = await eventInscriptionService._getInscriptionOnlineByEvent(eventId);
|
||||
result = await eventInscriptionService._getInscriptionOnlineByEvent(eventId);
|
||||
//No se le llamará nunca desde la app, la app trata todas las incripciopnes como normales
|
||||
// else result = await eventInscriptionService._getInscriptionByEventAndUser(eventId, userId);
|
||||
|
||||
return handleResultResponse(result, null, params, res, result === null ? httpStatus.NOT_FOUND : httpStatus.OK);
|
||||
} catch (error) {
|
||||
return handleErrorResponse(MODULE_NAME, "getInscriptionsOnline", error, res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
@ -4,23 +4,23 @@ const eventInscriptionService = require("./events_inscriptions.service");
|
||||
const marketing = require("../../helpers/sendinblue.helper");
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// dataInscription {incription:{...}, {..., event:{...}, reservation:{...}, user:{...}}
|
||||
// dataInscription {incription:{...}, event:{...}, reservation:{...}, user:{...}}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/*AHORA SE ALMACENA TODO EN UNA ÚNICA LISTA DE MAILCHIMP, QUE ES LA DEL EVENTO
|
||||
/*AHORA SE ALMACENA TODO EN UNA ÚNICA LISTA DE MAILCHIMP, QUE ES LA DEL EVENTO
|
||||
(si en un futuro se quiere tener listas independientes, bastaría con tratarlo aqui los campos de marketinglist de la reserva ...)
|
||||
if (dataInscription.inscription.reservationId)
|
||||
marketingListOfInscription = dataInscription.reservation.marketingList
|
||||
else if (dataInscription.inscription.overflowEventId)
|
||||
marketingListOfInscription = (await _getEvent(dataInscription.inscription.overflowEventId)).marketingList;
|
||||
else
|
||||
marketingListOfInscription = dataInscription.event.marketingList;
|
||||
if (dataInscription.inscription.reservationId)
|
||||
marketingListOfInscription = dataInscription.reservation.marketingList
|
||||
else if (dataInscription.inscription.overflowEventId)
|
||||
marketingListOfInscription = (await _getEvent(dataInscription.inscription.overflowEventId)).marketingList;
|
||||
else
|
||||
marketingListOfInscription = dataInscription.event.marketingList;
|
||||
*/
|
||||
function _generateMarketingDTO(dataInscription) {
|
||||
let inscriptionDTO = {};
|
||||
|
||||
console.log('entro>>> ', dataInscription);
|
||||
let inscription = dataInscription.inscription ? dataInscription.inscription : dataInscription;
|
||||
|
||||
console.log('entro>>>', inscription);
|
||||
console.log('inscripción>>> ', inscription);
|
||||
if (inscription) {
|
||||
inscriptionDTO.id = inscription.id;
|
||||
inscriptionDTO.source = inscription.source;
|
||||
@ -30,25 +30,25 @@ function _generateMarketingDTO(dataInscription) {
|
||||
inscriptionDTO.date_inscription = inscription.date;
|
||||
inscriptionDTO.code_ticket = inscription.code_ticket;
|
||||
inscriptionDTO.validated = inscription.validated;
|
||||
|
||||
|
||||
inscriptionDTO.reservation_code = inscription.reservation ? inscription.reservation.reservation_code : null;
|
||||
inscriptionDTO.color = inscription.reservation ? inscription.reservation.color : null;
|
||||
inscriptionDTO.description = (inscription.reservation ? inscription.reservation.description : "Entrada").toUpperCase();
|
||||
inscriptionDTO.qrConfig= null;
|
||||
inscriptionDTO.qrCode= null;
|
||||
inscriptionDTO.qrConfig = null;
|
||||
inscriptionDTO.qrCode = null;
|
||||
|
||||
if (inscription.user) {
|
||||
//Era para mailchimp
|
||||
/// inscriptionDTO.marketing_memberId = inscription.marketing_memberId ? inscription.marketing_memberId : null;
|
||||
inscriptionDTO.email = inscription.user.email;
|
||||
inscriptionDTO.name = inscription.user.name;
|
||||
inscriptionDTO.surname = inscription.user.surname;
|
||||
inscriptionDTO.userId = inscription.user.id;
|
||||
inscriptionDTO.entity = inscription.reservation && inscription.reservation.Entity ? inscription.reservation.Entity.name : (inscription.user.Entity ? inscription.user.Entity.name : inscription.user.entityId);
|
||||
//Era para mailchimp
|
||||
/// inscriptionDTO.marketing_memberId = inscription.marketing_memberId ? inscription.marketing_memberId : null;
|
||||
inscriptionDTO.email = inscription.user.email;
|
||||
inscriptionDTO.name = inscription.user.name;
|
||||
inscriptionDTO.surname = inscription.user.surname;
|
||||
inscriptionDTO.userId = inscription.user.id;
|
||||
inscriptionDTO.entity = inscription.reservation && inscription.reservation.Entity ? inscription.reservation.Entity.name : (inscription.user.Entity ? inscription.user.Entity.name : inscription.user.entityId);
|
||||
};
|
||||
|
||||
}
|
||||
console.log('salgo>>>', inscriptionDTO);
|
||||
console.log('salgo>>>', inscriptionDTO);
|
||||
return inscriptionDTO;
|
||||
}
|
||||
|
||||
@ -57,43 +57,43 @@ function sleep(time) {
|
||||
}
|
||||
|
||||
|
||||
async function _addMember (inscriptionDTO) {
|
||||
console.debug('>>>> _addMember', inscriptionDTO.email);
|
||||
console.debug('>>>> event_marketing_list', inscriptionDTO.event_marketing_list);
|
||||
// console.debug(member);
|
||||
async function _addMember(inscriptionDTO) {
|
||||
console.debug('>>>> _addMember', inscriptionDTO.email);
|
||||
console.debug('>>>> event_marketing_list', inscriptionDTO.event_marketing_list);
|
||||
// console.debug(member);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!inscriptionDTO.event_marketing_list) {
|
||||
// || !member.validated) {
|
||||
resolve(inscriptionDTO);
|
||||
} else {
|
||||
marketing
|
||||
.addMember(inscriptionDTO.event_marketing_list, inscriptionDTO)
|
||||
.then(function (result) {
|
||||
resolve(result.ID);
|
||||
})
|
||||
.catch(function (error) {
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!inscriptionDTO.event_marketing_list) {
|
||||
// || !member.validated) {
|
||||
resolve(inscriptionDTO);
|
||||
} else {
|
||||
marketing
|
||||
.addMember(inscriptionDTO.event_marketing_list, inscriptionDTO)
|
||||
.then(function (result) {
|
||||
resolve(result.ID);
|
||||
})
|
||||
.catch(function (error) {
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function _deleteMember (idLista, email) {
|
||||
console.debug(
|
||||
"Elimino miembro de la lista de marketing>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<",
|
||||
email,
|
||||
idLista,
|
||||
);
|
||||
async function _deleteMember(idLista, email) {
|
||||
console.debug(
|
||||
"Elimino miembro de la lista de marketing>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<",
|
||||
email,
|
||||
idLista,
|
||||
);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!idLista || !email) {
|
||||
resolve();
|
||||
} else {
|
||||
resolve(marketing.deleteMember(idLista, email));
|
||||
}
|
||||
});
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (!idLista || !email) {
|
||||
resolve();
|
||||
} else {
|
||||
resolve(marketing.deleteMember(idLista, email));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function addMarketingList(dataUser, dataInscription) {
|
||||
@ -105,26 +105,26 @@ async function addMarketingList(dataUser, dataInscription) {
|
||||
|
||||
|
||||
|
||||
async function syncronizeEventWithMarketingList (eventId) {
|
||||
async function syncronizeEventWithMarketingList(eventId) {
|
||||
let result = false;
|
||||
try {
|
||||
let inscriptionsToSync = await eventInscriptionService._getInscriptionsWithoutMemberId(eventId);
|
||||
|
||||
|
||||
for (var i = 0; i < inscriptionsToSync.length; i++) {
|
||||
const item = inscriptionsToSync[i].get({
|
||||
plain: true
|
||||
});
|
||||
const item = inscriptionsToSync[i].get({
|
||||
plain: true
|
||||
});
|
||||
|
||||
sleep(1000 * i).then(function () {
|
||||
let inscriptionDTO = _addMember(_generateMarketingDTO(item));
|
||||
// let marketingDTO = _generateMarketingDTO(item);
|
||||
// console.log(marketingDTO)
|
||||
// _deleteMember(marketingDTO.event_marketing_list, marketingDTO.email)
|
||||
});
|
||||
sleep(1000 * i).then(function () {
|
||||
let inscriptionDTO = _addMember(_generateMarketingDTO(item));
|
||||
// let marketingDTO = _generateMarketingDTO(item);
|
||||
// console.log(marketingDTO)
|
||||
// _deleteMember(marketingDTO.event_marketing_list, marketingDTO.email)
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
result = true;
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user