60 lines
2.2 KiB
JavaScript
60 lines
2.2 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router(); // eslint-disable-line
|
|
const select = require('../db/selectTicket');
|
|
|
|
router.get('/:ticket', async(req, res) => {
|
|
const ticket = req.params.ticket;
|
|
console.log(ticket);
|
|
searchTicket(ticket);
|
|
});
|
|
|
|
module.exports = router;
|
|
|
|
function searchTicket(ticket) {// parametro ticketFk
|
|
select.select(ticket, function(err, data) {
|
|
console.log(data);
|
|
insertFlash(data);
|
|
});
|
|
}
|
|
|
|
function insertFlash(consultaSql) {
|
|
console.log('CONSULTASQL_TAMAÑO:', consultaSql.length);
|
|
const dataLogIn = require('../server');
|
|
const got = require('got');
|
|
(async() => {
|
|
const info = await dataLogIn.dataLogIn;
|
|
let key = info.data.token;
|
|
let currentUser = info.data.currentUser;
|
|
|
|
(async() => {
|
|
for (let i = 0; i < consultaSql.length; i++) {
|
|
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line
|
|
json: {
|
|
agencyId: currentUser.agencyId,
|
|
merchantId: currentUser.merchantId,
|
|
storeId: currentUser.storeId,
|
|
unitName: currentUser.unitName,
|
|
itemList: [
|
|
{
|
|
attrCategory: 'verdnatura',
|
|
attrName: 'conTicket',
|
|
barCode: consultaSql[i].Shelving + consultaSql[i].Level, // Matricula + nivel
|
|
itemTitle: 'Etiqueta Con ticket',
|
|
productCode: consultaSql[i].Ticket, // Ticket
|
|
custFeature1: consultaSql[i].Client, // Client
|
|
custFeature2: consultaSql[i].Agency, // Agencia de transporte
|
|
custFeature3: 1 // Valor luz led
|
|
}
|
|
]
|
|
},
|
|
responseType: 'json',
|
|
headers: {
|
|
'Authorization': key
|
|
}
|
|
});
|
|
console.log(body);
|
|
}
|
|
})();
|
|
})();
|
|
}
|