This commit is contained in:
David Arranz 2019-07-26 11:23:06 +02:00
parent 19bd691ce0
commit 66018d1124

View File

@ -6,6 +6,29 @@ const moment = require('moment');
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
const models = require('../../core/models');
function generateNewCodeTicket() {
this.length = 8;
this.timestamp = +new Date;
var _getRandomInt = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
this.generate = function () {
var ts = this.timestamp.toString();
var parts = ts.split("").reverse();
var id = "";
for (var i = 0; i < this.length; ++i) {
var index = _getRandomInt(0, parts.length - 1);
id += parts[index];
}
return id;
}
}
const extraMethods = {
_getInscriptionById: (Id) => {
@ -75,7 +98,7 @@ const extraMethods = {
},
_createInscription: (eventId, userId, type, validated, source, reservationId, overflowEventId) => {
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<valores de la inscripcion');
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<valores de la inscripcion');
console.log(eventId, userId, type, validated, source, reservationId, overflowEventId);
return new Promise(function (resolve, reject) {
@ -84,7 +107,7 @@ console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<valores de la inscripcion');
date: moment().utc(),
userId: userId,
type: type,
code_ticket: ('ENT-' + (Date.now() + (Math.floor(Math.random()) * (9 - 1) + 1))),
code_ticket: ('ENT-' + generateNewCodeTicket()),
source: source,
validated: validated,
reservationId: reservationId,