add authentication
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko 2023-11-10 15:12:34 +01:00
parent ae7c9df246
commit d661a2cbbc
No known key found for this signature in database
6 changed files with 448 additions and 291 deletions

View File

@ -8,13 +8,13 @@
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url> <jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
<data-source source="LOCAL" name="DDEV" uuid="5ac23057-b782-421b-8d88-fecc4d3386ee"> <data-source source="LOCAL" name="DDEV" uuid="460f8880-31b0-4942-b249-e8c664c61f08">
<driver-ref>mariadb</driver-ref> <driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
<configured-by-url>true</configured-by-url> <configured-by-url>true</configured-by-url>
<remarks>DDEV generated data source</remarks> <remarks>DDEV generated data source</remarks>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver> <jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://127.0.0.1:55619/db?user=db&amp;password=db</jdbc-url> <jdbc-url>jdbc:mariadb://127.0.0.1:51773/db?user=db&amp;password=db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
</component> </component>

View File

@ -22,6 +22,9 @@ services:
App\EventSubscriber\SlackNotifySubscriber: App\EventSubscriber\SlackNotifySubscriber:
arguments: arguments:
$slackWebhookUrl: '%env(SLACK_DSN)%' $slackWebhookUrl: '%env(SLACK_DSN)%'
# App\Helper\Hiltes:
# arguments:
# $orderRepository: '@App\Repository\OrderRepository'
# add more service definitions when explicit configuration is needed # add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones # please note that last definitions always *replace* previous ones

View File

@ -20,7 +20,7 @@ DirectoryIndex index.php
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
# This Option needs to be enabled for RewriteRule, otherwise it will show an error like # This Option needs to be enabled for RewriteRule, otherwise it will show an error like
# 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden' # 'Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden'
Options +FollowSymlinks #Options +FollowSymlinks
RewriteEngine On RewriteEngine On

View File

@ -3,6 +3,7 @@
namespace App\EventSubscriber; namespace App\EventSubscriber;
use ApiPlatform\Symfony\EventListener\EventPriorities; use ApiPlatform\Symfony\EventListener\EventPriorities;
use App\Helper\Hiltes;
use App\Helper\Slack; use App\Helper\Slack;
use App\Entity\Order; use App\Entity\Order;
use Maknz\Slack\Client; use Maknz\Slack\Client;
@ -23,10 +24,13 @@ class SlackNotifySubscriber implements EventSubscriberInterface
private $slackWebhookUrl; private $slackWebhookUrl;
public function __construct(string $slackWebhookUrl, LoggerInterface $logger) private $hiltes;
public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
{ {
$this->slackWebhookUrl = $slackWebhookUrl; $this->slackWebhookUrl = $slackWebhookUrl;
$this->logger = $logger; $this->logger = $logger;
$this->hiltes = $hiltes;
} }
public static function getSubscribedEvents(): array public static function getSubscribedEvents(): array
@ -46,7 +50,9 @@ class SlackNotifySubscriber implements EventSubscriberInterface
$slack = new Client($this->slackWebhookUrl, [ $slack = new Client($this->slackWebhookUrl, [
'username' => 'CDS-Notify', 'username' => 'CDS-Notify',
'channel' => '#general', 'channel' => '#general',
'link_names' => true 'link_names' => true,
'icon' => ':robot_face:',
'allow_markdown' => true,
]); ]);
$order = $event->getControllerResult(); $order = $event->getControllerResult();
@ -57,19 +63,24 @@ class SlackNotifySubscriber implements EventSubscriberInterface
return; return;
} }
$msg = "Bestellung {$order->getId()}: "; $msg = "Bestellung {$order->getOrderId()}: \n";
foreach($order->getData() as $item) { foreach($order->getData() as $item) {
if($item['menge'] > 0 && strlen($item['sku']) > 0) { if($item['menge'] > 0 && strlen($item['sku']) > 0) {
$msg .= ' '.$item['name']; $msg .= $item['name'];
$msg .= ' - '.$item['sku']; $msg .= ' '.$item['sku'];
$msg .= ' Menge: '.$item['menge']; $msg .= ' Menge: '.$item['menge']."\n";
} }
} }
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');
} }
} }
} }

