2021-03-18 10:38:05 +00:00
|
|
|
function insertTicket(consultaSql, shelving, max) {
|
2021-03-17 14:27:09 +00:00
|
|
|
const config = require('../config');
|
2021-03-17 08:11:55 +00:00
|
|
|
const got = require('got');
|
|
|
|
(async() => {
|
2021-03-18 10:38:05 +00:00
|
|
|
const info = await config.info;
|
|
|
|
let key = info.data.token;
|
2021-03-17 08:11:55 +00:00
|
|
|
let currentUser = info.data.currentUser;
|
|
|
|
|
|
|
|
(async() => {
|
2021-03-18 10:38:05 +00:00
|
|
|
for (let i = 0; i < consultaSql.length; i++) {
|
|
|
|
// for(var j=0;j<max;j++){
|
|
|
|
for (let j = 0; j < consultaSql[i].Level.toString().length; j++) {
|
2021-03-18 10:51:28 +00:00
|
|
|
const {body} = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', { // eslint-disable-line
|
2021-03-18 10:38:05 +00:00
|
|
|
json: {
|
|
|
|
agencyId: currentUser.agencyId,
|
|
|
|
merchantId: currentUser.merchantId,
|
|
|
|
storeId: currentUser.storeId,
|
|
|
|
unitName: currentUser.unitName,
|
|
|
|
itemList: [
|
|
|
|
{
|
|
|
|
attrCategory: 'verdnatura',
|
|
|
|
attrName: 'conTicket',
|
|
|
|
barCode: shelving + consultaSql[i].Level.toString().charAt(j), // Matricula + nivel
|
|
|
|
itemTitle: 'Etiqueta Con ticket',
|
|
|
|
productCode: consultaSql[i].Ticket, // Ticket
|
|
|
|
custFeature1: consultaSql[i].Client, // Client
|
|
|
|
custFeature2: consultaSql[i].Agency // Agencia de transporte
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
responseType: 'json',
|
|
|
|
headers: {
|
|
|
|
'Authorization': key
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-03-17 08:11:55 +00:00
|
|
|
}
|
|
|
|
})();
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.insertTicket = insertTicket;
|