add Logging
This commit is contained in:
parent
ac955e5988
commit
966905a3bf
@ -16,7 +16,7 @@ when@prod:
|
|||||||
handlers:
|
handlers:
|
||||||
sentry:
|
sentry:
|
||||||
type: sentry
|
type: sentry
|
||||||
level: !php/const Monolog\Logger::ERROR
|
level: !php/const Monolog\Logger::INFO
|
||||||
hub_id: Sentry\State\HubInterface
|
hub_id: Sentry\State\HubInterface
|
||||||
|
|
||||||
# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders
|
# Uncomment these lines to register a log message processor that resolves PSR-3 placeholders
|
||||||
|
@ -37,7 +37,7 @@ class Hiltes
|
|||||||
* @param string $data
|
* @param string $data
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function export(string $data)
|
public function export(string $data) : void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$new_file_path = $this->current_dir_path . "/hiltes/c2h/" . $this->createFileName();
|
$new_file_path = $this->current_dir_path . "/hiltes/c2h/" . $this->createFileName();
|
||||||
@ -196,9 +196,6 @@ class Hiltes
|
|||||||
$param = array(
|
$param = array(
|
||||||
'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
|
'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
|
||||||
'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
|
'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
|
||||||
# 'parse_mode' => 'html',
|
|
||||||
# 'disable_notification' => $disable_notification,
|
|
||||||
# 'text' => $message_text
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = $this->sendToHiltes($url, $param);
|
$r = $this->sendToHiltes($url, $param);
|
||||||
@ -238,6 +235,10 @@ class Hiltes
|
|||||||
# Setup request to send json via POST.
|
# Setup request to send json via POST.
|
||||||
$payload = json_encode($param);
|
$payload = json_encode($param);
|
||||||
|
|
||||||
|
if ($auth) {
|
||||||
|
$this->logger->info('Send Order ' . $url . ' ' . $payload);
|
||||||
|
}
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization));
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization));
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||||
# Return response instead of printing.
|
# Return response instead of printing.
|
||||||
@ -254,7 +255,7 @@ class Hiltes
|
|||||||
* @param mixed $data The data to be converted to JSON.
|
* @param mixed $data The data to be converted to JSON.
|
||||||
* @return array The JSON object.
|
* @return array The JSON object.
|
||||||
*/
|
*/
|
||||||
public function createJson($data)
|
public function createJson($data) : array
|
||||||
{
|
{
|
||||||
$arr = array(
|
$arr = array(
|
||||||
'File' => array(
|
'File' => array(
|
||||||
@ -359,9 +360,17 @@ class Hiltes
|
|||||||
}
|
}
|
||||||
|
|
||||||
$t = json_decode($r, true);
|
$t = json_decode($r, true);
|
||||||
|
$order = $this->orderRepository->findOneBy(array('orderId' => $data['SaleList'][0]['OrderNumber']));
|
||||||
|
|
||||||
|
if (!$order) {
|
||||||
|
$this->logger->error('Order not found ' . $data['SaleList'][0]['OrderNumber']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($t['Success']) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$order = $this->orderRepository->findOneBy(array('orderId' => $data['SaleList'][0]['OrderNumber']));
|
//Status 3 für erfolgreich exportiert
|
||||||
$order->setStatus(3);
|
$order->setStatus(3);
|
||||||
$order->setHiltes($t);
|
$order->setHiltes($t);
|
||||||
|
|
||||||
@ -371,9 +380,20 @@ class Hiltes
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($t['Success']) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
//Status 4 für Fehler
|
||||||
|
$order->setStatus(4);
|
||||||
|
$order->setHiltes($t);
|
||||||
|
|
||||||
|
$this->orderRepository->update($order, true);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->logger->error('Send Order Error ' . $exception->getMessage() . __LINE__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$this->logger->error('Send Order Error ' . var_export($t['errors'], 1) . __LINE__);
|
$this->logger->error('Send Order Error ' . var_export($t['errors'], 1) . __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user