This commit is contained in:
parent
8554cf714d
commit
dd8faaea95
@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="LaravelPintOptionsConfiguration">
|
||||||
|
<option name="ruleset" value="laravel" />
|
||||||
|
</component>
|
||||||
<component name="MessDetectorOptionsConfiguration">
|
<component name="MessDetectorOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
@ -9,6 +12,9 @@
|
|||||||
<component name="PHPCodeSnifferOptionsConfiguration">
|
<component name="PHPCodeSnifferOptionsConfiguration">
|
||||||
<option name="transferred" value="true" />
|
<option name="transferred" value="true" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="PhpExternalFormatter">
|
||||||
|
<option name="externalFormatter" value="PHP_CBF" />
|
||||||
|
</component>
|
||||||
<component name="PhpIncludePathManager">
|
<component name="PhpIncludePathManager">
|
||||||
<include_path>
|
<include_path>
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
|
<path value="$PROJECT_DIR$/vendor/symfony/serializer" />
|
||||||
|
39
src/EventSubscriber/ExportHiltesSubscriber.php
Normal file
39
src/EventSubscriber/ExportHiltesSubscriber.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\EventSubscriber;
|
||||||
|
|
||||||
|
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
||||||
|
use App\Entity\Order;
|
||||||
|
use App\Helper\Hiltes;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
||||||
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
|
class ExportHiltesSubscriber implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
public function __construct(private Hiltes $hiltes)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onPatchOrder(ViewEvent $event): void
|
||||||
|
{
|
||||||
|
$method = $event->getRequest()->getMethod();
|
||||||
|
$order = $event->getControllerResult();
|
||||||
|
|
||||||
|
if (!$order instanceof Order || Request::METHOD_PATCH !== $method) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order->getStatus() == 2) {
|
||||||
|
$this->hiltes->createRequest($order);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
KernelEvents::VIEW => ['onPatchOrder', EventPriorities::POST_WRITE]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,8 @@ namespace App\EventSubscriber;
|
|||||||
|
|
||||||
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
||||||
use App\Entity\Order;
|
use App\Entity\Order;
|
||||||
use App\Helper\Hiltes;
|
|
||||||
use App\Helper\Slack;
|
use App\Helper\Slack;
|
||||||
use Maknz\Slack\Client;
|
use Maknz\Slack\Client;
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
use Symfony\Component\HttpKernel\Event\ViewEvent;
|
||||||
@ -19,17 +17,11 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
/**
|
/**
|
||||||
* @var Slack
|
* @var Slack
|
||||||
*/
|
*/
|
||||||
public $logger;
|
|
||||||
|
|
||||||
private $slackWebhookUrl;
|
private $slackWebhookUrl;
|
||||||
|
|
||||||
private $hiltes;
|
public function __construct(string $slackWebhookUrl)
|
||||||
|
|
||||||
public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
|
|
||||||
{
|
{
|
||||||
$this->slackWebhookUrl = $slackWebhookUrl;
|
$this->slackWebhookUrl = $slackWebhookUrl;
|
||||||
$this->logger = $logger;
|
|
||||||
$this->hiltes = $hiltes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents(): array
|
public static function getSubscribedEvents(): array
|
||||||
@ -75,11 +67,6 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
|||||||
if ($order->getStatus() == 1) {
|
if ($order->getStatus() == 1) {
|
||||||
$slack->from('CDS-Notify')
|
$slack->from('CDS-Notify')
|
||||||
->send($msg);
|
->send($msg);
|
||||||
} elseif ($order->getStatus() == 2) {
|
|
||||||
//Send to Hiltes
|
|
||||||
$this->hiltes->createRequest($order);
|
|
||||||
} else {
|
|
||||||
$this->logger->error('Status ist nicht 1 oder 2');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,7 @@ class Hiltes
|
|||||||
foreach ($finder as $file) {
|
foreach ($finder as $file) {
|
||||||
$contents = $file->getContents();
|
$contents = $file->getContents();
|
||||||
|
|
||||||
var_dump($contents);
|
//var_dump($contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -77,37 +77,27 @@ class Hiltes
|
|||||||
return 'WU' . $date . $number . '.' . $filial;
|
return 'WU' . $date . $number . '.' . $filial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $orderData
|
||||||
|
* @return bool|void
|
||||||
|
*/
|
||||||
public function createRequest($orderData)
|
public function createRequest($orderData)
|
||||||
{
|
{
|
||||||
|
|
||||||
dump($orderData);
|
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$this->loginToHiltes('', '');
|
$this->loginToHiltes('', '');
|
||||||
|
|
||||||
|
|
||||||
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
|
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
|
||||||
|
|
||||||
|
|
||||||
dump($order);
|
|
||||||
/**
|
/**
|
||||||
* @var Order
|
* @var Order
|
||||||
*/
|
*/
|
||||||
if ($order) {
|
if ($order) {
|
||||||
|
|
||||||
|
|
||||||
//foreach ($orders as $order) {
|
//foreach ($orders as $order) {
|
||||||
// if ($order->getStatus() > 0) continue;
|
if ($order->getStatus() != 2) return false;
|
||||||
$tA = $order->getData();#json_decode($order->getData());
|
$tA = $order->getData()[0];#json_decode($order->getData());
|
||||||
#$tA['orderdate'] = "2023-08-30T12:05:24.000Z";
|
|
||||||
|
#dump($tA);
|
||||||
|
|
||||||
dump($tA);
|
|
||||||
#dd($order->getData());
|
|
||||||
#dd(array(
|
|
||||||
# 'orderdate'=> $tA['orderdate'],
|
|
||||||
# 'time'=> strtotime($tA['orderdate']),
|
|
||||||
# 'gmdate '=> gmdate ('d-m-Y\TH:i:s.v\Z',strtotime($tA['orderdate'])),
|
|
||||||
#));
|
|
||||||
#*** Umkonvertieren des Datumstings *****************
|
#*** Umkonvertieren des Datumstings *****************
|
||||||
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', $tA['orderdate'] ? strtotime($tA['orderdate']) : time());
|
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', $tA['orderdate'] ? strtotime($tA['orderdate']) : time());
|
||||||
#****
|
#****
|
||||||
@ -120,12 +110,16 @@ class Hiltes
|
|||||||
'CustomerList' => array(),
|
'CustomerList' => array(),
|
||||||
);
|
);
|
||||||
#*** Items ***************
|
#*** Items ***************
|
||||||
if (!empty($tA['data']) && is_array($tA['data'])) {
|
if (!empty($tA['positions']) && is_array($tA['positions'])) {
|
||||||
# Noch nötig
|
# Noch nötig
|
||||||
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
|
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
|
||||||
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
|
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
|
||||||
$tSalNr = array();
|
$tSalNr = array();
|
||||||
foreach ($tA['data'] as $v) {
|
foreach ($tA['positions'] as $v) {
|
||||||
|
if ($v['type'] == 'versandposition') {
|
||||||
|
$SalesNumber = '000001';
|
||||||
|
$SalesGoodsGroupNumber = 9350;
|
||||||
|
} else {
|
||||||
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
|
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
|
||||||
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) {
|
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) {
|
||||||
$SalesNumber = $tP[1];
|
$SalesNumber = $tP[1];
|
||||||
@ -136,22 +130,26 @@ class Hiltes
|
|||||||
} else {
|
} else {
|
||||||
$tSalNr[$SalesNumber] = 0;
|
$tSalNr[$SalesNumber] = 0;
|
||||||
}
|
}
|
||||||
|
$SalesGoodsGroupNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#dump($SalesNumber);
|
#dump($SalesNumber);
|
||||||
#********
|
#********
|
||||||
$v['CalculatedSellingPrice'] = 100.00;
|
$v['CalculatedSellingPrice'] = round(str_replace(',', '.', $v['price']), 2);
|
||||||
$v['AchievedSalesPrice'] = 90.00;
|
$v['AchievedSalesPrice'] = round(str_replace(',', '.', $v['CalculatedSellingPrice']), 2);
|
||||||
|
|
||||||
$arr['SaleList'][] = array(
|
$arr['SaleList'][] = array(
|
||||||
"SalesLabel" => 'Ean',#$v['sku'],#X
|
"SalesLabel" => 'Ean',#$v['sku'],#X
|
||||||
"SalesLabelNumber" => $SalesNumber,#X
|
"SalesLabelNumber" => $SalesNumber,#X
|
||||||
"SalesGoodsGroupNumber" => 0,
|
"SalesGoodsGroupNumber" => $SalesGoodsGroupNumber,
|
||||||
"SizeDescription" => '',#"string",
|
"SizeDescription" => '',#"string",
|
||||||
"CustomerNumber" => 0,
|
"CustomerNumber" => $tA['kundenummer'],
|
||||||
"TypeOfEstate" => 0,
|
"TypeOfEstate" => 0,
|
||||||
"Amount" => $v['menge'],#X
|
"Amount" => $v['menge'],#X
|
||||||
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'], #X Kalkulierter Verkaufspreis
|
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'], #X Kalkulierter Verkaufspreis
|
||||||
"AchievedSalesPrice" => $v['AchievedSalesPrice'], #X Erzielter Verkaufspreis
|
"AchievedSalesPrice" => $v['AchievedSalesPrice'], #X Erzielter Verkaufspreis
|
||||||
"TransactionType" => "Sale", #X Die Vorgangsart Sale=Verkauf Exchange=Umtausch / Storno
|
"TransactionType" => "Sale", #X Die Vorgangsart Sale=Verkauf Exchange=Umtausch / Storno
|
||||||
"ReceiptNumber" => 0, #Die Belegnummer
|
"ReceiptNumber" => $tA['externOrderId'], #Die Belegnummer
|
||||||
"DateOfSale" => $tA['orderdate'],#X das Verkaufsdatum mit Verkaufszeit
|
"DateOfSale" => $tA['orderdate'],#X das Verkaufsdatum mit Verkaufszeit
|
||||||
"PaymentMethod" => 'Invoice',#X "CreditCard",
|
"PaymentMethod" => 'Invoice',#X "CreditCard",
|
||||||
"Currency" => 'EUR',#X "string",
|
"Currency" => 'EUR',#X "string",
|
||||||
@ -163,13 +161,13 @@ class Hiltes
|
|||||||
}
|
}
|
||||||
#*** Kundne *******************************
|
#*** Kundne *******************************
|
||||||
$arr['CustomerList'][] = array(
|
$arr['CustomerList'][] = array(
|
||||||
"CustomerNumber" => $tA['kundennummer'], # Fake Daten
|
"CustomerNumber" => $tA['kundenummer'], # Fake Daten
|
||||||
"Surname" => 'MAX',#"string",
|
"Surname" => $tA['name'],#"string",
|
||||||
"Forename" => 'MUSTERMANN',#"string",
|
"Forename" => $tA['vorname'],#"string",
|
||||||
"AddressCity" => 'ERFURT',#"string",
|
"AddressCity" => $tA['ort'],#"string",
|
||||||
"AddressZipCode" => '99084', "string",
|
"AddressZipCode" => $tA['plz'], "string",
|
||||||
"AddressStreet" => 'MusterStrasse 22',#"string",
|
"AddressStreet" => $tA['strasse'],#"string",
|
||||||
"AddressCountry" => 'DE',#"string",
|
"AddressCountry" => substr($tA['land'], 0, 3),#"string",
|
||||||
#*** Nicht nötig
|
#*** Nicht nötig
|
||||||
#"CardNumber" => 0,
|
#"CardNumber" => 0,
|
||||||
#"SalutionNumber" => 0,
|
#"SalutionNumber" => 0,
|
||||||
@ -207,16 +205,9 @@ class Hiltes
|
|||||||
#"AdBan" => '',#true
|
#"AdBan" => '',#true
|
||||||
);
|
);
|
||||||
|
|
||||||
dd($arr);
|
|
||||||
|
|
||||||
$data = $this->createJson($arr);
|
$data = $this->createJson($arr);
|
||||||
// }
|
|
||||||
|
|
||||||
return $this->sendOrderToHiltes($data);
|
return $this->sendOrderToHiltes($data);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,8 +360,9 @@ class Hiltes
|
|||||||
$url = $this->hiltesApiUrl . '/api/WebSale/import';
|
$url = $this->hiltesApiUrl . '/api/WebSale/import';
|
||||||
|
|
||||||
$param = $data;
|
$param = $data;
|
||||||
dump($param);
|
//dump($param);
|
||||||
$r = $this->sendToHiltes($url, $param, true);
|
$r = $this->sendToHiltes($url, $param, true);
|
||||||
|
|
||||||
$t = json_decode($r, true);
|
$t = json_decode($r, true);
|
||||||
if ($t['Success']) {
|
if ($t['Success']) {
|
||||||
return true;
|
return true;
|
||||||
@ -380,68 +372,4 @@ class Hiltes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkData($data)
|
|
||||||
{
|
|
||||||
$umsatz = [
|
|
||||||
'EtikettKz' => 'E', // E = EAN, I = Ident, W = Warengruppe
|
|
||||||
'Etikettnummer' => $data['sku'], // mit führenden Nullen bei Satzart „W“ die Warengruppennummer
|
|
||||||
'Warengruppennummer' => '0000', // mit führenden Nullen
|
|
||||||
'Groessenbez' => '',
|
|
||||||
'Kundennummer' => '00000000000000000000',
|
|
||||||
'Nachlassart' => '0',
|
|
||||||
'Menge' => '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
|
|
||||||
'Kalk-VkPreis' => '00000000000000000000', //7 Vor – und 2 Nachkommastellen (Darstellung ohne Komma mit führenden Nullen).
|
|
||||||
'Vorgangsart' => 'v', // u = Umtausch, v = Verkauf
|
|
||||||
'Belegnummer' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Verkaufsdatum' => '00000000', // YYYYMMTT
|
|
||||||
'Verkaufszeit' => '000000', // HHMM
|
|
||||||
'Zahlungsart' => 2, // 1 = Kreditkarte, 2 = Rechnung, 3 = Lastschrift, 4 = Gutschein, 5 = Gutschrift, 6 = Mischzahlung
|
|
||||||
'Währung' => 'EUR', // EUR
|
|
||||||
'Einheit' => 'S', // S= Stück, M = Meter
|
|
||||||
'Vertriebskanal' => '0000', // Vertriebskanäle werden über das Stammdatenprogramm angelegt und müssen mit der hinterlegten Nummer aus dem Webshop übergeben werden
|
|
||||||
];
|
|
||||||
|
|
||||||
$kunde = [
|
|
||||||
'Kunden-Nummer' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Kartennummer' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Nachname' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Vorname' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Ort' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'PLZ' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Straße' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Land' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Postfach' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'PostfachPLZ' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Titel' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Telefon1' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Telefon2' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Telefax' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Geburtsdatum' => '00000000', // YYYYMMDD
|
|
||||||
'Geschlecht' => '00000000000000000000', // s = sonstiges, m = männlich, w = weiblich
|
|
||||||
'Email' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Rabatt' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Limit' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Sperr Kennzeichen' => '0', // 0 = nicht gesperrt, 1 = gesperrt
|
|
||||||
'Dubios Kennzeichen' => '0', // 0 = nicht dubios, 1 = dubios
|
|
||||||
'Bankeinzug' => '0', // 0 = kein Bankeinzug, 1 = Bankeinzug
|
|
||||||
'BankName1' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Konto1' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'BLZ1' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'BankName2' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Konto2' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'BLZ2' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'BankName3' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Konto3' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'BLZ3' => '00000000000000000000', // mit führenden Nullen
|
|
||||||
'Kreditkartennummer Kreditkarte1' => '', // mit führenden Nullen
|
|
||||||
'Kreditkartennummer Kreditkarte2' => '', // mit führenden Nullen
|
|
||||||
'Kreditkartennummer Kreditkarte3' => '', // mit führenden Nullen
|
|
||||||
'Kreditkartennummer Kreditkarte4' => '', // mit führenden Nullen
|
|
||||||
'Änderungskennzeichen' => '0', // 0 = Kunde ist OK, 1 = Änderung
|
|
||||||
'Newsletter' => '0', // 0 = kein Newsletter, 1 = Newsletter
|
|
||||||
'Passwort' => '', //
|
|
||||||
'Werbesperre' => '0', // 0 = keine Werbung, 1 = Werbung
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user