increase speed

This commit is contained in:
Marko
2024-03-20 17:32:52 +01:00
parent 060b481319
commit df4d62bfdf
15 changed files with 1907 additions and 777 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Helper;
use App\Entity\Order;
use App\Repository\OrderRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
@@ -21,7 +22,7 @@ class Hiltes
protected $hiltesApiUrl;
public function __construct(private OrderRepository $orderRepository)
public function __construct(private OrderRepository $orderRepository, private LoggerInterface $logger)
{
$this->fsObject = new Filesystem();
$this->current_dir_path = getcwd();
@@ -31,19 +32,6 @@ class Hiltes
$this->hiltesPass = $_ENV['HILTES_API_PASS'];
}
// public function import()
// {
//
// $finder = new Finder();
// $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
//
// foreach ($finder as $file) {
// $contents = $file->getContents();
//
// //var_dump($contents);
// }
//
// }
/**
* @param string $data
@@ -100,7 +88,12 @@ class Hiltes
#dump($tA);
#*** Umkonvertieren des Datumstings *****************
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', $tA['orderdate'] ? strtotime($tA['orderdate']) : time());
if (!empty($tA['salesdate'])) {
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', $tA['salesdate'] ? strtotime($tA['salesdate']) : time());
} else {
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', time());
}
#****
$arr = array(
'SalesDate' => $tA['orderdate'],
@@ -112,9 +105,6 @@ class Hiltes
);
#*** Items ***************
if (!empty($tA['positions']) && is_array($tA['positions'])) {
# Noch nötig
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array();
foreach ($tA['positions'] as $v) {
if ($v['type'] == 'versandposition' || $v['sku'] == '') {
@@ -163,7 +153,7 @@ class Hiltes
}
}
#*** Kundne *******************************
#*** Kunde *******************************
$arr['CustomerList'][] = array(
"CustomerNumber" => $tA['kundenummer'], # Fake Daten
"Surname" => $tA['name'],#"string",
@@ -232,13 +222,19 @@ class Hiltes
);
$r = $this->sendToHiltes($url, $param);
dump($r);
if ($r === false) {
$this->logger->error('Login Error ' . $r . __LINE__);
return false;
}
$t = json_decode($r, true);
if ($t['Success']) {
$this->hiltesApiHash = $t['Data'];
return true;
} else {
dump($r);
dump('Login Error ' . __LINE__);
$this->logger->error('Login Error ' . __LINE__);
return false;
}
}
@@ -378,6 +374,13 @@ class Hiltes
//dump($param);
$r = $this->sendToHiltes($url, $param, true);
dump($r);
if ($r === false) {
dump('Send Order Error ' . __LINE__);
return false;
}
$t = json_decode($r, true);
if ($t['Success']) {
return true;