Correo incompleto
This commit is contained in:
@@ -4,23 +4,31 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
|
||||
const validarSinTicket = async (body) => {
|
||||
return usuarioInscrito(body.numeroCuenta, 0)
|
||||
.then((res) => {
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario: body.idUsuario,
|
||||
validacion: 2,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
// return usuarioInscrito(body.numeroCuenta, 0)
|
||||
// .then((res) => {
|
||||
// return Inscripcion.update(
|
||||
// {
|
||||
// validacion: 1,
|
||||
// },
|
||||
// {
|
||||
// where: {
|
||||
// idUsuario: body.idUsuario,
|
||||
// },
|
||||
// }
|
||||
// );
|
||||
// })
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario: body.idUsuario,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido.',
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('¡ No fue posible validar la inscripción !. ');
|
||||
|
||||
@@ -4,52 +4,57 @@ const Usuario = require(`${dbPath}/Usuario`);
|
||||
const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
|
||||
const validarTicket = async (body) => {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
if (body.validacion == 1) {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio, validacion: 1 },
|
||||
});
|
||||
}
|
||||
return (
|
||||
Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue validado');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio: body.folio,
|
||||
},
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
if (body.validacion == 1) {
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio, validacion: 1 },
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 0)
|
||||
throw new Error(
|
||||
'El administrador a declinado el ticket, ya que los datos no coinciden.'
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue validado');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio: body.folio,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
attributes: ['numeroCuenta'],
|
||||
}).then((res) => {
|
||||
return usuarioInscrito(res.numeroCuenta, 1).then(async (res) => {
|
||||
return {
|
||||
message: '¡ El ticket a sido validado de forma correcta !',
|
||||
};
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 0)
|
||||
throw new Error(
|
||||
'El administrador a declinado el ticket, ya que los datos no coinciden.'
|
||||
);
|
||||
})
|
||||
// .then((res) => {
|
||||
// return Usuario.findOne({
|
||||
// where: { idUsuario },
|
||||
// attributes: ['numeroCuenta'],
|
||||
// }).then((res) => {
|
||||
// return usuarioInscrito(res.numeroCuenta, 1).then(async (res) => {
|
||||
// return {
|
||||
// message: '¡ El ticket a sido validado de forma correcta !',
|
||||
// };
|
||||
// });
|
||||
// });
|
||||
// })
|
||||
.then((res) => ({
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = validarTicket;
|
||||
|
||||
@@ -2,7 +2,8 @@ const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
const { validarNumeroEntero, validarNumero } = require('../../helper/validar');
|
||||
const { eliminarArchivo } = require('../../helper/helper');
|
||||
const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correoInscripciones = require('../../helper/correo');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
@@ -13,6 +14,9 @@ const inscripcion = async (body, file) => {
|
||||
const monto = validarNumero(body.monto, 'monto', true);
|
||||
const folio = body.folio;
|
||||
|
||||
let correo = {};
|
||||
let email = '';
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio },
|
||||
})
|
||||
@@ -22,6 +26,8 @@ const inscripcion = async (body, file) => {
|
||||
where: { idUsuario, idArea, cancelacion: 0 },
|
||||
}).then((res) => {
|
||||
if (res) throw new Error('Ya estas registrado en esta área');
|
||||
email = `419085500@pcpuma.acatlan.unam.mx`;
|
||||
correo = correoInscripciones();
|
||||
if (file && folio && body.fechaTicket) {
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
@@ -47,6 +53,7 @@ const inscripcion = async (body, file) => {
|
||||
.then((res) => {
|
||||
if (file)
|
||||
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]);
|
||||
gmail(correo.subject, email, correo.msj);
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
|
||||
Reference in New Issue
Block a user