add hiltes log on Order
This commit is contained in:
parent
13d199768e
commit
9dbe5e5de7
@ -14,7 +14,7 @@
|
|||||||
<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:32768/db?user=db&password=db</jdbc-url>
|
<jdbc-url>jdbc:mariadb://127.0.0.1:32770/db?user=db&password=db</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
@ -41,6 +41,9 @@ class Order
|
|||||||
#[ORM\Column(name: 'change_date', type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
|
#[ORM\Column(name: 'change_date', type: Types::DATETIME_MUTABLE, nullable: true, options: ['default' => 'CURRENT_TIMESTAMP'])]
|
||||||
private ?DateTimeInterface $changeDate = null;
|
private ?DateTimeInterface $changeDate = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||||
|
private ?string $hiltes = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -93,4 +96,16 @@ class Order
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getHiltes(): ?string
|
||||||
|
{
|
||||||
|
return $this->hiltes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setHiltes(?string $hiltes): static
|
||||||
|
{
|
||||||
|
$this->hiltes = $hiltes;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
@ -82,7 +82,11 @@ class Hiltes
|
|||||||
|
|
||||||
if ($order) {
|
if ($order) {
|
||||||
//foreach ($orders as $order) {
|
//foreach ($orders as $order) {
|
||||||
if ($order->getStatus() != 2) return false;
|
if ($order->getStatus() != 2) {
|
||||||
|
$this->logger->error('Order not ready for export ' . $order->getOrderId());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$tA = $order->getData()[0];#json_decode($order->getData());
|
$tA = $order->getData()[0];#json_decode($order->getData());
|
||||||
|
|
||||||
#dump($tA);
|
#dump($tA);
|
||||||
@ -94,12 +98,14 @@ class Hiltes
|
|||||||
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', time());
|
$tA['orderdate'] = gmdate('Y-m-d\TH:i:s.v\Z', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
#****
|
#*** Aufbau des Arrays ******************************
|
||||||
$arr = array(
|
$arr = array(
|
||||||
'SalesDate' => $tA['orderdate'],
|
'File' => array(
|
||||||
"BranchNumber" => 8, #Die Filialnummer
|
"BranchNumber" => 8, #Die Filialnummer
|
||||||
"ShopNumber" => 1, #Die Shopnummer
|
"ShopNumber" => 1, #Die Shopnummer
|
||||||
"DistributionChannel" => 5, #Der Vertriebskanal
|
"SalesDate" => $tA['orderdate'], #Das Umsatzdatu
|
||||||
|
"DistributionChannel" => 5, #Der Vertriebskanal
|
||||||
|
),
|
||||||
'SaleList' => array(),
|
'SaleList' => array(),
|
||||||
'CustomerList' => array(),
|
'CustomerList' => array(),
|
||||||
);
|
);
|
||||||
@ -133,17 +139,18 @@ class Hiltes
|
|||||||
$v['AchievedSalesPrice'] = round(str_replace(',', '.', $v['CalculatedSellingPrice']), 2);
|
$v['AchievedSalesPrice'] = round(str_replace(',', '.', $v['CalculatedSellingPrice']), 2);
|
||||||
|
|
||||||
$arr['SaleList'][] = array(
|
$arr['SaleList'][] = array(
|
||||||
|
"OrderNumber" => $tA['externOrderId'], #X
|
||||||
"SalesLabel" => 'Ean',#$v['sku'],#X
|
"SalesLabel" => 'Ean',#$v['sku'],#X
|
||||||
"SalesLabelNumber" => $SalesNumber,#X
|
"SalesLabelNumber" => $SalesNumber,#X
|
||||||
"SalesGoodsGroupNumber" => $SalesGoodsGroupNumber,
|
"SalesGoodsGroupNumber" => $SalesGoodsGroupNumber,
|
||||||
"SizeDescription" => '',#"string",
|
#"SizeDescription" => '',#"string",
|
||||||
"CustomerNumber" => $tA['kundenummer'],
|
"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" => $tA['externOrderId'], #Die Belegnummer
|
"ReceiptNumber" => substr($order->getOrderId(), 3), #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",
|
||||||
@ -162,45 +169,18 @@ class Hiltes
|
|||||||
"AddressZipCode" => $tA['plz'], "string",
|
"AddressZipCode" => $tA['plz'], "string",
|
||||||
"AddressStreet" => $tA['strasse'],#"string",
|
"AddressStreet" => $tA['strasse'],#"string",
|
||||||
"AddressCountry" => substr($tA['land'], 0, 3),#"string",
|
"AddressCountry" => substr($tA['land'], 0, 3),#"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
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = $this->createJson($arr);
|
//$data = $this->createJson($arr);
|
||||||
return $this->sendOrderToHiltes($data);
|
$this->logger->info(var_export($arr, 1));
|
||||||
|
|
||||||
|
try {
|
||||||
|
return $this->sendOrderToHiltes($arr);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->logger->error('Send Order Error ' . $e->getMessage() . __LINE__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,18 +270,19 @@ class Hiltes
|
|||||||
if (!empty($data['SaleList'])) {
|
if (!empty($data['SaleList'])) {
|
||||||
foreach ($data['SaleList'] as $v) {
|
foreach ($data['SaleList'] as $v) {
|
||||||
$arr['SaleList'][] = array(
|
$arr['SaleList'][] = array(
|
||||||
|
"OrderNumber" => $v['OrderNumber'],
|
||||||
"SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
|
"SalesLabel" => $v['SalesLabel'], #Das Etikettkennzeichen
|
||||||
"SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
|
"SalesLabelNumber" => $v['SalesLabelNumber'], #Etikettennummer
|
||||||
"SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
|
"SalesGoodsGroupNumber" => $v['SalesGoodsGroupNumber'],
|
||||||
#"SizeDescription" => $v['SizeDescription'],
|
|
||||||
#"CustomerNumber" => $v['CustomerNumber'],
|
#"CustomerNumber" => $v['CustomerNumber'],
|
||||||
#"TypeOfEstate" => $v['TypeOfEstate'],
|
#"TypeOfEstate" => $v['TypeOfEstate'],
|
||||||
"Amount" => $v['Amount'],
|
"Amount" => $v['Amount'],
|
||||||
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
|
"CalculatedSellingPrice" => $v['CalculatedSellingPrice'],
|
||||||
"AchievedSalesPrice" => $v['AchievedSalesPrice'],
|
"AchievedSalesPrice" => $v['AchievedSalesPrice'],
|
||||||
"TransactionType" => $v['TransactionType'],
|
"TransactionType" => $v['TransactionType'],
|
||||||
#"ReceiptNumber" => $v['ReceiptNumber'],
|
"ReceiptNumber" => $v['ReceiptNumber'],
|
||||||
"DateOfSale" => $data['SalesDate'],#"2023-09-14T11:54:26.708Z",
|
"DateOfSale" => $v['SalesDate'],#"2023-09-14T11:54:26.708Z",
|
||||||
"PaymentMethod" => $v['PaymentMethod'],
|
"PaymentMethod" => $v['PaymentMethod'],
|
||||||
"Currency" => $v['Currency'],
|
"Currency" => $v['Currency'],
|
||||||
"Unit" => $v['Unit'],
|
"Unit" => $v['Unit'],
|
||||||
@ -364,6 +345,7 @@ class Hiltes
|
|||||||
/**
|
/**
|
||||||
* @param $data
|
* @param $data
|
||||||
* @return bool
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function sendOrderToHiltes($data): bool
|
public function sendOrderToHiltes($data): bool
|
||||||
{
|
{
|
||||||
@ -372,18 +354,30 @@ class Hiltes
|
|||||||
$param = $data;
|
$param = $data;
|
||||||
//dump($param);
|
//dump($param);
|
||||||
$r = $this->sendToHiltes($url, $param, true);
|
$r = $this->sendToHiltes($url, $param, true);
|
||||||
|
//$r = true;
|
||||||
|
|
||||||
if ($r === false) {
|
if ($r === false) {
|
||||||
$this->logger->error('Send Order Error ' . $r . __LINE__);
|
$this->logger->error('Send Order Error ' . __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$t = json_decode($r, true);
|
$t = json_decode($r, true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$order = $this->orderRepository->findOneBy(array('orderId' => $data['SaleList'][0]['OrderNumber']));
|
||||||
|
$order->setStatus(3);
|
||||||
|
$order->setHiltes(var_export($r, 1));
|
||||||
|
|
||||||
|
$this->orderRepository->update($order, true);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
$this->logger->error('Send Order Error ' . $exception->getMessage() . __LINE__);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($t['Success']) {
|
if ($t['Success']) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->logger->error('Send Order Error ' . var_dump($t['Message']) . __LINE__);
|
$this->logger->error('Send Order Error ' . var_export($t['errors'], 1) . __LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Order;
|
use App\Entity\Order;
|
||||||
|
use DateTime;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -24,6 +25,7 @@ class OrderRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
public function save(Order $entity, bool $flush = false): void
|
public function save(Order $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
|
$entity->setChangeDate(new DateTime());
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
|
|
||||||
if ($flush) {
|
if ($flush) {
|
||||||
@ -46,6 +48,7 @@ class OrderRepository extends ServiceEntityRepository
|
|||||||
public function update(Order $entity, bool $flush = false): void
|
public function update(Order $entity, bool $flush = false): void
|
||||||
{
|
{
|
||||||
$order = $this->getEntityManager()->find(Order::class, $entity->getId());
|
$order = $this->getEntityManager()->find(Order::class, $entity->getId());
|
||||||
|
$order->setChangeDate(new DateTime());
|
||||||
|
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
throw $this->createNotFoundException('Order not found: ' . $entity->getId());
|
throw $this->createNotFoundException('Order not found: ' . $entity->getId());
|
||||||
|
Loading…
Reference in New Issue
Block a user