mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Fix broken ShopUpdates after move to "versandpakete"
This commit is contained in:
parent
bd94ac8e15
commit
1ab2bea2f1
15
classes/Modules/Onlineshop/Data/OrderStatus.php
Normal file
15
classes/Modules/Onlineshop/Data/OrderStatus.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
// SPDX-FileCopyrightText: 2024 Andreas Palm
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
namespace Xentral\Modules\Onlineshop\Data;
|
||||
|
||||
enum OrderStatus
|
||||
{
|
||||
case Imported;
|
||||
case InProgress;
|
||||
case Completed;
|
||||
case Cancelled;
|
||||
}
|
48
classes/Modules/Onlineshop/Data/OrderStatusUpdateRequest.php
Normal file
48
classes/Modules/Onlineshop/Data/OrderStatusUpdateRequest.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// SPDX-FileCopyrightText: 2024 Andreas Palm
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
namespace Xentral\Modules\Onlineshop\Data;
|
||||
|
||||
class OrderStatusUpdateRequest
|
||||
{
|
||||
/**
|
||||
* @var int ID of the (primary/imported) order (ERP domain)
|
||||
*/
|
||||
public int $orderId;
|
||||
|
||||
/**
|
||||
* @var string ID of the order (Shop domain)
|
||||
*/
|
||||
public string $shopOrderId;
|
||||
|
||||
/**
|
||||
* @var OrderStatus current order status
|
||||
*/
|
||||
public OrderStatus $orderStatus;
|
||||
|
||||
/**
|
||||
* @var Shipment[] list of shipments for this order
|
||||
*/
|
||||
public array $shipments;
|
||||
|
||||
public function getTrackingNumberList() : array {
|
||||
$list = [];
|
||||
foreach ($this->shipments as $shipment) {
|
||||
if (!empty($shipment->trackingNumber))
|
||||
$list[] = $shipment->trackingNumber;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getTrackingUrlList() : array {
|
||||
$list = [];
|
||||
foreach ($this->shipments as $shipment) {
|
||||
if (!empty($shipment->trackingUrl))
|
||||
$list[] = $shipment->trackingUrl;
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
}
|
30
classes/Modules/Onlineshop/Data/Shipment.php
Normal file
30
classes/Modules/Onlineshop/Data/Shipment.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// SPDX-FileCopyrightText: 2024 Andreas Palm
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
namespace Xentral\Modules\Onlineshop\Data;
|
||||
|
||||
class Shipment
|
||||
{
|
||||
/**
|
||||
* @var int ID of the shipment (ERP domain)
|
||||
*/
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* @var string plain tracking number
|
||||
*/
|
||||
public string $trackingNumber;
|
||||
|
||||
/**
|
||||
* @var string URL to view tracking details
|
||||
*/
|
||||
public string $trackingUrl;
|
||||
|
||||
/**
|
||||
* @var string shipping method (after mapping to Shop domain)
|
||||
*/
|
||||
public string $shippingMethod;
|
||||
}
|
@ -387,15 +387,16 @@ function GetLaender()
|
||||
$join = '';
|
||||
$where = '';
|
||||
$app->erp->RunHook('shop_rueckmeldung', 2, $join, $where);
|
||||
$sql = "SELECT a.id,apro.zeit, a.shop, l.id as lieferschein, v.id as versandid, l.projekt
|
||||
FROM auftrag AS a
|
||||
LEFT JOIN lieferschein AS l on l.auftragid = a.id
|
||||
LEFT JOIN auftrag_protokoll AS apro ON a.id = apro.auftrag AND apro.grund LIKE 'Auftrag importiert vom Shop'
|
||||
LEFT JOIN projekt AS pr ON l.projekt = pr.id
|
||||
LEFT JOIN versand AS v ON v.lieferschein = l.id
|
||||
$sql = "SELECT DISTINCT a.id, a.shop
|
||||
FROM auftrag a
|
||||
LEFT JOIN lieferschein l on l.auftragid = a.id
|
||||
LEFT JOIN projekt pr ON l.projekt = pr.id
|
||||
LEFT JOIN lieferschein_position lp ON lp.lieferschein = l.id
|
||||
LEFT JOIN versandpaket_lieferschein_position vlp ON vlp.lieferschein_position = lp.id
|
||||
LEFT JOIN versandpakete v ON (v.lieferschein_ohne_pos = l.id OR v.id = vlp.versandpaket)
|
||||
$join
|
||||
WHERE a.status = 'abgeschlossen' AND $subwhere AND
|
||||
DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 2 WEEK),'%Y-%m-%d') < a.datum AND
|
||||
DATE_SUB(NOW(),INTERVAL 2 WEEK) < a.datum AND
|
||||
a.shopextstatus <> 'abgeschlossen' AND a.shop > 0 AND
|
||||
(
|
||||
( v.tracking <> '' AND l.status = 'versendet') OR
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
* SPDX-FileCopyrightText: 2022-2024 Andreas Palm
|
||||
* SPDX-FileCopyrightText: 2019 Xentral (c) Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg, Germany
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
@ -20,6 +20,10 @@
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
use Xentral\Modules\Onlineshop\Data\Shipment;
|
||||
use Xentral\Modules\Onlineshop\Data\ShopConnectorResponseInterface;
|
||||
|
||||
class Remote
|
||||
@ -2301,133 +2305,58 @@ class Remote
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getDataToSendForUpdateOrder(int $shopId, int $orderId): array
|
||||
public function getDataToSendForUpdateOrder(int $shopId, int $orderId): ?OrderStatusUpdateRequest
|
||||
{
|
||||
$orderArr = $this->app->DB->SelectRow("SELECT * FROM `auftrag` WHERE `id` = {$orderId} LIMIT 1");
|
||||
$status = $orderArr['status'];
|
||||
$zahlungsweise = $orderArr['zahlungsweise'];
|
||||
$shopextid = $orderArr['shopextid'];
|
||||
$internet = $orderArr['internet'];
|
||||
$deliveryNoteArr = $this->app->DB->SelectRow(
|
||||
"SELECT `id`, `versandart` FROM `lieferschein` WHERE `auftragid` = {$orderId} LIMIT 1"
|
||||
);
|
||||
$trackingArr = null;
|
||||
$versandart = '';
|
||||
$tracking = '';
|
||||
$shippingProduct = null;
|
||||
if(!empty($deliveryNoteArr)) {
|
||||
$deliveryNoteId = $deliveryNoteArr['id'];
|
||||
$versandart = $deliveryNoteArr['versandart'];
|
||||
$query =
|
||||
"SELECT *
|
||||
FROM `shopexport_versandarten`
|
||||
WHERE `aktiv`=1 AND `versandart_wawision` = '{$versandart}' AND `shop` = {$shopId} AND `versandart_wawision` <> ''
|
||||
LIMIT 1";
|
||||
$shippingMapping = $this->app->DB->SelectRow($query);
|
||||
$versandartAusgehend = $shippingMapping['versandart_ausgehend'] ?? null;
|
||||
$shippingProduct = $shippingMapping['produkt_ausgehend'] ?? null;
|
||||
$orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
|
||||
if (empty($orderArr))
|
||||
return null;
|
||||
|
||||
if(!empty($versandartAusgehend)){
|
||||
$versandart = $versandartAusgehend;
|
||||
}
|
||||
$trackingArr = $this->app->DB->SelectPairs(
|
||||
sprintf(
|
||||
"SELECT `id`, `tracking`
|
||||
FROM `versand`
|
||||
WHERE `lieferschein` = {$deliveryNoteId} AND `tracking` <> ''
|
||||
ORDER BY `id` DESC"
|
||||
)
|
||||
);
|
||||
$tracking = '';
|
||||
if(!empty($trackingArr)) {
|
||||
$tracking = reset($trackingArr);
|
||||
$data = new OrderStatusUpdateRequest();
|
||||
$data->orderId = $orderId;
|
||||
$data->shopOrderId = $orderArr['shopextid'];
|
||||
|
||||
$statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
|
||||
if (in_array('storniert', $statusArr))
|
||||
$data->orderStatus = OrderStatus::Cancelled;
|
||||
if (in_array('abgeschlossen', $statusArr))
|
||||
$data->orderStatus = OrderStatus::Completed;
|
||||
if (in_array('freigegeben', $statusArr))
|
||||
$data->orderStatus = OrderStatus::InProgress;
|
||||
if (in_array('angelegt', $statusArr))
|
||||
$data->orderStatus = OrderStatus::Imported;
|
||||
|
||||
$sql = "
|
||||
SELECT
|
||||
v.id,
|
||||
v.tracking,
|
||||
v.tracking_link,
|
||||
COALESCE(sv.versandart_ausgehend, sv.versandart_shop, v.versandart) versandart
|
||||
FROM
|
||||
auftrag a
|
||||
LEFT JOIN lieferschein l ON
|
||||
l.auftragid = a.id
|
||||
LEFT JOIN lieferschein_position lp ON
|
||||
lp.lieferschein = l.id
|
||||
LEFT JOIN versandpaket_lieferschein_position vlp ON
|
||||
vlp.lieferschein_position = lp.id
|
||||
LEFT JOIN versandpakete v ON
|
||||
vlp.versandpaket = v.id OR v.lieferschein_ohne_pos = l.id
|
||||
LEFT JOIN shopexport_versandarten sv ON
|
||||
sv.versandart_wawision = v.versandart AND sv.shop = $shopId
|
||||
WHERE a.id = $orderId OR a.teillieferungvon = $orderId
|
||||
ORDER BY v.id";
|
||||
|
||||
$shipments = $this->app->DB->SelectArr($sql);
|
||||
foreach ($shipments as $shipment) {
|
||||
$item = new Shipment();
|
||||
$item->id = $shipment['id'];
|
||||
$item->trackingNumber = $shipment['tracking'];
|
||||
$item->trackingUrl = $shipment['tracking_link'];
|
||||
$item->shippingMethod = $shipment['versandart'];
|
||||
$data->shipments[] = $item;
|
||||
}
|
||||
|
||||
$positionen = $this->app->DB->SelectArr(
|
||||
"SELECT ap.webid, trim(lp.geliefert)+0 AS `geliefert`, trim(lp.menge)+0 AS `menge`, lp.id
|
||||
FROM `lieferschein_position` AS `lp`
|
||||
INNER JOIN `lieferschein` AS `l` ON l.id = lp.lieferschein
|
||||
INNER JOIN `auftrag` AS `a` ON a.id = l.auftragid
|
||||
INNER JOIN `auftrag_position` AS `ap` ON ap.id = lp.auftrag_position_id
|
||||
WHERE l.id = {$deliveryNoteId} AND ap.webid <> '' "
|
||||
);
|
||||
$allPositions = false;
|
||||
if(!empty($positionen)) {
|
||||
$allPositions = true;
|
||||
foreach($positionen as $position) {
|
||||
if($position['geliefert'] > 0) {
|
||||
$itemlist[] = array('webid'=>$position['webid'],'quantity'=>$position['geliefert']);
|
||||
if($position['geliefert'] < $position['menge']) {
|
||||
$allPositions = false;
|
||||
}
|
||||
}
|
||||
elseif($this->app->DB->Select("SELECT trim(sum(geliefert))+0
|
||||
FROM lieferschein_position
|
||||
WHERE explodiert_parent = '".$position['id']."' AND lieferschein = '$deliveryNoteId'")) {
|
||||
$itemlist[] = array('webid'=>$position['webid'],'quantity'=>$position['menge']);
|
||||
}
|
||||
else {
|
||||
$allPositions = false;
|
||||
}
|
||||
}
|
||||
if($allPositions && (!empty($itemlist)?count($itemlist):0) <
|
||||
$this->app->DB->Select(
|
||||
sprintf('SELECT count(id) FROM auftrag_position WHERE auftrag = %d', $orderId)
|
||||
)
|
||||
) {
|
||||
$allPositions = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!empty($itemlist)) {
|
||||
$data['itemlist'] = $itemlist;
|
||||
if($allPositions) {
|
||||
$data['allpositions'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$data['orderId'] = $orderId;
|
||||
$data['auftrag'] = $shopextid;
|
||||
$data['internet'] = $internet;
|
||||
$data['zahlungsweise'] = $zahlungsweise;
|
||||
$data['versandart'] = $versandart;
|
||||
if(!empty($trackingArr)) {
|
||||
$data['trackinglist'] = $trackingArr;
|
||||
}
|
||||
if($status==='abgeschlossen') {
|
||||
$data['versand']='1';
|
||||
$data['zahlung']='1';
|
||||
if($shippingProduct !== null) {
|
||||
$data['shipping_product'] = $shippingProduct;
|
||||
}
|
||||
if($tracking!='') {
|
||||
$data['tracking']=$tracking;
|
||||
$lastShippingId = (int)$this->app->DB->Select(
|
||||
sprintf(
|
||||
"SELECT `id` FROM `versand` WHERE `lieferschein` = %d AND `lieferschein` > 0
|
||||
ORDER BY `id` DESC LIMIT 1",
|
||||
$deliveryNoteId
|
||||
)
|
||||
);
|
||||
$trackinglink = $lastShippingId > 0 && method_exists($this->app->erp,'GetTrackinglink')
|
||||
?$this->app->erp->GetTrackinglink($lastShippingId):'';
|
||||
if($trackinglink) {
|
||||
$data['trackinglink'] = $trackinglink;
|
||||
if(!empty($trackingArr)) {
|
||||
foreach($trackingArr as $versandId => $track) {
|
||||
$data['trackinglinklist'][$versandId] = $this->app->erp->GetTrackinglink($versandId);
|
||||
}
|
||||
}
|
||||
}
|
||||
$trackinglinkRaw = $lastShippingId > 0 && method_exists($this->app->erp,'GetTrackingRawLink')
|
||||
?$this->app->erp->GetTrackingRawLink($lastShippingId):'';
|
||||
if(!empty($trackinglinkRaw)) {
|
||||
$data['trackinglinkraw'] = $trackinglinkRaw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2438,9 +2367,10 @@ class Remote
|
||||
*/
|
||||
public function RemoteUpdateAuftrag($shopId, $orderId)
|
||||
{
|
||||
$data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
|
||||
if($data['versand']=='1' || $data['zahlung']=='1')
|
||||
{
|
||||
$data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
|
||||
if($data?->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
$bearbeiter = 'Cronjob';
|
||||
if(isset($this->app->User)){
|
||||
$bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
|
||||
@ -2465,7 +2395,6 @@ class Remote
|
||||
|
||||
$this->app->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
|
||||
$this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,9 @@
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
*/
|
||||
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
class Shopimporter_Presta extends ShopimporterBase
|
||||
{
|
||||
private $app;
|
||||
@ -161,18 +164,21 @@ class Shopimporter_Presta extends ShopimporterBase
|
||||
|
||||
public function ImportUpdateAuftrag()
|
||||
{
|
||||
$auftrag = $this->data['auftrag'];
|
||||
/** @var OrderStatusUpdateRequest $data */
|
||||
$data = $this->CatchRemoteCommand('data');
|
||||
if ($data->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
$obj = $this->prestaRequest('GET', 'order_histories?schema=blank');
|
||||
$obj->order_history->id_order = $auftrag;
|
||||
$obj->order_history->id_order = $data->shopOrderId;
|
||||
$obj->order_history->id_order_state = $this->idabgeschlossen;
|
||||
|
||||
$this->prestaRequest('POST', 'order_histories', $obj->asXML());
|
||||
|
||||
$req = $this->prestaRequest('GET', "order_carriers?filter[id_order]=$auftrag&display=[id]");
|
||||
$req = $this->prestaRequest('GET', "order_carriers?filter[id_order]=$data->shopOrderId&display=[id]");
|
||||
$orderCarrierId = strval($req->order_carriers->order_carrier[0]->id);
|
||||
$req = $this->prestaRequest('GET', "order_carriers/$orderCarrierId");
|
||||
$req->order_carrier->tracking_number = $this->data['tracking'];
|
||||
$req->order_carrier->tracking_number = join(',', $data->getTrackingNumberList());
|
||||
$this->prestaRequest('PUT', "order_carriers/$orderCarrierId", $req->asXML());
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
include_once 'Shopimporter_Shopify_Adapter.php';
|
||||
|
||||
@ -3381,17 +3383,21 @@ class Shopimporter_Shopify extends ShopimporterBase
|
||||
|
||||
public function ImportUpdateAuftrag()
|
||||
{
|
||||
$tmp = $this->CatchRemoteCommand('data');
|
||||
/** @var OrderStatusUpdateRequest $req */
|
||||
$req = $this->CatchRemoteCommand('data');
|
||||
if ($req->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
// pruefe ob $tmp[datei] vorhanden wenn nicht lege an sonst update [inhalt] und [checksum]
|
||||
$auftrag = $tmp['auftrag'];
|
||||
$auftrag = $req->shopOrderId;
|
||||
if(!empty($auftrag)){
|
||||
$zahlungok = $tmp['zahlung'];
|
||||
$versandok = $tmp['versand'];
|
||||
$tracking = $tmp['tracking'];
|
||||
$versandart = $tmp['versandart'];
|
||||
$data = array();
|
||||
$data['fulfillment'] = array('tracking_number' => $tracking, 'tracking_company' => $versandart, 'notify_customer' => false);
|
||||
$data['fulfillment'] = [
|
||||
'tracking_numbers' => $req->getTrackingNumberList(),
|
||||
'tracking_company' => $req->shipments[0]?->shippingMethod,
|
||||
'notify_customer' => false,
|
||||
'tracking_urls' => $req->getTrackingUrlList()
|
||||
];
|
||||
if(!empty($this->location)){
|
||||
$data['fulfillment']['location_id'] = $this->location;
|
||||
}
|
||||
@ -3410,16 +3416,10 @@ class Shopimporter_Shopify extends ShopimporterBase
|
||||
if($this->shopifytracking){
|
||||
$data['fulfillment']['notify_customer'] = true;
|
||||
}
|
||||
if(!empty($tmp['trackinglinkraw'])) {
|
||||
$data['fulfillment']['tracking_urls'] = [$tmp['trackinglinkraw']];
|
||||
}
|
||||
elseif(!empty($tmp['trackinglink'])){
|
||||
$data['fulfillment']['tracking_urls'] = [$tmp['trackinglink']];
|
||||
}
|
||||
|
||||
$result = $this->adapter->call('orders/' . $auftrag . '/fulfillments.json', 'POST', $data);
|
||||
if($this->logging){
|
||||
$this->app->erp->LogFile(array($tmp, $auftrag, $data, $result['data']));
|
||||
$this->app->erp->LogFile(array($data, $auftrag, $data, $result['data']));
|
||||
}
|
||||
$this->adapter->call('orders/' . $auftrag . '/metafields.json', 'POST', array('metafield' => [
|
||||
'key' => 'sync_status',
|
||||
@ -3429,7 +3429,7 @@ class Shopimporter_Shopify extends ShopimporterBase
|
||||
]));
|
||||
}else{
|
||||
if($this->logging){
|
||||
$this->app->erp->LogFile(array($tmp, $auftrag,'Kein Auftrag'));
|
||||
$this->app->erp->LogFile(array($data, $auftrag,'Kein Auftrag'));
|
||||
}
|
||||
}
|
||||
return 'OK';
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
@ -10,10 +10,12 @@
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
class Shopimporter_Shopware extends ShopimporterBase
|
||||
{
|
||||
@ -2520,38 +2522,19 @@ class Shopimporter_Shopware extends ShopimporterBase
|
||||
//TODO fuer AuftragImport
|
||||
public function ImportUpdateAuftrag()
|
||||
{
|
||||
$tmp = $this->CatchRemoteCommand('data');
|
||||
/** @var OrderStatusUpdateRequest $data */
|
||||
$data = $this->CatchRemoteCommand('data');
|
||||
if ($data->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
// pruefe ob $tmp[datei] vorhanden wenn nicht lege an sonst update [inhalt] und [checksum]
|
||||
$auftrag = $tmp['auftrag'];
|
||||
$zahlungok = $tmp['zahlung'];
|
||||
$versandok = $tmp['versand'];
|
||||
$tracking = $tmp['tracking'];
|
||||
$auftrag = $data->shopOrderId;
|
||||
|
||||
/*if($zahlungok=='ok' || $zahlungok=='1')
|
||||
$status_zahlung=12;
|
||||
else
|
||||
$status_zahlung=1;
|
||||
|
||||
if($versandok=='ok' || $versandok=='1')
|
||||
$status_versand=7;
|
||||
else
|
||||
$status_versand=1;*/
|
||||
/*
|
||||
$date = new DateTime();
|
||||
$date->modify('+10 days');
|
||||
$date = $date->format(DateTime::ISO8601);
|
||||
*/
|
||||
$result = $this->adapter->put('orders/'.$auftrag, array(
|
||||
// 'paymentStatusId' => $status_zahlung,
|
||||
'orderStatusId' => $this->abgeschlossenStatusId,//$status_versand,
|
||||
'trackingCode' => $tracking
|
||||
//'comment' => 'Neuer Kommentar',
|
||||
//'transactionId' => '0',
|
||||
// 'clearedDate' => $date,
|
||||
'orderStatusId' => $this->abgeschlossenStatusId,
|
||||
'trackingCode' => join(',', $data->getTrackingNumberList())
|
||||
));
|
||||
$this->ShopwareLog("Abschlussstatusrückmeldung für Auftrag: $auftrag", print_r($result,true));
|
||||
//$this->app->DB->Delete("DELETE FROM auftraege WHERE id='$auftrag' LIMIT 1");
|
||||
return 'ok';
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
<?php
|
||||
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
use Xentral\Modules\Shopware6\Client\Shopware6Client;
|
||||
use Xentral\Modules\Shopware6\Data\PriceData;
|
||||
|
||||
@ -3408,9 +3410,12 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
*/
|
||||
public function ImportUpdateAuftrag()
|
||||
{
|
||||
$tmp = $this->CatchRemoteCommand('data');
|
||||
$auftrag = $tmp['auftrag'];
|
||||
$tracking = $tmp['tracking'];
|
||||
/** @var OrderStatusUpdateRequest $data */
|
||||
$data = $this->CatchRemoteCommand('data');
|
||||
if ($data->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
$auftrag = $data->shopOrderId;
|
||||
|
||||
$this->shopwareRequest('POST', '_action/order/'.$auftrag.'/state/complete');
|
||||
|
||||
@ -3421,17 +3426,17 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
||||
$this->shopwareRequest('POST', '_action/order_delivery/'.$deliveryId.'/state/ship');
|
||||
|
||||
$deliveryData = [
|
||||
'trackingCodes' => [$tracking]
|
||||
'trackingCodes' => [$data->getTrackingNumberList()]
|
||||
];
|
||||
$this->shopwareRequest('PATCH', 'order-delivery/'.$deliveryId,$deliveryData);
|
||||
}
|
||||
|
||||
$this->sendInvoce($auftrag);
|
||||
$this->addCustomFieldToOrder((string)$auftrag);
|
||||
if(empty($tmp['orderId'])) {
|
||||
$this->addCustomFieldToOrder($auftrag);
|
||||
if(empty($data->orderId)) {
|
||||
return;
|
||||
}
|
||||
$this->updateStorageForOrderIntId((int)$tmp['orderId']);
|
||||
$this->updateStorageForOrderIntId($data->orderId);
|
||||
}
|
||||
|
||||
public function ImportStorniereAuftrag()
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
/*
|
||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*
|
||||
@ -10,10 +10,12 @@
|
||||
* to obtain the text of the corresponding license version.
|
||||
*
|
||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||
*/
|
||||
?>
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
use Xentral\Components\Http\JsonResponse;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||
|
||||
class Shopimporter_Woocommerce extends ShopimporterBase
|
||||
{
|
||||
@ -442,47 +444,35 @@ class Shopimporter_Woocommerce extends ShopimporterBase
|
||||
*/
|
||||
public function ImportUpdateAuftrag()
|
||||
{
|
||||
$tmp = $this->CatchRemoteCommand('data');
|
||||
/** @var OrderStatusUpdateRequest $data */
|
||||
$data = $this->CatchRemoteCommand('data');
|
||||
if ($data->orderStatus !== OrderStatus::Completed)
|
||||
return;
|
||||
|
||||
$orderId = $tmp['auftrag'];
|
||||
$paymentOk = $tmp['zahlung'];
|
||||
$shippingOk = $tmp['versand'];
|
||||
$trackingCode = $tmp['tracking'];
|
||||
$carrier = $tmp['versandart'];
|
||||
|
||||
if ($paymentOk === 'ok' || $paymentOk === '1'){
|
||||
$paymentOk = true;
|
||||
}
|
||||
|
||||
if ($shippingOk === 'ok' || $shippingOk === '1'){
|
||||
$shippingOk = true;
|
||||
}
|
||||
$trackingCode = $data->shipments[0]?->trackingNumber;
|
||||
|
||||
if (!empty($trackingCode)) {
|
||||
$this->client->post('orders/'.$orderId.'/notes', [
|
||||
$this->client->post('orders/'.$data->orderId.'/notes', [
|
||||
'note' => 'Tracking Code: ' . $trackingCode
|
||||
]);
|
||||
$this->WooCommerceLog("Tracking Code Rückmeldung für Auftrag: $orderId", $trackingCode);
|
||||
$this->WooCommerceLog("Tracking Code Rückmeldung für Auftrag: $data->orderId", $trackingCode);
|
||||
}
|
||||
|
||||
if ($paymentOk && $shippingOk) {
|
||||
$updateData = [
|
||||
'status' => $this->statusCompleted,
|
||||
'meta_data' => [
|
||||
[
|
||||
'key' => 'tracking_code',
|
||||
'value' => $trackingCode
|
||||
],
|
||||
[
|
||||
'key' => 'shipping_carrier',
|
||||
'value' => $carrier
|
||||
]
|
||||
$updateData = [
|
||||
'status' => $this->statusCompleted,
|
||||
'meta_data' => [
|
||||
[
|
||||
'key' => 'tracking_code',
|
||||
'value' => $data->shipments[0]?->trackingNumber
|
||||
],
|
||||
];
|
||||
$this->client->put('orders/'.$orderId, $updateData);
|
||||
$this->WooCommerceLog("Statusrückmeldung 'completed' für Auftrag: $orderId",$this->statusCompleted );
|
||||
}
|
||||
|
||||
[
|
||||
'key' => 'shipping_carrier',
|
||||
'value' => $data->shipments[0]?->shippingMethod
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->client->put('orders/'.$data->orderId, $updateData);
|
||||
$this->WooCommerceLog("Statusrückmeldung 'completed' für Auftrag: $data->orderId", $this->statusCompleted );
|
||||
|
||||
return 'ok';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user