Correo incompleto
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user