43 lines
1.8 KiB
JavaScript
43 lines
1.8 KiB
JavaScript
function insertTicket(consultaSql, shelving){
|
|
const config = require('./config');
|
|
const got = require('got');
|
|
(async() => {
|
|
const info = await config.info
|
|
let key = info.data.token
|
|
let currentUser = info.data.currentUser;
|
|
|
|
(async() => {
|
|
for(var i=0;i<consultaSql.length;i++){
|
|
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",
|
|
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
|
|
}
|
|
})
|
|
console.log(body)
|
|
}
|
|
}
|
|
})();
|
|
})();
|
|
}
|
|
|
|
exports.insertTicket = insertTicket;
|