some fixes

This commit is contained in:
2025-07-10 08:04:15 +00:00
parent 34fe281e2c
commit e37b4dd963
14 changed files with 121 additions and 93 deletions

View File

@@ -6,7 +6,6 @@
// FVKOR Polska - 17314
// FVKOR domyślna - 7689
/*
DELETE p
FROM ecommerce_invoices_products p
@@ -21,7 +20,7 @@ function importFV($seriesId)
$IMPORT_START_ID = 1531694;
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY id DESC LIMIT 1");
$dbRes = $db->query("SELECT id FROM ecommerce_invoices WHERE origin = 'allegro' AND type = 'normal' AND series_id = '$seriesId' ORDER BY CAST(id AS UNSIGNED) DESC LIMIT 1");
$lastImportId = $db->fetchByAssoc($dbRes)['id'];
if ($lastImportId == null) {
$lastImportId = $IMPORT_START_ID;
@@ -30,6 +29,7 @@ function importFV($seriesId)
}
$invoicesRes = loadInvoices($baselinker_config['token'], $lastImportId, $seriesId);
$invoices = $invoicesRes->invoices;
usort($invoices, function ($a, $b) {
@@ -205,7 +205,11 @@ function getInvoiceSource($token, $orderId)
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiParams));
$res = json_decode(curl_exec($curl));
return $res->orders[0]->order_source;
if ($res->orders[0]->order_source != '') {
return $res->orders[0]->order_source;
} else {
return 'allegro'; //default
}
}
function getCorrectTotals($invoice)
{