.
This commit is contained in:
parent
19bd691ce0
commit
66018d1124
@ -6,6 +6,29 @@ const moment = require('moment');
|
|||||||
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
|
const { generateService, parseParamsToFindOptions } = require('../../helpers/service.helper');
|
||||||
const models = require('../../core/models');
|
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 = {
|
const extraMethods = {
|
||||||
|
|
||||||
_getInscriptionById: (Id) => {
|
_getInscriptionById: (Id) => {
|
||||||
@ -75,7 +98,7 @@ const extraMethods = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_createInscription: (eventId, userId, type, validated, source, reservationId, overflowEventId) => {
|
_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);
|
console.log(eventId, userId, type, validated, source, reservationId, overflowEventId);
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
@ -84,7 +107,7 @@ console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<valores de la inscripcion');
|
|||||||
date: moment().utc(),
|
date: moment().utc(),
|
||||||
userId: userId,
|
userId: userId,
|
||||||
type: type,
|
type: type,
|
||||||
code_ticket: ('ENT-' + (Date.now() + (Math.floor(Math.random()) * (9 - 1) + 1))),
|
code_ticket: ('ENT-' + generateNewCodeTicket()),
|
||||||
source: source,
|
source: source,
|
||||||
validated: validated,
|
validated: validated,
|
||||||
reservationId: reservationId,
|
reservationId: reservationId,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user