arreglos a la validacion
This commit is contained in:
@@ -5,12 +5,24 @@ const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
|
||||
const validarSinTicket = async (body) => {
|
||||
console.log(body.numeroCuenta);
|
||||
return usuarioInscrito(body.numeroCuenta)
|
||||
.then(async (res) => {
|
||||
return {
|
||||
message: '¡ La inscripción se valido de forma correcta !',
|
||||
};
|
||||
return usuarioInscrito(body.numeroCuenta, 0)
|
||||
.then((res) => {
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario: body.idUsuario,
|
||||
validacion: 2,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido.',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('¡ No fue posible validar la inscripción !. ');
|
||||
});
|
||||
|
||||
@@ -10,6 +10,12 @@ const validarTicket = async (body) => {
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio, validacion: 1 },
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya fue validado');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
@@ -23,7 +29,6 @@ const validarTicket = async (body) => {
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este ticket ya fue validado');
|
||||
if (body.validacion === 0)
|
||||
throw new Error(
|
||||
'El administrador a declinado el ticket, ya que los datos no coinciden.'
|
||||
@@ -34,7 +39,7 @@ const validarTicket = async (body) => {
|
||||
where: { idUsuario },
|
||||
attributes: ['numeroCuenta'],
|
||||
}).then((res) => {
|
||||
return usuarioInscrito(res.numeroCuenta).then(async (res) => {
|
||||
return usuarioInscrito(res.numeroCuenta, 1).then(async (res) => {
|
||||
return {
|
||||
message: '¡ El ticket a sido validado de forma correcta !',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user