INCLUSION A CONSULTA XSYSTEM API.
This commit is contained in:
@@ -10,7 +10,6 @@ controlador.verClientesJsonApp = (req, res) => {
|
||||
//next(err);
|
||||
}
|
||||
//console.log(rows);
|
||||
//var test = {"Items":[{"idt_prdcto":"1","codigo_prdcto":"CODIGOTEST","detalle_prdcto":"ITEM GENERADO","describe_prdcto":"DESCRIPCION DE ITEMS"}]};
|
||||
var client = { Clientes: rows };
|
||||
res.json(client);
|
||||
//res.render('clientesV',{ data:rows });
|
||||
@@ -157,20 +156,20 @@ controlador.app_pedidos_clientes = (req, res) => {
|
||||
|
||||
//CONSULTA CLIENTE CLOUD C.I-RUC => ruta:/busquedaSRI
|
||||
var data_url0 = 'http://www.ecuadorlegalonline.com/modulo/sri/consulta-ruc/ruc.api.php';
|
||||
var data_url1 = "https://xsystem.ddns.net/app/consulta_clientes.php";
|
||||
var data_url1 = "https://xsystem.ddns.net/app/clientes_cloud.php";
|
||||
var data_url2 = "http://sheyla2.dyndns.info/SRI/SRI.php";
|
||||
var data_url3 = "http://192.168.10.100:8000/test_post";
|
||||
var arrayUrl = [
|
||||
"http://www.ecuadorlegalonline.com/modulo/sri/consulta-ruc/ruc.api.php",
|
||||
"https://xsystem.ddns.net/app/consulta_clientes.php",
|
||||
"https://xsystem.ddns.net/api/clientes_cloud.php",
|
||||
"http://sheyla2.dyndns.info/SRI/SRI.php",
|
||||
"http://192.168.10.100:8000/test_post",
|
||||
"solo testing"
|
||||
];
|
||||
controlador.buscarCli_sri = (req, res) => {
|
||||
var idCli = req.query.ruc;
|
||||
var idCli = req.query.ID_CLIENTE;
|
||||
console.log(`Peticion => Consulta RUC: ${idCli}`);
|
||||
let selc = 2;
|
||||
let selc = 1;
|
||||
|
||||
switch (selc) {
|
||||
case 0:
|
||||
@@ -184,11 +183,13 @@ controlador.buscarCli_sri = (req, res) => {
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
axios.post(arrayUrl[selc] + "?ruc=" + idCli)
|
||||
axios({
|
||||
method: 'POST',
|
||||
url: arrayUrl[selc]+"?ID_CLIENTE="+idCli,
|
||||
})
|
||||
.then(function (resp_sri) {
|
||||
console.log(resp_sri.data);
|
||||
var consulta = { "resp_consulta": resp_sri };
|
||||
res.json(consulta);
|
||||
res.json(resp_sri.data);
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
@@ -228,33 +229,54 @@ controlador.api_consultaCliente = (req, res) => {
|
||||
//console.log(req.query.id);
|
||||
console.log(`Peticion => Consulta ID: ${idCli}`);
|
||||
req.getConnection((err, conn) => {
|
||||
conn.query('SELECT client_nombre as nombre,client_razonSocial as nombre_comercial,client_direccion as direccion,IFNULL(client_celular,client_telefono) as telefono,client_email as email FROM clientes WHERE client_rucCed = ?', [idCli], (err, rows) => {
|
||||
conn.query('SELECT client_nombre as nombre,client_razonSocial as nombre_comercial,client_Ciudad as ciudad,client_direccion as direccion,IFNULL(client_celular,client_telefono) as telefono,client_email as email FROM clientes WHERE client_rucCed = ?', [idCli], (err, rows) => {
|
||||
//conn.query('SELECT * FROM clientes WHERE client_rucCed = ?',[idCli],(err,rows)=>{
|
||||
if (rows.length > 0) {
|
||||
console.log("Encontrado en Servidor Local:");
|
||||
res.json(rows);
|
||||
} else {
|
||||
axios.post(arrayUrl[2] + "?ruc=" + idCli)
|
||||
axios.post(arrayUrl[1] + "?ID_CLIENTE=" + idCli)
|
||||
.then(function (resp_sri) {
|
||||
console.log("Encontrado en Servidor SRI:");
|
||||
//console.log(resp_sri.data);
|
||||
var data_toArray = resp_sri.data;
|
||||
let arr = data_toArray.split('***');
|
||||
//console.log(arr);
|
||||
var obj_json = { nombre: arr[1], nombre_comercial: arr[2], direccion: arr[5],telefono:"",email:"" };
|
||||
console.log(obj_json);
|
||||
res.json(obj_json);
|
||||
console.log(resp_sri.data);
|
||||
var resp = resp_sri.data;
|
||||
if(resp.length > 0){
|
||||
var obj_json = {
|
||||
nombre: resp[0].CLI_NOMBRE,
|
||||
nombre_comercial: resp[0].CLI_NOMBRE,
|
||||
direccion: resp[0].CLI_DIRECCION,
|
||||
ciudad:"", telefono:
|
||||
resp[0].CLI_TELEFONOS,
|
||||
email: resp[0].CLI_EMAIL };
|
||||
res.json(obj_json);
|
||||
}else{
|
||||
res.json({"RESP":"DATA NO ENCONTRADA"});
|
||||
//axios.post(arrayUrl[1] + "?ID_CLIENTE=" + idCli).then(function (resp_sri) {});
|
||||
}
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function consulta_clientes(idCli) {
|
||||
|
||||
if(false){
|
||||
axios.post(arrayUrl[1] + "?ID_CLIENTE=" + idCli)
|
||||
.then(function (resp_sri) {
|
||||
console.log("Encontrado en Servidor SRI:");
|
||||
console.log(resp_sri.data);
|
||||
var data_toArray = resp_sri.data;
|
||||
let arr = data_toArray.split('***');
|
||||
//console.log(arr);
|
||||
var obj_json = { nombre: arr[1], nombre_comercial: arr[2], direccion: arr[5], telefono: "", email: "" };
|
||||
console.log(obj_json);
|
||||
res.json(obj_json);
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user