2021-03-12 15:57:49 +00:00
|
|
|
function insertTicket(consultaSql, shelving){
|
2021-03-11 15:38:22 +00:00
|
|
|
const config = require('./config');
|
|
|
|
const got = require('got');
|
|
|
|
(async() => {
|
|
|
|
const info = await config.info
|
|
|
|
let key = info.data.token
|
|
|
|
let currentUser = info.data.currentUser;
|
2021-03-15 09:37:07 +00:00
|
|
|
|
2021-03-11 15:38:22 +00:00
|
|
|
(async() => {
|
2021-03-12 15:57:49 +00:00
|
|
|
for(var i=0;i<consultaSql.length;i++){
|
2021-03-15 09:37:07 +00:00
|
|
|
for(var j=0;j<consultaSql[i].Level.toString().length;j++){
|
|
|
|
const { body } = await got.post('http://app.etiquetaselectronicas.com:9999/item/batchImportItem', {
|
|
|
|
json: {
|
|
|
|
agencyId: currentUser.agencyId,
|
|
|
|
merchantId: currentUser.merchantId,
|
|
|
|
storeId: currentUser.storeId,
|
|
|
|
unitName: currentUser.unitName,
|
|
|
|
itemList: [
|
|
|
|
{
|
|
|
|
attrCategory: "verdnatura",
|
|
|
|
attrName: "conTicket",
|
2021-03-15 10:00:05 +00:00
|
|
|
barCode: shelving + consultaSql[i].Level.toString().charAt(j),//Matricula + nivel
|
2021-03-15 09:37:07 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log(body)
|
|
|
|
}
|
2021-03-11 15:38:22 +00:00
|
|
|
}
|
|
|
|
})();
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.insertTicket = insertTicket;
|