View File

@ -2,6 +2,9 @@
namespace App\Helper; namespace App\Helper;
use App\Entity\Order;
use App\Repository\OrderRepository;
use Doctrine\Common\Collections\Criteria;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface; use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
@ -9,296 +12,437 @@ use Symfony\Component\Finder\Finder;
class Hiltes class Hiltes
{ {
// init file system // init file system
protected $fsObject; protected $fsObject;
protected $current_dir_path; protected $current_dir_path;
protected $apiKey; protected $apiKey;
protected $hiltesApiHash = ''; protected $hiltesApiHash = '';
protected $hiltesUsr; protected $hiltesUsr;
protected $hiltesPass; protected $hiltesPass;
protected $hiltesApiUrl; protected $hiltesApiUrl;
public function __construct()
{
$this->fsObject = new Filesystem();
$this->current_dir_path = getcwd();
$this->hiltesApiUrl = $_ENV['HILTES_API_URL']; public function __construct(private OrderRepository $orderRepository)
$this->hiltesUsr = $_ENV['HILTES_API_USER']; {
$this->hiltesPass = $_ENV['HILTES_API_PASSWORD']; $this->fsObject = new Filesystem();
} $this->current_dir_path = getcwd();
$this->hiltesApiUrl = $_ENV['HILTES_API_URL'];
/** $this->hiltesUsr = $_ENV['HILTES_API_USER'];
* Aufbau des Dateinamens: $this->hiltesPass = $_ENV['HILTES_API_PASS'];
* WU + Datum(TTMM) + Fortlaufendenummer (x2) + . +Filialnummer(x4)
* Beispieldateiname : WU220401.0001
*/
public function createFileName() :String
{
$date = date('dm');
$number = '01';
$filial = '0001';
return 'WU'.$date.$number.'.'.$filial;
}
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
* @return void
*/
public function export(string $data)
{
try {
$new_file_path = $this->current_dir_path . "/hiltes/c2h/".$this->createFileName();
if (!$this->fsObject->exists($new_file_path))
{
$this->fsObject->touch($new_file_path);
$this->fsObject->chmod($new_file_path, 0777);
$this->fsObject->dumpFile($new_file_path, $data);
}
} catch (IOExceptionInterface $exception) {
echo "Error creating file at". $exception->getPath();
} }
}
public function checkData($data) public function import()
{ {
$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 = [ $finder = new Finder();
'Kunden-Nummer'=> '00000000000000000000', // mit führenden Nullen $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
'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
];
}
public function createJson($data){
$arr = array(
'File' => array(
"BranchNumber" => $data['BranchNumber'], #Die Filialnummer
"ShopNumber" => $data['ShopNumber'], #Die Shopnummer
"SalesDate" => $data['SalesDate'], #Das Umsatzdatu
"DistributionChannel" => $data['DistributionChannel'] #Der Vertriebskanal
),
'SaleList' => array(
),
'CustomerList' => array(
),
);
#*** Sale List
if(!empty($data['SaleList'])){
foreach ($data['SaleList'] as $v){
$arr['SaleList'][] = array(
"SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
"SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
"SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
#"SizeDescription" => $v['SizeDescription'],
#"CustomerNumber" => $v['CustomerNumber'],
#"TypeOfEstate" => $v['TypeOfEstate'],
"Amount" => $v['Amount'],
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
"AchievedSalesPrice" => $v['AchievedSalesPrice'],
"TransactionType" => $v['TransactionType'],
#"ReceiptNumber" => $v['ReceiptNumber'],
"DateOfSale" => $data['SalesDate'],#"2023-09-14T11:54:26.708Z",
"PaymentMethod" => $v['PaymentMethod'],
"Currency" => $v['Currency'],
"Unit" => $v['Unit'],
"DistributionChannel" => $v['DistributionChannel']
);
}
}
#*** Sale List
if(true){
foreach ($data['CustomerList'] as $v){
$arr['CustomerList'][] = array(
"CustomerNumber" => $v['CustomerNumber'],
#"CardNumber" => $v['CardNumber'],
#"SalutionNumber" => $v['SalutionNumber'],
"Surname" => $v['Surname'],
"Forename" => $v['Forename'],
"AddressCity" => $v['AddressCity'],
"AddressZipCode" => $v['AddressZipCode'],
"AddressStreet" => $v['AddressStreet'],
"AddressCountry" => $v['AddressCountry'],
#"PostOfficeBox" => $v['PostOfficeBox'],
#"PostOfficeBoxZipCode" => $v['PostOfficeBoxZipCode'],
#"Title" => $v['Title'],
#"PhoneNumber1" => $v['PhoneNumber1'],
#"PhoneNumber2" => $v['PhoneNumber2'],
#"FaxNumber" => $v['FaxNumber'],#"string",
#"BirthDay" => $v['BirthDay'],
#"Gender" => $v['Gender'],
#"EmailAddress" => $v['EmailAddress'],
#"Discount" => $v['Discount'],
#"Limit" => $v['Limit'],
#"LockMark" => $v['LockMark'],
#"DubiousMark" => $v['DubiousMark'],
#"DubiousText" => $v['DubiousText'],
#"DirectDebit" => $v['DirectDebit'],
#"BankName1" => $v['BankName1'],#"string",
#"BankAccountNumber1" => $v['BankAccountNumber1'],#"string",
#"BankCodeNumber1" => $v['BankCodeNumber1'],#"string",
#"BankName2" => $v['BankName2'],#"string",
#"BankAccountNumber2" => $v['BankAccountNumber2'],#"string",
#"BankCodeNumber2" => $v['BankCodeNumber2'],#"string",
#"BankName3" => $v['BankName3'],#"string",
#"BankAccountNumber3" => $v['BankAccountNumber3'],#"string",
#"BankCodeNumber3" => $v['BankCodeNumber3'],#"string",
#"CreditcardNumber1" => $v['CreditcardNumber1'],#"string",
#"CreditcardNumber2" => $v['CreditcardNumber2'],#"string",
#"CreditcardNumber3" => $v['CreditcardNumber3'],#"string",
#"CreditcardNumber4" => $v['CreditcardNumber4'],#"string",
#"ChangeIndicator" => $v['ChangeIndicator'],
#"Newsletter" => $v['Newsletter'],
#"Password" => $v['Password'],
#"AdBan" => $v['AdBan']
);
}
}
#dump($arr);
return $arr;
}
public function sendToHiltes($url,$param,$auth=false){
if($auth){
#var_export($this->hiltesApiHash);
#var_export($url);
#var_export($param);
} foreach ($finder as $file) {
$contents = $file->getContents();
$ch = curl_init($url); var_dump($contents);
if($auth){ }
$authorization = "Authorization: Bearer ".$this->hiltesApiHash;
}else{ }
$authorization = false;
} /**
#dump($param); * @param string $data
# Setup request to send json via POST. * @return void
$payload = json_encode( $param ); */
#dump($payload); public function export(string $data)
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json',$authorization)); {
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload ); try {
# Return response instead of printing. $new_file_path = $this->current_dir_path . "/hiltes/c2h/" . $this->createFileName();
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request. if (!$this->fsObject->exists($new_file_path)) {
$result = curl_exec($ch); $this->fsObject->touch($new_file_path);
curl_close($ch); $this->fsObject->chmod($new_file_path, 0777);
return $result; $this->fsObject->dumpFile($new_file_path, $data);
} }
public function loginToHiltes($usr,$pass){ } catch (IOExceptionInterface $exception) {
$url = $this->hiltesApiUrl.'/api/Authentication/authenticate'; echo "Error creating file at" . $exception->getPath();
/* }
{ }
"Username": "string",
"Password": "string" /**
} * Aufbau des Dateinamens:
*/ * WU + Datum(TTMM) + Fortlaufendenummer (x2) + . +Filialnummer(x4)
$param = array( * Beispieldateiname : WU220401.0001
'Username' => (!empty($usr) ? $usr : $this->hiltesUsr), */
'Password' => (!empty($pass) ? $pass : $this->hiltesPass), public function createFileName(): string
{
$date = date('dm');
$number = '01';
$filial = '0001';
return 'WU' . $date . $number . '.' . $filial;
}
public function createRequest($orderData)
{
dump($orderData);
$data = array();
$this->loginToHiltes('', '');
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
dump($order);
/**
* @var Order
*/
if ($order) {
//foreach ($orders as $order) {
// if ($order->getStatus() > 0) continue;
$tA = $order->getData();#json_decode($order->getData());
#$tA['orderdate'] = "2023-08-30T12:05:24.000Z";
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 *****************
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', $tA['orderdate'] ? strtotime($tA['orderdate']) : time());
#****
$arr = array(
'SalesDate' => $tA['orderdate'],
"BranchNumber" => 8, #Die Filialnummer
"ShopNumber" => 1, #Die Shopnummer
"DistributionChannel" => 5, #Der Vertriebskanal
'SaleList' => array(),
'CustomerList' => array(),
);
#*** Items ***************
if (!empty($tA['data']) && is_array($tA['data'])) {
# Noch nötig
# "CalculatedSellingPrice" => 0, #X Kalkulierter Verkaufspreis
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array();
foreach ($tA['data'] as $v) {
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) {
$SalesNumber = $tP[1];
}
if (isset($tSalNr[$SalesNumber])) {
$tSalNr[$SalesNumber]++;
$SalesNumber .= $tSalNr[$SalesNumber];
} else {
$tSalNr[$SalesNumber] = 0;
}
#dump($SalesNumber);
#********
$v['CalculatedSellingPrice'] = 100.00;
$v['AchievedSalesPrice'] = 90.00;
$arr['SaleList'][] = array(
"SalesLabel" => 'Ean',#$v['sku'],#X
"SalesLabelNumber" => $SalesNumber,#X
"SalesGoodsGroupNumber" => 0,
"SizeDescription" => '',#"string",
"CustomerNumber" => 0,
"TypeOfEstate" => 0,
"Amount" => $v['menge'],#X
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'], #X Kalkulierter Verkaufspreis
"AchievedSalesPrice" => $v['AchievedSalesPrice'], #X Erzielter Verkaufspreis
"TransactionType" => "Sale", #X Die Vorgangsart Sale=Verkauf Exchange=Umtausch / Storno
"ReceiptNumber" => 0, #Die Belegnummer
"DateOfSale" => $tA['orderdate'],#X das Verkaufsdatum mit Verkaufszeit
"PaymentMethod" => 'Invoice',#X "CreditCard",
"Currency" => 'EUR',#X "string",
"Unit" => "Piece",#X
"DistributionChannel" => 5,
);
}
}
#*** Kundne *******************************
$arr['CustomerList'][] = array(
"CustomerNumber" => $tA['kundennummer'], # Fake Daten
"Surname" => 'MAX',#"string",
"Forename" => 'MUSTERMANN',#"string",
"AddressCity" => 'ERFURT',#"string",
"AddressZipCode" => '99084', "string",
"AddressStreet" => 'MusterStrasse 22',#"string",
"AddressCountry" => 'DE',#"string",
#*** Nicht nötig
#"CardNumber" => 0,
#"SalutionNumber" => 0,
#"PostOfficeBox" => '',#"string",
#"PostOfficeBoxZipCode" => '',#"string",
#"Title" => '',#"string",
#"PhoneNumber1" => '',#"string",
#"PhoneNumber2" => '',#"string",
#"FaxNumber" => '',#"string",
#"BirthDay" => '',#"2023-09-14T11:54:26.708Z",
#"Gender" => 'Male',
#"EmailAddress" => '',#"string",
#"Discount" => 0,
#"Limit" => 0,
#"LockMark" => 'Unblocked',
#"DubiousMark" => 'Undubious',
#"DubiousText" => '',#"string",
#"DirectDebit" => '',#true,
#"BankName1" => '',#"string",
#"BankAccountNumber1" => '',#"string",
#"BankCodeNumber1" => '',#"string",
#"BankName2" => '',#"string",
#"BankAccountNumber2" => '',#"string",
#"BankCodeNumber2" => '',#"string",
#"BankName3" => '',#"string",
#"BankAccountNumber3" => '',#"string",
#"BankCodeNumber3" => '',#"string",
#"CreditcardNumber1" => '',#"string",
#"CreditcardNumber2" => '',#"string",
#"CreditcardNumber3" => '',#"string",
#"CreditcardNumber4" => '',#"string",
#"ChangeIndicator" => '',#true,
#"Newsletter" => '',#true,
#"Password" => '',#"string",
#"AdBan" => '',#true
);
dd($arr);
$data = $this->createJson($arr);
// }
return $this->sendOrderToHiltes($data);
}
}
/**
* @param $usr
* @param $pass
* @return bool
*/
public function loginToHiltes($usr, $pass): bool
{
$url = $this->hiltesApiUrl . '/api/Authentication/authenticate';
$param = array(
'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
# 'parse_mode' => 'html', # 'parse_mode' => 'html',
# 'disable_notification' => $disable_notification, # 'disable_notification' => $disable_notification,
# 'text' => $message_text # 'text' => $message_text
); );
$r = $this->sendToHiltes($url,$param);
$t = json_decode($r,true); $r = $this->sendToHiltes($url, $param);
if($t['Success']){ $t = json_decode($r, true);
$this->hiltesApiHash = $t['Data']; if ($t['Success']) {
return true; $this->hiltesApiHash = $t['Data'];
}else{ return true;
dump($r); } else {
dump('Login Error '.__LINE__); dump($r);
return false; dump('Login Error ' . __LINE__);
} return false;
} }
public function sendOrderToHiltes($data){ }
$url = $this->hiltesApiUrl.'/api/WebSale/import';
/* public function sendToHiltes($url, $param, $auth = false)
{ {
"Username": "string", if ($auth) {
"Password": "string" #var_export($this->hiltesApiHash);
} #var_export($url);
*/ #var_export($param);
$param = $data;
dump($param); }
$r = $this->sendToHiltes($url,$param,true);
$t = json_decode($r,true); $ch = curl_init($url);
if($t['Success']){ if ($auth) {
$this->hiltesApiHash = $t['Data']; $authorization = "Authorization: Bearer " . $this->hiltesApiHash;
}else{ } else {
dump($r); $authorization = false;
dd('Submit Error'.__LINE__); }
} #dump($param);
} # Setup request to send json via POST.
$payload = json_encode($param);
#dump($payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', $authorization));
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
# Return response instead of printing.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
# Send request.
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
public function createJson($data)
{
$arr = array(
'File' => array(
"BranchNumber" => $data['BranchNumber'], #Die Filialnummer
"ShopNumber" => $data['ShopNumber'], #Die Shopnummer
"SalesDate" => $data['SalesDate'], #Das Umsatzdatu
"DistributionChannel" => $data['DistributionChannel'] #Der Vertriebskanal
),
'SaleList' => array(),
'CustomerList' => array(),
);
#*** Sale List
if (!empty($data['SaleList'])) {
foreach ($data['SaleList'] as $v) {
$arr['SaleList'][] = array(
"SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
"SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
"SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
#"SizeDescription" => $v['SizeDescription'],
#"CustomerNumber" => $v['CustomerNumber'],
#"TypeOfEstate" => $v['TypeOfEstate'],
"Amount" => $v['Amount'],
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
"AchievedSalesPrice" => $v['AchievedSalesPrice'],
"TransactionType" => $v['TransactionType'],
#"ReceiptNumber" => $v['ReceiptNumber'],
"DateOfSale" => $data['SalesDate'],#"2023-09-14T11:54:26.708Z",
"PaymentMethod" => $v['PaymentMethod'],
"Currency" => $v['Currency'],
"Unit" => $v['Unit'],
"DistributionChannel" => $v['DistributionChannel']
);
}
}
#*** Sale List
if (true) {
foreach ($data['CustomerList'] as $v) {
$arr['CustomerList'][] = array(
"CustomerNumber" => $v['CustomerNumber'],
#"CardNumber" => $v['CardNumber'],
#"SalutionNumber" => $v['SalutionNumber'],
"Surname" => $v['Surname'],
"Forename" => $v['Forename'],
"AddressCity" => $v['AddressCity'],
"AddressZipCode" => $v['AddressZipCode'],
"AddressStreet" => $v['AddressStreet'],
"AddressCountry" => $v['AddressCountry'],
#"PostOfficeBox" => $v['PostOfficeBox'],
#"PostOfficeBoxZipCode" => $v['PostOfficeBoxZipCode'],
#"Title" => $v['Title'],
#"PhoneNumber1" => $v['PhoneNumber1'],
#"PhoneNumber2" => $v['PhoneNumber2'],
#"FaxNumber" => $v['FaxNumber'],#"string",
#"BirthDay" => $v['BirthDay'],
#"Gender" => $v['Gender'],
#"EmailAddress" => $v['EmailAddress'],
#"Discount" => $v['Discount'],
#"Limit" => $v['Limit'],
#"LockMark" => $v['LockMark'],
#"DubiousMark" => $v['DubiousMark'],
#"DubiousText" => $v['DubiousText'],
#"DirectDebit" => $v['DirectDebit'],
#"BankName1" => $v['BankName1'],#"string",
#"BankAccountNumber1" => $v['BankAccountNumber1'],#"string",
#"BankCodeNumber1" => $v['BankCodeNumber1'],#"string",
#"BankName2" => $v['BankName2'],#"string",
#"BankAccountNumber2" => $v['BankAccountNumber2'],#"string",
#"BankCodeNumber2" => $v['BankCodeNumber2'],#"string",
#"BankName3" => $v['BankName3'],#"string",
#"BankAccountNumber3" => $v['BankAccountNumber3'],#"string",
#"BankCodeNumber3" => $v['BankCodeNumber3'],#"string",
#"CreditcardNumber1" => $v['CreditcardNumber1'],#"string",
#"CreditcardNumber2" => $v['CreditcardNumber2'],#"string",
#"CreditcardNumber3" => $v['CreditcardNumber3'],#"string",
#"CreditcardNumber4" => $v['CreditcardNumber4'],#"string",
#"ChangeIndicator" => $v['ChangeIndicator'],
#"Newsletter" => $v['Newsletter'],
#"Password" => $v['Password'],
#"AdBan" => $v['AdBan']
);
}
}
#dump($arr);
return $arr;
}
public function sendOrderToHiltes($data)
{
$url = $this->hiltesApiUrl . '/api/WebSale/import';
$param = $data;
dump($param);
$r = $this->sendToHiltes($url, $param, true);
$t = json_decode($r, true);
if ($t['Success']) {
return true;
} else {
dump($r);
return false;
}
}
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
];
}
} }

View File

@ -23,7 +23,6 @@ class Slack
try { try {
$sentMessage = $this->chatter->send($message); $sentMessage = $this->chatter->send($message);
dump($sentMessage);
} catch (TransportExceptionInterface $e) { } catch (TransportExceptionInterface $e) {
} }