2022-03-06 18:41:23 -06:00
|
|
|
const dbPath = '../../db/tablas';
|
|
|
|
|
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
2022-08-05 16:47:52 -05:00
|
|
|
const {
|
|
|
|
|
validarNumeroEntero,
|
|
|
|
|
validarNumeroCuenta,
|
|
|
|
|
} = require('../../helper/validar');
|
|
|
|
|
const correoInscripcion = require('../../helper/correo');
|
2022-03-06 18:41:23 -06:00
|
|
|
|
|
|
|
|
const validarSinTicket = async (body) => {
|
2022-08-05 16:47:52 -05:00
|
|
|
const numeroCuenta = validarNumeroCuenta(
|
|
|
|
|
body.numeroCuenta,
|
|
|
|
|
'número de cuenta',
|
|
|
|
|
true
|
|
|
|
|
);
|
2022-03-21 14:03:30 -06:00
|
|
|
const idUsuario = validarNumeroEntero(body.idUsuario, 'usuario', true);
|
2022-08-05 16:47:52 -05:00
|
|
|
const idArea = validarNumeroEntero(body.idArea, 'IDAREA', true);
|
|
|
|
|
|
|
|
|
|
let correo = {};
|
|
|
|
|
let email = '';
|
|
|
|
|
|
2022-03-17 00:46:01 -06:00
|
|
|
return Inscripcion.update(
|
|
|
|
|
{
|
|
|
|
|
validacion: 1,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
where: {
|
2022-03-21 14:03:30 -06:00
|
|
|
idUsuario,
|
2022-03-17 00:46:01 -06:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
)
|
2022-08-05 16:47:52 -05:00
|
|
|
.then((res) => {
|
|
|
|
|
email = `${numeroCuenta}@pcpuma.acatlan.unam.mx`;
|
|
|
|
|
usuarioInscrito(numeroCuenta, idArea);
|
|
|
|
|
correo = correoInscripcion();
|
|
|
|
|
gmail(correo.subject, email, correo.msj);
|
|
|
|
|
})
|
2022-03-06 20:02:42 -06:00
|
|
|
.then((res) => ({
|
2022-03-17 00:46:01 -06:00
|
|
|
message: '¡El ticket a sido validado de forma correcta!',
|
2022-03-06 20:02:42 -06:00
|
|
|
}))
|
2022-03-06 18:41:23 -06:00
|
|
|
.catch((err) => {
|
2022-08-05 16:47:52 -05:00
|
|
|
throw new Error('¡No fue posible validar la inscripción!');
|
2022-03-06 18:41:23 -06:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = validarSinTicket;
|