This commit is contained in:
parent
ae7c9df246
commit
d661a2cbbc
@ -8,13 +8,13 @@
|
||||
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</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>
|
||||
<synchronize>true</synchronize>
|
||||
<configured-by-url>true</configured-by-url>
|
||||
<remarks>DDEV generated data source</remarks>
|
||||
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:mariadb://127.0.0.1:55619/db?user=db&password=db</jdbc-url>
|
||||
<jdbc-url>jdbc:mariadb://127.0.0.1:51773/db?user=db&password=db</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
|
@ -22,6 +22,9 @@ services:
|
||||
App\EventSubscriber\SlackNotifySubscriber:
|
||||
arguments:
|
||||
$slackWebhookUrl: '%env(SLACK_DSN)%'
|
||||
# App\Helper\Hiltes:
|
||||
# arguments:
|
||||
# $orderRepository: '@App\Repository\OrderRepository'
|
||||
|
||||
# add more service definitions when explicit configuration is needed
|
||||
# please note that last definitions always *replace* previous ones
|
@ -20,7 +20,7 @@ DirectoryIndex index.php
|
||||
<IfModule mod_rewrite.c>
|
||||
# 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
|
||||
#Options +FollowSymlinks
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\EventSubscriber;
|
||||
|
||||
use ApiPlatform\Symfony\EventListener\EventPriorities;
|
||||
use App\Helper\Hiltes;
|
||||
use App\Helper\Slack;
|
||||
use App\Entity\Order;
|
||||
use Maknz\Slack\Client;
|
||||
@ -23,10 +24,13 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
||||
|
||||
private $slackWebhookUrl;
|
||||
|
||||
public function __construct(string $slackWebhookUrl, LoggerInterface $logger)
|
||||
private $hiltes;
|
||||
|
||||
public function __construct(string $slackWebhookUrl, LoggerInterface $logger, Hiltes $hiltes)
|
||||
{
|
||||
$this->slackWebhookUrl = $slackWebhookUrl;
|
||||
$this->logger = $logger;
|
||||
$this->hiltes = $hiltes;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
@ -46,7 +50,9 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
||||
$slack = new Client($this->slackWebhookUrl, [
|
||||
'username' => 'CDS-Notify',
|
||||
'channel' => '#general',
|
||||
'link_names' => true
|
||||
'link_names' => true,
|
||||
'icon' => ':robot_face:',
|
||||
'allow_markdown' => true,
|
||||
]);
|
||||
|
||||
$order = $event->getControllerResult();
|
||||
@ -57,19 +63,24 @@ class SlackNotifySubscriber implements EventSubscriberInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$msg = "Bestellung {$order->getId()}: ";
|
||||
$msg = "Bestellung {$order->getOrderId()}: \n";
|
||||
|
||||
foreach($order->getData() as $item) {
|
||||
if($item['menge'] > 0 && strlen($item['sku']) > 0) {
|
||||
$msg .= ' '.$item['name'];
|
||||
$msg .= ' - '.$item['sku'];
|
||||
$msg .= ' Menge: '.$item['menge'];
|
||||
$msg .= $item['name'];
|
||||
$msg .= ' '.$item['sku'];
|
||||
$msg .= ' Menge: '.$item['menge']."\n";
|
||||
}
|
||||
}
|
||||
|
||||
if($order->getStatus() == 1) {
|
||||
$slack->from('CDS-Notify')
|
||||
->send($msg);
|
||||
}elseif($order->getStatus() == 2){
|
||||
//Send to Hiltes
|
||||
$this->hiltes->createRequest($order);
|
||||
}else{
|
||||
$this->logger->error('Status ist nicht 1 oder 2');
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,9 @@
|
||||
|
||||
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\Filesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
@ -18,32 +21,17 @@ class Hiltes
|
||||
protected $hiltesPass;
|
||||
protected $hiltesApiUrl;
|
||||
|
||||
public function __construct()
|
||||
|
||||
public function __construct(private OrderRepository $orderRepository)
|
||||
{
|
||||
$this->fsObject = new Filesystem();
|
||||
$this->current_dir_path = getcwd();
|
||||
|
||||
|
||||
$this->hiltesApiUrl = $_ENV['HILTES_API_URL'];
|
||||
$this->hiltesUsr = $_ENV['HILTES_API_USER'];
|
||||
$this->hiltesPass = $_ENV['HILTES_API_PASSWORD'];
|
||||
$this->hiltesPass = $_ENV['HILTES_API_PASS'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Aufbau des Dateinamens:
|
||||
* 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()
|
||||
{
|
||||
|
||||
@ -65,83 +53,233 @@ class Hiltes
|
||||
public function export(string $data)
|
||||
{
|
||||
try {
|
||||
$new_file_path = $this->current_dir_path . "/hiltes/c2h/".$this->createFileName();
|
||||
$new_file_path = $this->current_dir_path . "/hiltes/c2h/" . $this->createFileName();
|
||||
|
||||
if (!$this->fsObject->exists($new_file_path))
|
||||
{
|
||||
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();
|
||||
echo "Error creating file at" . $exception->getPath();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkData($data)
|
||||
/**
|
||||
* Aufbau des Dateinamens:
|
||||
* WU + Datum(TTMM) + Fortlaufendenummer (x2) + “.“ +Filialnummer(x4)
|
||||
* Beispieldateiname : WU220401.0001
|
||||
*/
|
||||
public function createFileName(): string
|
||||
{
|
||||
$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
|
||||
];
|
||||
$date = date('dm');
|
||||
$number = '01';
|
||||
$filial = '0001';
|
||||
return 'WU' . $date . $number . '.' . $filial;
|
||||
}
|
||||
public function createJson($data){
|
||||
|
||||
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',
|
||||
# 'disable_notification' => $disable_notification,
|
||||
# 'text' => $message_text
|
||||
);
|
||||
|
||||
$r = $this->sendToHiltes($url, $param);
|
||||
$t = json_decode($r, true);
|
||||
if ($t['Success']) {
|
||||
$this->hiltesApiHash = $t['Data'];
|
||||
return true;
|
||||
} else {
|
||||
dump($r);
|
||||
dump('Login Error ' . __LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function sendToHiltes($url, $param, $auth = false)
|
||||
{
|
||||
if ($auth) {
|
||||
#var_export($this->hiltesApiHash);
|
||||
#var_export($url);
|
||||
#var_export($param);
|
||||
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
if ($auth) {
|
||||
$authorization = "Authorization: Bearer " . $this->hiltesApiHash;
|
||||
} else {
|
||||
$authorization = false;
|
||||
}
|
||||
#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
|
||||
@ -149,14 +287,12 @@ class Hiltes
|
||||
"SalesDate" => $data['SalesDate'], #Das Umsatzdatu
|
||||
"DistributionChannel" => $data['DistributionChannel'] #Der Vertriebskanal
|
||||
),
|
||||
'SaleList' => array(
|
||||
),
|
||||
'CustomerList' => array(
|
||||
),
|
||||
'SaleList' => array(),
|
||||
'CustomerList' => array(),
|
||||
);
|
||||
#*** Sale List
|
||||
if(!empty($data['SaleList'])){
|
||||
foreach ($data['SaleList'] as $v){
|
||||
if (!empty($data['SaleList'])) {
|
||||
foreach ($data['SaleList'] as $v) {
|
||||
$arr['SaleList'][] = array(
|
||||
"SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
|
||||
"SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
|
||||
@ -178,8 +314,8 @@ class Hiltes
|
||||
}
|
||||
}
|
||||
#*** Sale List
|
||||
if(true){
|
||||
foreach ($data['CustomerList'] as $v){
|
||||
if (true) {
|
||||
foreach ($data['CustomerList'] as $v) {
|
||||
$arr['CustomerList'][] = array(
|
||||
"CustomerNumber" => $v['CustomerNumber'],
|
||||
#"CardNumber" => $v['CardNumber'],
|
||||
@ -228,77 +364,85 @@ class Hiltes
|
||||
#dump($arr);
|
||||
return $arr;
|
||||
}
|
||||
public function sendToHiltes($url,$param,$auth=false){
|
||||
if($auth){
|
||||
#var_export($this->hiltesApiHash);
|
||||
#var_export($url);
|
||||
#var_export($param);
|
||||
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
if($auth){
|
||||
$authorization = "Authorization: Bearer ".$this->hiltesApiHash;
|
||||
}else{
|
||||
$authorization = false;
|
||||
}
|
||||
#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 loginToHiltes($usr,$pass){
|
||||
$url = $this->hiltesApiUrl.'/api/Authentication/authenticate';
|
||||
/*
|
||||
public function sendOrderToHiltes($data)
|
||||
{
|
||||
"Username": "string",
|
||||
"Password": "string"
|
||||
}
|
||||
*/
|
||||
$param = array(
|
||||
'Username' => (!empty($usr) ? $usr : $this->hiltesUsr),
|
||||
'Password' => (!empty($pass) ? $pass : $this->hiltesPass),
|
||||
# 'parse_mode' => 'html',
|
||||
# 'disable_notification' => $disable_notification,
|
||||
# 'text' => $message_text
|
||||
);
|
||||
$r = $this->sendToHiltes($url,$param);
|
||||
$t = json_decode($r,true);
|
||||
if($t['Success']){
|
||||
$this->hiltesApiHash = $t['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{
|
||||
} else {
|
||||
dump($r);
|
||||
dump('Login Error '.__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public function sendOrderToHiltes($data){
|
||||
$url = $this->hiltesApiUrl.'/api/WebSale/import';
|
||||
/*
|
||||
|
||||
public function checkData($data)
|
||||
{
|
||||
"Username": "string",
|
||||
"Password": "string"
|
||||
}
|
||||
*/
|
||||
$param = $data;
|
||||
dump($param);
|
||||
$r = $this->sendToHiltes($url,$param,true);
|
||||
$t = json_decode($r,true);
|
||||
if($t['Success']){
|
||||
$this->hiltesApiHash = $t['Data'];
|
||||
}else{
|
||||
dump($r);
|
||||
dd('Submit Error'.__LINE__);
|
||||
}
|
||||
$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
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -23,7 +23,6 @@ class Slack
|
||||
|
||||
try {
|
||||
$sentMessage = $this->chatter->send($message);
|
||||
dump($sentMessage);
|
||||
} catch (TransportExceptionInterface $e) {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user