Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de3046936f | |||
| 43551937cc | |||
| c914300997 | |||
| 8629858760 | |||
| a2ac9f2e5c | |||
| 6d85b66486 | |||
| 9d6a87854d | |||
| 703005ef5c | |||
| fb26d8adf7 | |||
| 63fc909859 | |||
| c3954b0110 | |||
| 21b37735b3 | |||
| 10dc4a0e3c | |||
| b1ff83b576 | |||
| ccd18dfe77 | |||
| 975aadcbea | |||
| 3d0043cbc1 | |||
| f8350e3961 | |||
| 9695122cdf | |||
| 5d895e99ec | |||
| b1b2b38d88 | |||
| 4cdadae9ba | |||
| e2a8dd5f98 | |||
| 2bb8336f8a | |||
| 3f1099b29b | |||
| 2cd8c0810c | |||
| 73d661cefc | |||
| 47f48a4464 | |||
| a9d148e714 | |||
| 591905d20e | |||
| 82b0d07c5c | |||
| 028cc45405 | |||
| 52a6cb614b | |||
| c5f488a7c9 | |||
| e8305da5a3 | |||
| 156daa4242 | |||
| 7586cb4aae | |||
| 80852bb2c9 | |||
| 4eb67e7f3f | |||
| 83da896aa4 | |||
| d311b3385d | |||
| 01885c6aef | |||
| c120c86409 | |||
| 7d4a8e150a |
Generated
+32
@@ -19,6 +19,7 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"fs": "^0.0.1-security",
|
||||
"gmail-send": "^1.8.14",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mariadb": "^2.5.3",
|
||||
"moment": "^2.29.1",
|
||||
@@ -1071,6 +1072,15 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/gmail-send": {
|
||||
"version": "1.8.14",
|
||||
"resolved": "https://registry.npmjs.org/gmail-send/-/gmail-send-1.8.14.tgz",
|
||||
"integrity": "sha512-hc+4Ej7ZJtw0G5sync10pmWkpPXIabkQ+p/a92lPPTXni3ChEU9sR2wxOvK6Hx+5Ou+2m9h1cVffWEgtR6Gzkw==",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21",
|
||||
"nodemailer": "^6.6.5"
|
||||
}
|
||||
},
|
||||
"node_modules/got": {
|
||||
"version": "9.6.0",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
|
||||
@@ -1757,6 +1767,14 @@
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nodemailer": {
|
||||
"version": "6.7.2",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz",
|
||||
"integrity": "sha512-Dz7zVwlef4k5R71fdmxwR8Q39fiboGbu3xgswkzGwczUfjp873rVxt1O46+Fh0j1ORnAC6L9+heI8uUpO6DT7Q==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/nodemon": {
|
||||
"version": "2.0.15",
|
||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz",
|
||||
@@ -3558,6 +3576,15 @@
|
||||
"ini": "2.0.0"
|
||||
}
|
||||
},
|
||||
"gmail-send": {
|
||||
"version": "1.8.14",
|
||||
"resolved": "https://registry.npmjs.org/gmail-send/-/gmail-send-1.8.14.tgz",
|
||||
"integrity": "sha512-hc+4Ej7ZJtw0G5sync10pmWkpPXIabkQ+p/a92lPPTXni3ChEU9sR2wxOvK6Hx+5Ou+2m9h1cVffWEgtR6Gzkw==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.21",
|
||||
"nodemailer": "^6.6.5"
|
||||
}
|
||||
},
|
||||
"got": {
|
||||
"version": "9.6.0",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
|
||||
@@ -4092,6 +4119,11 @@
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"nodemailer": {
|
||||
"version": "6.7.2",
|
||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.7.2.tgz",
|
||||
"integrity": "sha512-Dz7zVwlef4k5R71fdmxwR8Q39fiboGbu3xgswkzGwczUfjp873rVxt1O46+Fh0j1ORnAC6L9+heI8uUpO6DT7Q=="
|
||||
},
|
||||
"nodemon": {
|
||||
"version": "2.0.15",
|
||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"fs": "^0.0.1-security",
|
||||
"gmail-send": "^1.8.14",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"mariadb": "^2.5.3",
|
||||
"moment": "^2.29.1",
|
||||
|
||||
+114
-19
@@ -1,31 +1,24 @@
|
||||
require('./config');
|
||||
const mariadb = require('mariadb');
|
||||
|
||||
const pool1 = mariadb.createPool({
|
||||
host: process.env.SAT_HOST,
|
||||
user: process.env.SAT_USER,
|
||||
password: process.env.SAT_PASSWORD,
|
||||
database: process.env.SATL_DB,
|
||||
});
|
||||
|
||||
const pool2 = mariadb.createPool({
|
||||
const pool = mariadb.createPool({
|
||||
host: process.env.HOST_DB,
|
||||
user: process.env.USER_DB,
|
||||
password: process.env.PASSWORD_DB,
|
||||
database: process.env.SATE_DB,
|
||||
database: process.env.SAT_DB,
|
||||
});
|
||||
|
||||
const obtenerIdCarrera = async (numeroCuenta) => {
|
||||
const conn = await pool1.getConnection().catch((err) => {
|
||||
const obtenerDatosUsr = async (numeroCuenta) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(`SELECT id_carrera FROM alumno WHERE id_cuenta = ${numeroCuenta}`)
|
||||
.query(
|
||||
`SELECT id_carrera, generacion FROM alumno WHERE id_cuenta = ${numeroCuenta}`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
// console.log(rows[0]);
|
||||
// if (rows[0].length === 0) return null;
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -35,7 +28,7 @@ const obtenerIdCarrera = async (numeroCuenta) => {
|
||||
};
|
||||
|
||||
const obtenerCarrera = async (idCarrera) => {
|
||||
const conn = await pool1.getConnection().catch((err) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
@@ -51,14 +44,14 @@ const obtenerCarrera = async (idCarrera) => {
|
||||
});
|
||||
};
|
||||
|
||||
const usuarioInscrito = async (numeroCuenta) => {
|
||||
const conn = await pool2.getConnection().catch((err) => {
|
||||
const usuarioInscrito = async (numeroCuenta, idArea) => {
|
||||
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(realizo_pago, id_cuenta, id_periodo, id_plataforma) values(1, ${numeroCuenta}, 20, ${idArea})`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
@@ -70,4 +63,106 @@ const usuarioInscrito = async (numeroCuenta) => {
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { obtenerIdCarrera, obtenerCarrera, usuarioInscrito };
|
||||
const agregarRecibo = async (folio, monto, fechaTicket, numeroCuenta) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(
|
||||
`INSERT INTO recibo(folio_recibo, monto, fecha_recibo, fecha_registro, id_cuenta, id_usuario) values(${folio}, ${monto}, STR_TO_DATE('${fechaTicket}', '%m/%d/%Y'), now() ,${numeroCuenta}, 134)`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
conn.end();
|
||||
throw new Error('Hubo un problema con el querry.' + err);
|
||||
});
|
||||
};
|
||||
|
||||
const agregarDetalleServicio = async (monto, numeroCuenta) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(
|
||||
`INSERT INTO detalle_servicio(monto, numero_hojas, id_cuenta, id_servicio, id_usuario, id_periodo) values(${monto}, 0, ${numeroCuenta}, 4, 134, 20)`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
conn.end();
|
||||
throw new Error('Hubo un problema con el querry.' + err);
|
||||
});
|
||||
};
|
||||
|
||||
const borrarInscripcion = async (numeroCuenta) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(
|
||||
`DELETE FROM alumno_inscrito WHERE id_cuenta = ${numeroCuenta} AND periodo = 20`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
conn.end();
|
||||
throw new Error('Hubo un problema con el querry.' + err);
|
||||
});
|
||||
};
|
||||
|
||||
const borrarRecibo = async (folio) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(`DELETE FROM recibo WHERE folio_recibo = ${folio}`)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
conn.end();
|
||||
throw new Error('Hubo un problema con el querry.' + err);
|
||||
});
|
||||
};
|
||||
|
||||
const borrarDetalleServicio = async (numeroCuenta) => {
|
||||
const conn = await pool.getConnection().catch((err) => {
|
||||
throw new Error('No se pudo conectar con la db. ' + err);
|
||||
});
|
||||
|
||||
return conn
|
||||
.query(
|
||||
`DELETE FROM detalle_servicio WHERE id_Cuenta = ${numeroCuenta} AND id_servicio = 4 AND id_periodo = 20`
|
||||
)
|
||||
.then((rows) => {
|
||||
conn.end();
|
||||
return rows[0];
|
||||
})
|
||||
.catch((err) => {
|
||||
conn.end();
|
||||
throw new Error('Hubo un problema con el querry.' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
obtenerDatosUsr,
|
||||
obtenerCarrera,
|
||||
usuarioInscrito,
|
||||
agregarRecibo,
|
||||
agregarDetalleServicio,
|
||||
borrarInscripcion,
|
||||
borrarRecibo,
|
||||
borrarDetalleServicio,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const { Op } = require('sequelize');
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const actualizarTicket = async (body) => {
|
||||
const idInscripcion = validarNumeroEntero(
|
||||
body.idInscripcion,
|
||||
'id Inscripcion',
|
||||
true
|
||||
);
|
||||
const monto = validarNumeroEntero(body.monto, 'monto', true);
|
||||
const folio = validarNumeroEntero(body.folio, 'folio', true);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: {
|
||||
idInscripcion,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No pudimos encontrar este ticket.');
|
||||
return Inscripcion.findOne({
|
||||
where: {
|
||||
folio,
|
||||
cancelacion: 0,
|
||||
idInscripcion: { [Op.ne]: idInscripcion },
|
||||
},
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
if (res)
|
||||
throw new Error('¡ Este folio ya fue utilizado por otra inscripción !');
|
||||
})
|
||||
.then((res) => {
|
||||
return Inscripcion.update(
|
||||
{
|
||||
folio,
|
||||
monto,
|
||||
fechaTicket: body.fechaTicket,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idInscripcion,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
'¡ Los datos de la inscripción fueron actualizados de forma correcta !',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible actualizar los datos del ticket. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = actualizarTicket;
|
||||
@@ -0,0 +1,36 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
|
||||
const cancelarInscripcion = async (body) => {
|
||||
const idInscripcion = validarNumeroEntero(
|
||||
body.idInscripcion,
|
||||
'id Inscripcion',
|
||||
true
|
||||
);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { idInscripcion },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Lo sentimos esta inscripción no existe.');
|
||||
return Inscripcion.update(
|
||||
{
|
||||
cancelacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idInscripcion,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => ({
|
||||
message: '¡ Esta inscripción fue cancelada de forma correcta !',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('¡ No fue posible validar la inscripción !. ');
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = cancelarInscripcion;
|
||||
@@ -0,0 +1,23 @@
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const motivo = async (body) => {
|
||||
const folio = validarNumeroEntero(body.folio, 'folio', true);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No pudimos encontrar este ticket.');
|
||||
return Inscripcion.findOne({
|
||||
where: { folio, validacion: 0 },
|
||||
attributes: ['motivo'],
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible encontrar el ticket. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = motivo;
|
||||
@@ -29,30 +29,17 @@ const reporte = async (body) => {
|
||||
],
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (body.tipo === 'CSV') {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numero_cuenta: res[i].Usuario.numeroCuenta,
|
||||
id_area: res[i].idArea,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizo_pago: res[i].hizoPago,
|
||||
fecha_inscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numeroCuenta: res[i].Usuario.numeroCuenta,
|
||||
validacion: res[i].validacion,
|
||||
confirmacion: res[i].confirmacion,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizoPago: res[i].hizoPago,
|
||||
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
idArea: res[i].idArea,
|
||||
});
|
||||
}
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
data.push({
|
||||
numeroCuenta: res[i].Usuario.numeroCuenta,
|
||||
idArea: res[i].idArea,
|
||||
folio: res[i].folio,
|
||||
monto: res[i].monto,
|
||||
hizoPago: res[i].hizoPago,
|
||||
fechaInscripcion: moment(res[i].fechaInscripcion).format('L'),
|
||||
validacion: res[i].validacion,
|
||||
motivoDeclinacion: res[i].motivo,
|
||||
});
|
||||
}
|
||||
await helper.eliminarArchivo(path).catch((err) => {});
|
||||
return helper.crearArchivo(path, convertArrayToCSV(data));
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const ticket = async (body) => {
|
||||
const folio = validarNumeroEntero(body.folio, 'folio', true);
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio: body.folio },
|
||||
attributes: ['rutaTicket', 'extension'],
|
||||
}).then((res) => {
|
||||
return { rutaTicket: res.rutaTicket, extension: res.extension };
|
||||
});
|
||||
attributes: ['rutaTicket', 'extension', 'motivo'],
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('No pudimos encontrar este ticket.');
|
||||
return {
|
||||
rutaTicket: res.rutaTicket,
|
||||
extension: res.extension,
|
||||
motivo: res.motivo,
|
||||
};
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = ticket;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { Op } = require('sequelize');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
|
||||
const todasInscripciones = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const validacion = validarNumeroEntero(body.validacion, 'validacion', true);
|
||||
return Inscripcion.findAll({
|
||||
where: { validacion: body.validacion },
|
||||
where: { validacion, cancelacion: 0 },
|
||||
include: [
|
||||
{
|
||||
model: Usuario,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
|
||||
const validarSinTicket = async (body) => {
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'usuario', true);
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: 1,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
idUsuario,
|
||||
},
|
||||
}
|
||||
)
|
||||
.then((res) => ({
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
}))
|
||||
.catch((err) => {
|
||||
throw new Error('¡ No fue posible validar la inscripción !. ');
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = validarSinTicket;
|
||||
@@ -1,47 +1,88 @@
|
||||
const {
|
||||
validarNumeroEntero,
|
||||
validarNumeroCuenta,
|
||||
} = require('../../helper/validar');
|
||||
const {
|
||||
borrarInscripcion,
|
||||
borrarRecibo,
|
||||
borrarDetalleServicio,
|
||||
} = require('../../config/mariadb.conf');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
const { usuarioInscrito } = require('../../config/mariadb.conf');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correoDeclinar = require('../../helper/correoDeclinar');
|
||||
|
||||
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;
|
||||
return Inscripcion.update(
|
||||
{
|
||||
validacion: body.validacion,
|
||||
},
|
||||
{
|
||||
where: {
|
||||
folio: body.folio,
|
||||
},
|
||||
const folio = validarNumeroEntero(body.folio, 'folio', true);
|
||||
const numeroCuenta = validarNumeroCuenta(
|
||||
body.numeroCuenta,
|
||||
'número de cuenta',
|
||||
true
|
||||
);
|
||||
|
||||
let correo = {};
|
||||
let email = '';
|
||||
|
||||
return (
|
||||
Inscripcion.findOne({
|
||||
where: { folio },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este folio no existe');
|
||||
idUsuario = res.idUsuario;
|
||||
if (body.validacion == 1) {
|
||||
return Inscripcion.findOne({
|
||||
where: { 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,
|
||||
cancelacion: 0,
|
||||
},
|
||||
}
|
||||
);
|
||||
})
|
||||
.then((res) => {
|
||||
return Usuario.findOne({
|
||||
where: { idUsuario },
|
||||
attributes: ['numeroCuenta'],
|
||||
}).then((res) => {
|
||||
return usuarioInscrito(res.numeroCuenta).then(async (res) => {
|
||||
})
|
||||
//el ticket ya fue validado
|
||||
.then((res) => {
|
||||
if (body.validacion === 0) {
|
||||
email = `${numeroCuenta}@pcpuma.acatlan.unam.mx`;
|
||||
correoDeclinar = correoInscripciones();
|
||||
borrarInscripcion(numeroCuenta);
|
||||
borrarRecibo(folio);
|
||||
borrarDetalleServicio(numeroCuenta);
|
||||
return Inscripcion.update(
|
||||
{ motivo: body.motivo },
|
||||
{
|
||||
where: {
|
||||
folio,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
})
|
||||
.then((res) => {
|
||||
if (body.validacion === 1) {
|
||||
//Insertar en AD
|
||||
return {
|
||||
message: '¡ El ticket a sido validado de forma correcta !',
|
||||
message: '¡El ticket a sido validado de forma correcta!',
|
||||
};
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
});
|
||||
} else
|
||||
return {
|
||||
message: '¡El ticket a sido declinado',
|
||||
};
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new Error('No fue posible validar el ticket. ' + err);
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = validarTicket;
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
const {
|
||||
obtenerIdCarrera,
|
||||
obtenerCarrera,
|
||||
} = require('../../config/mariadb.conf');
|
||||
const validar = require('../../helper/validar');
|
||||
const { obtenerDatosUsr } = require('../../config/mariadb.conf');
|
||||
const { validarNumeroCuenta } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Usuario = require(`${dbPath}/Usuario`);
|
||||
|
||||
const escolares = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
|
||||
const numeroCuenta = validarNumeroCuenta(
|
||||
body.numeroCuenta,
|
||||
'numero cuenta',
|
||||
true
|
||||
);
|
||||
return Usuario.findOne({
|
||||
where: { numeroCuenta: body.numeroCuenta },
|
||||
where: { numeroCuenta },
|
||||
}).then((res) => {
|
||||
if (!res) {
|
||||
return obtenerIdCarrera(body.numeroCuenta).then(async (res) => {
|
||||
return Usuario.create({
|
||||
idUsuario: body.idUsuario,
|
||||
numeroCuenta: body.numeroCuenta,
|
||||
return obtenerDatosUsr(numeroCuenta).then(async (res) => {
|
||||
await Usuario.create({
|
||||
numeroCuenta,
|
||||
nombre: body.nombre,
|
||||
semestre: 8,
|
||||
generacion: res.generacion,
|
||||
carrera: body.carrera,
|
||||
idCarrera: res.id_carrera,
|
||||
});
|
||||
});
|
||||
}
|
||||
return Usuario.findOne({
|
||||
where: { numeroCuenta: body.numeroCuenta },
|
||||
where: { numeroCuenta },
|
||||
attributes: [
|
||||
'idUsuario',
|
||||
'numeroCuenta',
|
||||
'nombre',
|
||||
'semestre',
|
||||
'generacion',
|
||||
'idCarrera',
|
||||
'carrera',
|
||||
],
|
||||
|
||||
@@ -1,28 +1,49 @@
|
||||
const moment = require('moment');
|
||||
const fs = require('fs');
|
||||
const { validarNumeroEntero, validarNumero } = require('../../helper/validar');
|
||||
const {
|
||||
usuarioInscrito,
|
||||
agregarRecibo,
|
||||
agregarDetalleServicio,
|
||||
} = require('../../config/mariadb.conf');
|
||||
const {
|
||||
validarNumeroEntero,
|
||||
validarNumero,
|
||||
validarNumeroCuenta,
|
||||
} = require('../../helper/validar');
|
||||
const { eliminarArchivo } = require('../../helper/helper');
|
||||
const gmail = require('../../helper/gmail');
|
||||
const correoInscripciones = require('../../helper/correo');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const inscripcion = async (body, file) => {
|
||||
const ahora = moment();
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'id Usuario', true);
|
||||
const numeroCuenta = validarNumeroCuenta(
|
||||
body.numeroCuenta,
|
||||
'numero de cuenta',
|
||||
true
|
||||
);
|
||||
const idArea = validarNumeroEntero(body.idArea, 'id Area', true);
|
||||
const monto = validarNumero(body.monto, 'monto', true);
|
||||
const folio = body.folio;
|
||||
const folio = validarNumero(body.folio, 'folio', true, 6);
|
||||
const fechaTicket = body.fechaTicket;
|
||||
|
||||
let correo = {};
|
||||
let email = '';
|
||||
|
||||
return Inscripcion.findOne({
|
||||
where: { folio },
|
||||
where: { folio, cancelacion: 0 },
|
||||
})
|
||||
.then((res) => {
|
||||
if (res) throw new Error('Este folio ya esta registrado');
|
||||
return Inscripcion.findOne({
|
||||
where: { idUsuario, idArea },
|
||||
where: { idUsuario, idArea, cancelacion: 0 },
|
||||
}).then((res) => {
|
||||
if (res) throw new Error('Ya estas registrado en esta área');
|
||||
if (file) {
|
||||
email = `${numeroCuenta}@pcpuma.acatlan.unam.mx`;
|
||||
correo = correoInscripciones();
|
||||
if (file && folio && fechaTicket) {
|
||||
return Inscripcion.create({
|
||||
idUsuario,
|
||||
idArea,
|
||||
@@ -32,7 +53,7 @@ const inscripcion = async (body, file) => {
|
||||
rutaTicket: file.path,
|
||||
extension: file.mimetype.split('/')[1],
|
||||
fechaInscripcion: ahora.format(),
|
||||
fechaTicket: body.fechaTicket,
|
||||
fechaTicket,
|
||||
});
|
||||
} else {
|
||||
return Inscripcion.create({
|
||||
@@ -47,10 +68,19 @@ const inscripcion = async (body, file) => {
|
||||
.then((res) => {
|
||||
if (file)
|
||||
fs.renameSync(file.path, file.path + '.' + file.mimetype.split('/')[1]);
|
||||
usuarioInscrito(numeroCuenta, idArea);
|
||||
agregarRecibo(
|
||||
folio,
|
||||
monto,
|
||||
moment(fechaTicket).format('L'),
|
||||
numeroCuenta
|
||||
);
|
||||
agregarDetalleServicio(monto, numeroCuenta);
|
||||
return gmail(correo.subject, email, correo.msj);
|
||||
})
|
||||
.then((res) => ({
|
||||
message:
|
||||
'¡La inscripción se realizo de manera correcta! Tu inscripción esta sujeta a revisión en caso de no ser correcta se suspende el servicio',
|
||||
'Tu inscripción está sujeta a validación, en caso de no ser correcta o veraz el servicio será suspendido. Por favor revisa tu correo de PCPUMA para confirmar tu registro.',
|
||||
}))
|
||||
.catch((err) => {
|
||||
if (file) eliminarArchivo(file.path);
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
const validar = require('../../helper/validar');
|
||||
const { validarNumeroEntero } = require('../../helper/validar');
|
||||
const dbPath = '../../db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Inscripcion = require(`${dbPath}/Inscripcion`);
|
||||
|
||||
const inscripciones = async (body) => {
|
||||
// const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const idUsuario = validarNumeroEntero(body.idUsuario, 'Usuario', true);
|
||||
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
where: { idUsuario },
|
||||
}).then((res) => {
|
||||
if (!res) return [];
|
||||
return Inscripcion.findAll({
|
||||
where: { idUsuario: body.idUsuario },
|
||||
where: { idUsuario, cancelacion: 0 },
|
||||
attributes: [
|
||||
'idInscripcion',
|
||||
'validacion',
|
||||
'confirmacion',
|
||||
'folio',
|
||||
'monto',
|
||||
'idUsuario',
|
||||
|
||||
@@ -5,17 +5,16 @@ const { crearToken } = require('../../middleware/autentificacion');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
|
||||
const login = async (body) => {
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta);
|
||||
const numeroCuenta = validar.validarNumeroCuenta(body.numeroCuenta, 'número de cuenta', true);
|
||||
const data = {
|
||||
usuario: 'votacionesUser',
|
||||
password: 'poasfnr*/049_]',
|
||||
numeroCuenta: numeroCuenta,
|
||||
passwordUser: body.passwordUser,
|
||||
};
|
||||
|
||||
console.log(numeroCuenta, body.passwordUser);
|
||||
passwordUser: body.passwordUser
|
||||
}
|
||||
|
||||
return axios
|
||||
.post(
|
||||
.post(
|
||||
`https://venus.acatlan.unam.mx/conexionEscolares_test/ingresarAlumno`,
|
||||
data
|
||||
)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
const Usuario = require('./tablas/Usuario');
|
||||
const { encriptar } = require('../helper/encriptar');
|
||||
|
||||
const dataUsuarios = async () => {
|
||||
let usuario = ['416313221', '111111111', '222222222'];
|
||||
let nombre = [
|
||||
'Adriana De Luna Ramirez',
|
||||
'Nombre Falso 1',
|
||||
'Nombre Falso 2',
|
||||
];
|
||||
|
||||
for (let i = 0; i < usuario.length; i++) {
|
||||
await Usuario.create({
|
||||
usuario: usuario[i],
|
||||
nombre: nombre[i],
|
||||
password: encriptar('holi'),
|
||||
idTipoUsuario: 2,
|
||||
});
|
||||
console.log(`Se insertó el usuario ${usuario[i]}.`.magenta);
|
||||
}
|
||||
};
|
||||
|
||||
const exec = async () => {
|
||||
await dataUsuarios();
|
||||
console.log(
|
||||
'\nSe ha instalado exitosamente la información falsa en la base de datos.\n'
|
||||
.underline.bold.green
|
||||
);
|
||||
process.exit();
|
||||
};
|
||||
|
||||
exec();
|
||||
@@ -53,7 +53,7 @@ const sync = async () => {
|
||||
};
|
||||
|
||||
const dataArea = async () => {
|
||||
const data = ['Windows', 'Macintosh', 'Linux', 'Mesa para laptop'];
|
||||
const data = ['Windows', 'Macintosh', 'Linux'];
|
||||
|
||||
console.log('\nPaso 3) Instalando catalogo area.'.bold.blue);
|
||||
for (let i = 0; i < data.length; i++) await Area.create({ area: data[i] });
|
||||
|
||||
@@ -18,16 +18,18 @@ Inscripcion.init(
|
||||
type: DataTypes.INTEGER,
|
||||
defaultValue: 2,
|
||||
},
|
||||
confirmacion: {
|
||||
cancelacion: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
motivo: {
|
||||
type: DataTypes.STRING(100),
|
||||
defaultValue: null,
|
||||
},
|
||||
folio: {
|
||||
type: DataTypes.STRING(5),
|
||||
type: DataTypes.STRING(10),
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
unique: true,
|
||||
},
|
||||
monto: {
|
||||
type: DataTypes.INTEGER,
|
||||
|
||||
@@ -22,8 +22,8 @@ Usuario.init(
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
},
|
||||
semestre: {
|
||||
type: DataTypes.STRING(30),
|
||||
generacion: {
|
||||
type: DataTypes.STRING(5),
|
||||
allowNull: false,
|
||||
},
|
||||
idCarrera: {
|
||||
@@ -43,12 +43,12 @@ Usuario.init(
|
||||
}
|
||||
);
|
||||
|
||||
// Usuario.belongsTo(Carrera, {
|
||||
// foreignKey: {
|
||||
// name: 'idCarrera',
|
||||
// type: DataTypes.INTEGER,
|
||||
// allowNull: false,
|
||||
// },
|
||||
// });
|
||||
Usuario.belongsTo(Carrera, {
|
||||
foreignKey: {
|
||||
name: 'idCarrera',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = Usuario;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
const correoInscripciones = () => ({
|
||||
subject: `Inscripción a CEDETEC`,
|
||||
msj: `
|
||||
<p>Estimado Usuario</p>
|
||||
<p>
|
||||
Su inscripción esta sujeta a revisión, es necesario revisar los datos que registro en el sistema.
|
||||
</p>
|
||||
|
||||
<p>Te sugerimos guardar tu ticket para cualquier aclaración</p>
|
||||
|
||||
<p>Por el momento podras hacer tu confirmación en <a href="https://kalinga.acatlan.unam.mx/cedetec/" target="_blanc">KALINGA</a></p>
|
||||
|
||||
<p>En caso de recibir un correo con el asunto Inscripción declinada se cancelara el servicio y no podras hacer uso de los servicios</p>
|
||||
|
||||
<p>Atentamente:</p>
|
||||
<p>Atención Usuarios DSC</p>
|
||||
`,
|
||||
});
|
||||
|
||||
module.exports = correoInscripciones;
|
||||
@@ -0,0 +1,22 @@
|
||||
const correoDeclinar = () => ({
|
||||
subject: `Tu inscripción a CEDETEC a sido declinada`,
|
||||
msj: `
|
||||
<p>Estimado Usuario</p>
|
||||
<p>
|
||||
Su inscripción a sido declinada, favor de pasar a CEDETEC para aclarar la situción.
|
||||
</p>
|
||||
|
||||
<p>Motivos por los cuales tu inscripción a sido declinada:</p>
|
||||
|
||||
<ul>
|
||||
<li>La foto del ticket no es visible.</li>
|
||||
<li>El ticket no pertenece a CEDETEC</li>
|
||||
<li>Encontramos algún otra anomalía en tu ticket.</li>
|
||||
</ul>
|
||||
|
||||
<p>Atentamente:</p>
|
||||
<p>Atención Usuarios DSC</p>
|
||||
`,
|
||||
});
|
||||
|
||||
module.exports = correoDeclinar;
|
||||
@@ -5,11 +5,10 @@ const send = require('gmail-send')({
|
||||
pass: process.env.GMAILPASSWORD,
|
||||
});
|
||||
|
||||
const gmail = (subject, to, text) => {
|
||||
const gmail = (subject, to, html) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
send({ subject, to, text }, (error, result, fullResult) => {
|
||||
send({ subject, to, html }, (error, result, fullResult) => {
|
||||
if (error) reject(error);
|
||||
console.log(fullResult);
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ const caracterEspecial = (char) => {
|
||||
'#',
|
||||
'%',
|
||||
'\n',
|
||||
'@',
|
||||
];
|
||||
|
||||
for (let i = 0; i < charset.length; i++) if (charset[i] === char) return true;
|
||||
|
||||
@@ -37,10 +37,4 @@ const crearTokenAdmin = (data) => {
|
||||
});
|
||||
};
|
||||
|
||||
const crearTokenOperador = (data) => {
|
||||
return jwt.sign({ data }, process.env.KEY, {
|
||||
expiresIn: Number(process.env.CADUCIDAD_TOKEN_OPERADOR),
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = { verificaToken, crearToken, crearTokenAdmin };
|
||||
|
||||
+45
-2
@@ -1,15 +1,18 @@
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const fs = require('fs');
|
||||
const { validarAlfanumerico } = require('../helper/validar');
|
||||
const { verificaToken } = require('../middleware/autentificacion');
|
||||
const route = '/Admin';
|
||||
const controllerPath = '../controller/Admin';
|
||||
const login = require(`${controllerPath}/login`);
|
||||
const todasInscripciones = require(`${controllerPath}/todasInscripciones`);
|
||||
const ticket = require(`${controllerPath}/ticket`);
|
||||
const actualizarTicket = require(`${controllerPath}/actualizarTicket`);
|
||||
const cancelarInscripcion = require(`${controllerPath}/cancelarInscripcion`);
|
||||
const motivo = require(`${controllerPath}/motivo`);
|
||||
const validarSinTicket = require(`${controllerPath}/validarSinTicket`);
|
||||
const validarTicket = require(`${controllerPath}/validarTicket`);
|
||||
const reporte = require(`${controllerPath}/reporte`);
|
||||
const login = require(`${controllerPath}/login`);
|
||||
|
||||
app.post(`${route}/login`, (req, res) => {
|
||||
return login(req.body)
|
||||
@@ -44,6 +47,36 @@ app.get(`${route}/ticket`, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get(`${route}/motivo`, verificaToken, (req, res) => {
|
||||
return motivo(req.query)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.put(`${route}/actualizar_ticket`, verificaToken, (req, res) => {
|
||||
return actualizarTicket(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.put(`${route}/cancelar_inscripcion`, verificaToken, (req, res) => {
|
||||
return cancelarInscripcion(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.put(`${route}/validar`, verificaToken, (req, res) => {
|
||||
return validarTicket(req.body)
|
||||
.then((data) => {
|
||||
@@ -54,6 +87,16 @@ app.put(`${route}/validar`, verificaToken, (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.put(`${route}/validar_sin_ticket`, verificaToken, (req, res) => {
|
||||
return validarSinTicket(req.body)
|
||||
.then((data) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(400).json({ message: err.message });
|
||||
});
|
||||
});
|
||||
|
||||
app.get(`${route}/reporte`, verificaToken, (req, res) => {
|
||||
return reporte(req.query)
|
||||
.then((data) => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
numero_cuenta,id_area,folio,monto,hizo_pago,fecha_inscripcion
|
||||
419085500,1,99999,20,true,02/26/2022
|
||||
|
||||
|
Reference in New Issue
Block a user