insert ticket update

This commit is contained in:
alexmorenograu 2021-03-15 10:37:07 +01:00
parent 3e5e2487af
commit 904eb5e8b2
2 changed files with 29 additions and 25 deletions

View File

@ -6,7 +6,7 @@ const con = require('./connect')
var x;
function select(collectionFk, callback){
let consSql = `SELECT t.id AS ticket, c.name AS Client, am.name AS Agency, tc.level
let consSql = `SELECT t.id AS Ticket, c.name AS Client, am.name AS Agency, tc.level AS Level
FROM ticketCollection tc
JOIN ticket t ON t.id = tc.ticketFk JOIN client c ON t.clientFk = c.id
JOIN agencyMode am ON am.id = t.agencyModeFk

View File

@ -5,32 +5,36 @@ function insertTicket(consultaSql, shelving){
const info = await config.info
let key = info.data.token
let currentUser = info.data.currentUser;
(async() => {
for(var i=0;i<consultaSql.length;i++){
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,//Matricula + nivel
itemTitle: "Etiqueta Con ticket",
productCode: consultaSql[i].ticketFk, //Ticket
custFeature1: consultaSql[i].nickname, //Client
custFeature2: consultaSql[i].agencyModeFk //Agencia de transporte
}
]
},
responseType: 'json',
headers: {
"Authorization": key
}
})
console.log(body)
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),//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
}
]
},
responseType: 'json',
headers: {
"Authorization": key
}
})
console.log(body)
}
}
})();
})();