arreglos a la validacion
This commit is contained in:
@@ -44,14 +44,14 @@ const obtenerCarrera = async (idCarrera) => {
|
||||
});
|
||||
};
|
||||
|
||||
const usuarioInscrito = async (numeroCuenta) => {
|
||||
const usuarioInscrito = async (numeroCuenta, realizoPago) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(
|
||||
`INSERT INTO alumno_inscrito(id_cuenta,id_periodo,id_plataforma,realizo_pago,platica) values(${numeroCuenta}, 20, 4, 1, 1)`
|
||||
`INSERT INTO alumno_inscrito(id_cuenta,id_periodo,id_plataforma,realizo_pago,platica) values(${numeroCuenta}, 20, 4, ${realizoPago}, 1)`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
|
||||
@@ -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 !',
|
||||
};
|
||||
|
||||
@@ -37,7 +37,6 @@ const inscripcion = async (body, file) => {
|
||||
} else {
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
validacion: 1,
|
||||
idArea,
|
||||
hizoPago: false,
|
||||
fechaInscripcion: ahora.format(),
|
||||
|
||||
@@ -20,7 +20,7 @@ app.post(`${route}/login`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get(`${route}/inscripciones`, (req, res) => {
|
||||
app.get(`${route}/inscripciones`, verificaToken, (req, res) => {
|
||||
return inscripciones(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
|
||||
Reference in New Issue
Block a user