refs #4734 refactor: use loopback instead of
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
219ad75172
commit
303be74382
|
@ -26,42 +26,6 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [data] = await Self.rawSql(`
|
||||
SELECT
|
||||
url,
|
||||
clientViaexpress,
|
||||
userViaexpress,
|
||||
passwordViaexpress,
|
||||
defaultWeight,
|
||||
deliveryType,
|
||||
DATE_FORMAT(t.shipped, '%Y-%m-%d') shipped,
|
||||
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 expedition = await models.Expedition.findOne({
|
||||
fields: ['id', 'ticketFk'],
|
||||
where: {id: expeditionFk},
|
||||
|
@ -141,20 +105,28 @@ module.exports = Self => {
|
|||
}
|
||||
]
|
||||
}, myOptions);
|
||||
console.log(data);
|
||||
console.log(expedition);
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
fields: ['url', 'clientViaexpress', 'userViaexpress', 'passwordViaexpress', 'defaultWeight', 'deliveryType']
|
||||
}, myOptions);
|
||||
|
||||
const shipped = expedition.ticket().shipped;
|
||||
const year = shipped.getFullYear();
|
||||
const month = shipped.getMonth() + 1;
|
||||
const day = shipped.getDate();
|
||||
const date = `${year}-${month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`;
|
||||
|
||||
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>
|
||||
<Peso>${viaexpressConfig.defaultWeight}</Peso>
|
||||
<Bultos>1</Bultos>
|
||||
<Reembolso>0</Reembolso>
|
||||
<Fecha>${data.shipped}</Fecha>
|
||||
<Fecha>${date}</Fecha>
|
||||
<ConRetorno>0</ConRetorno>
|
||||
<Tipo>${data.deliveryType}</Tipo>
|
||||
<Tipo>${viaexpressConfig.deliveryType}</Tipo>
|
||||
<Debidos>0</Debidos>
|
||||
<Asegurado>0</Asegurado>
|
||||
<Imprimir>0</Imprimir>
|
||||
|
@ -166,31 +138,31 @@ module.exports = Self => {
|
|||
<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>
|
||||
<RazonSocial>${expedition.ticket().company().client().socialName}</RazonSocial>
|
||||
<Domicilio>${expedition.ticket().company().client().defaultAddress().street}</Domicilio>
|
||||
<Cpostal>${expedition.ticket().company().client().defaultAddress().postalCode}</Cpostal>
|
||||
<Poblacion>${expedition.ticket().company().client().defaultAddress().city}</Poblacion>
|
||||
<Provincia>${expedition.ticket().company().client().defaultAddress().province().name}</Provincia>
|
||||
<Contacto></Contacto>
|
||||
<Telefono>${data.senderPhone}</Telefono>
|
||||
<Email>${data.senderEmail}</Email>
|
||||
<Telefono>${expedition.ticket().company().client().defaultAddress().mobile || expedition.ticket().company().client().defaultAddress().phone || expedition.ticket().company().client().mobile || expedition.ticket().company().client().phone}</Telefono>
|
||||
<Email>${expedition.ticket().company().client().email}</Email>
|
||||
</ObjetoRemitente>
|
||||
<ObjetoDestinatario>
|
||||
<RazonSocial>${data.receiverName}</RazonSocial>
|
||||
<Domicilio>${data.receiverStreet}</Domicilio>
|
||||
<Cpostal>${data.receiverPostalCode}</Cpostal>
|
||||
<Poblacion>${data.receiverCity}</Poblacion>
|
||||
<RazonSocial>${expedition.ticket().address().nickname}</RazonSocial>
|
||||
<Domicilio>${expedition.ticket().address().street}</Domicilio>
|
||||
<Cpostal>${expedition.ticket().address().postalCode}</Cpostal>
|
||||
<Poblacion>${expedition.ticket().address().city}</Poblacion>
|
||||
<Municipio></Municipio>
|
||||
<Provincia>${data.receiverProvince}</Provincia>
|
||||
<Provincia>${expedition.ticket().address().province().name}</Provincia>
|
||||
<Contacto></Contacto>
|
||||
<Telefono>${data.receiverPhone}</Telefono>
|
||||
<Email>${data.receiverEmail}</Email>
|
||||
<Pais>${data.receiverCountry}</Pais>
|
||||
<Telefono>${expedition.ticket().address().mobile || expedition.ticket().address().phone || expedition.ticket().client().mobile || expedition.ticket().client().phone}</Telefono>
|
||||
<Email>${expedition.ticket().client().email}</Email>
|
||||
<Pais>${expedition.ticket().address().province().country().code}</Pais>
|
||||
</ObjetoDestinatario>
|
||||
<ObjetoLogin>
|
||||
<IdCliente>${data.clientViaexpress}</IdCliente>
|
||||
<Usuario>${data.userViaexpress}</Usuario>
|
||||
<Password>${data.passwordViaexpress}</Password>
|
||||
<IdCliente>${viaexpressConfig.clientViaexpress}</IdCliente>
|
||||
<Usuario>${viaexpressConfig.userViaexpress}</Usuario>
|
||||
<Password>${viaexpressConfig.passwordViaexpress}</Password>
|
||||
</ObjetoLogin>
|
||||
</ObjetoEnvio>
|
||||
</PutExpedicionInternacional>
|
||||
|
@ -198,7 +170,7 @@ module.exports = Self => {
|
|||
</soap12:Envelope>`;
|
||||
|
||||
try {
|
||||
const response = await axios.post(`${data.url}ServicioVxClientes.asmx`, xmlData, {
|
||||
const response = await axios.post(`${viaexpressConfig.url}ServicioVxClientes.asmx`, xmlData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
}
|
||||
|
|
|
@ -16,19 +16,19 @@
|
|||
"required": true
|
||||
},
|
||||
"clientViaexpress": {
|
||||
"type": "date"
|
||||
"type": "string"
|
||||
},
|
||||
"userViaexpress": {
|
||||
"type": "number"
|
||||
"type": "string"
|
||||
},
|
||||
"passwordViaexpress": {
|
||||
"type": "number"
|
||||
"type": "string"
|
||||
},
|
||||
"defaultWeight": {
|
||||
"type": "number"
|
||||
},
|
||||
"deliveryType": {
|
||||
"type": "number"
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue