refs #4734 feat: añadido método putExpedicionInternacional de viaexpress
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
983081a08e
commit
0cc5781f3f
|
@ -0,0 +1,135 @@
|
|||
const axios = require('axios');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('putExpedicionInternacional', {
|
||||
description: 'Returns the lastest campaigns',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'expeditionFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}],
|
||||
returns: {
|
||||
type: ['object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/putExpedicionInternacional`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.putExpedicionInternacional = async(expeditionFk, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [data] = await Self.rawSql(`
|
||||
SELECT urlAccess,
|
||||
clientViaexpress,
|
||||
userViaexpress,
|
||||
passwordViaexpress,
|
||||
defaultWeight,
|
||||
DATE_FORMAT(t.shipped, '%Y-%m-%d') shipped,
|
||||
deliveryType,
|
||||
cv.socialName senderName,
|
||||
av.street senderStreet,
|
||||
av.postalCode senderPostalCode,
|
||||
av.city senderCity,
|
||||
pv.name senderProvince,
|
||||
IFNULL(av.mobile, IFNULL(av.phone, IFNULL(cv.mobile, cv.phone))) senderPhone,
|
||||
SUBSTRING_INDEX(cv.email, ',', 1) senderEmail,
|
||||
a.nickname receiverName,
|
||||
a.street receiverStreet,
|
||||
a.postalCode receiverPostalCode,
|
||||
a.city receiverCity,
|
||||
p.name receiverProvince,
|
||||
IFNULL(a.mobile, IFNULL(a.phone, IFNULL(c.mobile, c.phone))) receiverPhone,
|
||||
SUBSTRING_INDEX(c.email, ',', 1) receiverEmail,
|
||||
c2.code receiverCountry
|
||||
FROM vn.viaexpressConfig
|
||||
JOIN vn.expedition e ON e.id = ?
|
||||
JOIN vn.ticket t ON t.id = e.ticketFk
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
JOIN vn.company co ON co.id = t.companyFk
|
||||
JOIN vn.client cv ON cv.id = co.clientFk
|
||||
JOIN vn.address av ON av.id = cv.defaultAddressFk
|
||||
JOIN vn.province pv ON pv.id = av.provinceFk
|
||||
JOIN vn.country c2 ON c2.id = p.countryFk`, [expeditionFk], myOptions);
|
||||
|
||||
const xmlData = `<?xml version="1.0" encoding="utf-8"?>
|
||||
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
|
||||
<soap12:Body>
|
||||
<PutExpedicionInternacional xmlns="http://82.223.6.71:82">
|
||||
<ObjetoEnvio>
|
||||
<Peso>${data.defaultWeight}</Peso>
|
||||
<Bultos>1</Bultos>
|
||||
<Reembolso>0</Reembolso>
|
||||
<Fecha>${data.shipped}</Fecha>
|
||||
<ConRetorno>0</ConRetorno>
|
||||
<Tipo>${data.deliveryType}</Tipo>
|
||||
<Debidos>0</Debidos>
|
||||
<Asegurado>0</Asegurado>
|
||||
<Imprimir>0</Imprimir>
|
||||
<ConDevolucionAlbaran>0</ConDevolucionAlbaran>
|
||||
<Intradia>0</Intradia>
|
||||
<Observaciones></Observaciones>
|
||||
<AlbaranRemitente></AlbaranRemitente>
|
||||
<Modo>0</Modo>
|
||||
<TextoAgencia></TextoAgencia>
|
||||
<Terminal></Terminal>
|
||||
<ObjetoRemitente>
|
||||
<RazonSocial>${data.senderName}</RazonSocial>
|
||||
<Domicilio>${data.senderStreet}</Domicilio>
|
||||
<Cpostal>${data.senderPostalCode}</Cpostal>
|
||||
<Poblacion>${data.senderCity}</Poblacion>
|
||||
<Provincia>${data.senderProvince}</Provincia>
|
||||
<Contacto></Contacto>
|
||||
<Telefono>${data.senderPhone}</Telefono>
|
||||
<Email>${data.senderEmail}</Email>
|
||||
</ObjetoRemitente>
|
||||
<ObjetoDestinatario>
|
||||
<RazonSocial>${data.receiverName}</RazonSocial>
|
||||
<Domicilio>${data.receiverStreet}</Domicilio>
|
||||
<Cpostal>${data.receiverPostalCode}</Cpostal>
|
||||
<Poblacion>${data.receiverCity}</Poblacion>
|
||||
<Municipio></Municipio>
|
||||
<Provincia>${data.receiverProvince}</Provincia>
|
||||
<Contacto></Contacto>
|
||||
<Telefono>${data.receiverPhone}</Telefono>
|
||||
<Email>${data.receiverEmail}</Email>
|
||||
<Pais>${data.receiverCountry}</Pais>
|
||||
</ObjetoDestinatario>
|
||||
<ObjetoLogin>
|
||||
<IdCliente>${data.clientViaexpress}</IdCliente>
|
||||
<Usuario>${data.userViaexpress}</Usuario>
|
||||
<Password>${data.passwordViaexpress}</Password>
|
||||
</ObjetoLogin>
|
||||
</ObjetoEnvio>
|
||||
</PutExpedicionInternacional>
|
||||
</soap12:Body>
|
||||
</soap12:Envelope>`;
|
||||
|
||||
const url = 'http://82.223.6.71:82/ServicioVxClientes.asmx';
|
||||
try {
|
||||
const response = await axios.post(url, xmlData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
}
|
||||
});
|
||||
|
||||
const startTag = '<ReferenciaVx>';
|
||||
const endTag = '</ReferenciaVx>';
|
||||
const startIndex = response.data.indexOf(startTag) + startTag.length;
|
||||
const endIndex = response.data.indexOf(endTag);
|
||||
const referenciaVx = response.data.substring(startIndex, endIndex);
|
||||
|
||||
return referenciaVx;
|
||||
} catch (error) {
|
||||
throw Error(error.response.data);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -139,6 +139,9 @@
|
|||
},
|
||||
"PrintConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ViaexpressConfig": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/viaexpress-config/putExpedicionInternacional')(Self);
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"name": "ViaexpressConfig",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "viaexpressConfig"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"urlAccess": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"clientViaexpress": {
|
||||
"type": "date"
|
||||
},
|
||||
"userViaexpress": {
|
||||
"type": "number"
|
||||
},
|
||||
"passwordViaexpress": {
|
||||
"type": "number"
|
||||
},
|
||||
"defaultWeight": {
|
||||
"type": "number"
|
||||
},
|
||||
"deliveryType": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||
VALUES
|
||||
('ViaexpressConfig', 'putExpedicionInternacional', 'WRITE', 'ALLOW', 'ROLE', 'employee');
|
|
@ -0,0 +1,13 @@
|
|||
CREATE TABLE `vn`.`viaexpressConfig` (
|
||||
id int auto_increment NOT NULL,
|
||||
urlAccess varchar(100) NOT NULL,
|
||||
clientViaexpress varchar(100) NOT NULL,
|
||||
userViaexpress varchar(100) NOT NULL,
|
||||
passwordViaexpress varchar(100) NOT NULL,
|
||||
defaultWeight decimal(10,2) NOT NULL,
|
||||
deliveryType varchar(5) NOT NULL,
|
||||
CONSTRAINT viaexpressConfig_PK PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb3
|
||||
COLLATE=utf8mb3_unicode_ci;
|
|
@ -566,13 +566,13 @@ INSERT INTO `vn`.`supplierAccount`(`id`, `supplierFk`, `iban`, `bankEntityFk`)
|
|||
VALUES
|
||||
(241, 442, 'ES111122333344111122221111', 128);
|
||||
|
||||
INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary`)
|
||||
INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, `companyCode`, `sage200Company`, `expired`, `companyGroupFk`, `phytosanitary` , `clientFk`)
|
||||
VALUES
|
||||
(69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL),
|
||||
(442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport'),
|
||||
(567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport'),
|
||||
(791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL),
|
||||
(1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport');
|
||||
(69 , 'CCs', NULL, 30, NULL, 0, NULL, 1, NULL , NULL),
|
||||
(442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport' , 1101),
|
||||
(567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport' , NULL),
|
||||
(791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL , NULL),
|
||||
(1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport' , NULL);
|
||||
|
||||
INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`)
|
||||
VALUES
|
||||
|
|
Loading…
Reference in New Issue