mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 20:17:14 +01:00
Merge pull request #133 from exciler/tracking_versandpakete
Tracking versandpakete
This commit is contained in:
commit
6fb17e9945
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 = '';
|
$join = '';
|
||||||
$where = '';
|
$where = '';
|
||||||
$app->erp->RunHook('shop_rueckmeldung', 2, $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
|
$sql = "SELECT DISTINCT a.id, a.shop
|
||||||
FROM auftrag AS a
|
FROM auftrag a
|
||||||
LEFT JOIN lieferschein AS l on l.auftragid = a.id
|
LEFT JOIN lieferschein 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 pr ON l.projekt = pr.id
|
||||||
LEFT JOIN projekt AS pr ON l.projekt = pr.id
|
LEFT JOIN lieferschein_position lp ON lp.lieferschein = l.id
|
||||||
LEFT JOIN versand AS v ON v.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
|
$join
|
||||||
WHERE a.status = 'abgeschlossen' AND $subwhere AND
|
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
|
a.shopextstatus <> 'abgeschlossen' AND a.shop > 0 AND
|
||||||
(
|
(
|
||||||
( v.tracking <> '' AND l.status = 'versendet') OR
|
( v.tracking <> '' AND l.status = 'versendet') OR
|
||||||
|
@ -15888,127 +15888,6 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
|
|||||||
$this->app->Tpl->Parse('PAGE','emptytab.tpl');
|
$this->app->Tpl->Parse('PAGE','emptytab.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function GetTrackingRawLink($id)
|
|
||||||
{
|
|
||||||
return $this->GetTrackinglink($id, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $id
|
|
||||||
* @param bool $returnRaw
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function GetTrackinglink($id, $returnRaw = false)
|
|
||||||
{
|
|
||||||
if($id > 0)
|
|
||||||
{
|
|
||||||
$versandarr = $this->app->DB->SelectRow("SELECT * FROM versand WHERE id='$id' LIMIT 1");
|
|
||||||
}
|
|
||||||
if(empty($versandarr))
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
$adresse = $versandarr['adresse'];
|
|
||||||
$lieferscheinid = $versandarr['lieferschein'];
|
|
||||||
if($lieferscheinid > 0){
|
|
||||||
$lieferscheinarr = $this->app->DB->SelectRow("SELECT auftragid,projekt FROM lieferschein WHERE id='$lieferscheinid' LIMIT 1");
|
|
||||||
}
|
|
||||||
if(!empty($lieferscheinarr))
|
|
||||||
{
|
|
||||||
$auftrag = $lieferscheinarr['auftragid'];
|
|
||||||
$projekt = $lieferscheinarr['projekt'];
|
|
||||||
}else{
|
|
||||||
$auftrag = 0;
|
|
||||||
$projekt = 0;
|
|
||||||
}
|
|
||||||
$auftragarr = $this->app->DB->SelectRow("SELECT belegnr,internet,ihrebestellnummer,DATE_FORMAT(datum,'%d.%m.%Y') as datum_de FROM auftrag WHERE id='$auftrag' LIMIT 1");
|
|
||||||
if(!empty($auftragarr)){
|
|
||||||
$auftragbelegnr = $auftragarr['belegnr'];
|
|
||||||
$auftraginternet = $auftragarr['internet'];
|
|
||||||
$ihrebestellnummer = $auftragarr['ihrebestellnummer'];
|
|
||||||
$auftragdatum = $auftragarr['datum_de'];
|
|
||||||
}else{
|
|
||||||
$auftragbelegnr = '';
|
|
||||||
$auftraginternet = '';
|
|
||||||
$ihrebestellnummer = '';
|
|
||||||
$auftragdatum = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tracking = $versandarr['tracking'];
|
|
||||||
$versandunternehmen = $versandarr['versandunternehmen'];
|
|
||||||
|
|
||||||
// FIX fuer selbstabholer Mail
|
|
||||||
$versandart = $versandarr['versandart'];
|
|
||||||
if($versandart=='selbstabholer') {
|
|
||||||
$versandunternehmen='selbstabholer';
|
|
||||||
}
|
|
||||||
|
|
||||||
if($versandunternehmen=='dhl' || $versandunternehmen=="dhlpremium" || $versandunternehmen=="intraship"){
|
|
||||||
$versandmodul = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$typ = $versandunternehmen;
|
|
||||||
if($typ === ''){
|
|
||||||
$typ = $versandart;
|
|
||||||
}
|
|
||||||
//$versandartenmodul = $this->app->DB->SelectArr("SELECT id, modul FROM versanddienstleister WHERE aktiv = 1 AND modul = '".$this->app->DB->real_escape_string($typ)."' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1");
|
|
||||||
$versandartenmodul = $this->app->DB->SelectArr("SELECT * FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND modul != '' AND type = '".$this->app->DB->real_escape_string($typ)."' AND modul != '' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1");
|
|
||||||
$standard = true;
|
|
||||||
if($versandartenmodul && @is_file(dirname(__FILE__).'/versandarten/'.$versandartenmodul[0]['modul'].'.php'))
|
|
||||||
{
|
|
||||||
$obj = $this->LoadVersandModul($versandartenmodul[0]['modul'], $versandartenmodul[0]['id']);
|
|
||||||
if(!empty($obj) && method_exists($obj, 'Trackinglink'))
|
|
||||||
{
|
|
||||||
if($obj->Trackinglink($tracking, $notsend, $link, $rawlink))
|
|
||||||
{
|
|
||||||
if($returnRaw) {
|
|
||||||
return $rawlink;
|
|
||||||
}
|
|
||||||
return $link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}elseif($versandartenmodul2 = $this->app->DB->SelectArr("SELECT * FROM versandarten WHERE aktiv = 1 AND ausprojekt = 0 AND type = '".$this->app->DB->real_escape_string($typ)."' AND (projekt = 0 OR projekt = '$projekt') ORDER BY projekt DESC LIMIT 1"))
|
|
||||||
{
|
|
||||||
$obj = $this->LoadVersandModul($versandartenmodul2[0]['modul'], $versandartenmodul2[0]['id']);
|
|
||||||
if(!empty($obj) && method_exists($obj, 'Trackinglink'))
|
|
||||||
{
|
|
||||||
if($obj->Trackinglink($tracking, $notsend, $link, $rawlink))
|
|
||||||
{
|
|
||||||
if($returnRaw) {
|
|
||||||
return $rawlink;
|
|
||||||
}
|
|
||||||
return $link;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!$versandmodul && $standard)
|
|
||||||
{
|
|
||||||
if($versandunternehmen=="dhl" || $versandunternehmen=="dhlpremium" || $versandunternehmen=="intraship")
|
|
||||||
{
|
|
||||||
return 'http://nolp.dhl.de/nextt-online-public/set_identcodes.do?lang=de&idc='.$tracking;
|
|
||||||
}
|
|
||||||
else if ($versandunternehmen=="logoix")
|
|
||||||
{
|
|
||||||
return 'http://www.logoix.com/cgi-bin/tnt.pl?q='.$tracking;
|
|
||||||
}
|
|
||||||
else if ($versandunternehmen=="dpd")
|
|
||||||
{
|
|
||||||
return 'https://tracking.dpd.de/parcelstatus/?locale=de_DE&query='.$tracking;
|
|
||||||
}
|
|
||||||
else if ($versandunternehmen=="gls")
|
|
||||||
{
|
|
||||||
return 'https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DE03/DE/5004.htm?txtRefNo='.$tracking;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $id
|
* @param int $id
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?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-FileCopyrightText: 2019 Xentral (c) Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg, Germany
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||||
@ -20,6 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?php
|
<?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;
|
use Xentral\Modules\Onlineshop\Data\ShopConnectorResponseInterface;
|
||||||
|
|
||||||
class Remote
|
class Remote
|
||||||
@ -2301,133 +2305,58 @@ class Remote
|
|||||||
return $result;
|
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");
|
$orderArr = $this->app->DB->SelectRow("SELECT `zahlungsweise`, `shopextid` FROM `auftrag` WHERE `id` = $orderId LIMIT 1");
|
||||||
$status = $orderArr['status'];
|
if (empty($orderArr))
|
||||||
$zahlungsweise = $orderArr['zahlungsweise'];
|
return null;
|
||||||
$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;
|
|
||||||
|
|
||||||
if(!empty($versandartAusgehend)){
|
$data = new OrderStatusUpdateRequest();
|
||||||
$versandart = $versandartAusgehend;
|
$data->orderId = $orderId;
|
||||||
}
|
$data->shopOrderId = $orderArr['shopextid'];
|
||||||
$trackingArr = $this->app->DB->SelectPairs(
|
|
||||||
sprintf(
|
$statusArr = $this->app->DB->SelectFirstCols("SELECT DISTINCT status FROM auftrag WHERE id = $orderId OR teillieferungvon = $orderId");
|
||||||
"SELECT `id`, `tracking`
|
if (in_array('storniert', $statusArr))
|
||||||
FROM `versand`
|
$data->orderStatus = OrderStatus::Cancelled;
|
||||||
WHERE `lieferschein` = {$deliveryNoteId} AND `tracking` <> ''
|
if (in_array('abgeschlossen', $statusArr))
|
||||||
ORDER BY `id` DESC"
|
$data->orderStatus = OrderStatus::Completed;
|
||||||
)
|
if (in_array('freigegeben', $statusArr))
|
||||||
);
|
$data->orderStatus = OrderStatus::InProgress;
|
||||||
$tracking = '';
|
if (in_array('angelegt', $statusArr))
|
||||||
if(!empty($trackingArr)) {
|
$data->orderStatus = OrderStatus::Imported;
|
||||||
$tracking = reset($trackingArr);
|
|
||||||
|
$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(
|
return $data;
|
||||||
"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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2438,9 +2367,10 @@ class Remote
|
|||||||
*/
|
*/
|
||||||
public function RemoteUpdateAuftrag($shopId, $orderId)
|
public function RemoteUpdateAuftrag($shopId, $orderId)
|
||||||
{
|
{
|
||||||
$data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
|
$data = $this->getDataToSendForUpdateOrder((int)$shopId, (int)$orderId);
|
||||||
if($data['versand']=='1' || $data['zahlung']=='1')
|
if($data?->orderStatus !== OrderStatus::Completed)
|
||||||
{
|
return;
|
||||||
|
|
||||||
$bearbeiter = 'Cronjob';
|
$bearbeiter = 'Cronjob';
|
||||||
if(isset($this->app->User)){
|
if(isset($this->app->User)){
|
||||||
$bearbeiter = $this->app->DB->real_escape_string($this->app->User->GetName());
|
$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->erp->AuftragProtokoll($orderId, 'Versandmeldung an Shop übertragen', $bearbeiter);
|
||||||
$this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
|
$this->app->DB->Update("UPDATE `auftrag` SET `shopextstatus` = 'abgeschlossen' WHERE `id` = $orderId LIMIT 1");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,12 +6,15 @@
|
|||||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||||
|
|
||||||
class Shopimporter_Presta extends ShopimporterBase
|
class Shopimporter_Presta extends ShopimporterBase
|
||||||
{
|
{
|
||||||
private $app;
|
private $app;
|
||||||
private $intern;
|
private $intern;
|
||||||
private $shopid;
|
private $shopid;
|
||||||
private $data;
|
var $data;
|
||||||
private $protocol;
|
private $protocol;
|
||||||
private $apiKey;
|
private $apiKey;
|
||||||
private $shopUrl;
|
private $shopUrl;
|
||||||
@ -161,18 +164,21 @@ class Shopimporter_Presta extends ShopimporterBase
|
|||||||
|
|
||||||
public function ImportUpdateAuftrag()
|
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 = $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;
|
$obj->order_history->id_order_state = $this->idabgeschlossen;
|
||||||
|
|
||||||
$this->prestaRequest('POST', 'order_histories', $obj->asXML());
|
$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);
|
$orderCarrierId = strval($req->order_carriers->order_carrier[0]->id);
|
||||||
$req = $this->prestaRequest('GET', "order_carriers/$orderCarrierId");
|
$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());
|
$this->prestaRequest('PUT', "order_carriers/$orderCarrierId", $req->asXML());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
use Xentral\Components\Http\JsonResponse;
|
use Xentral\Components\Http\JsonResponse;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||||
|
|
||||||
include_once 'Shopimporter_Shopify_Adapter.php';
|
include_once 'Shopimporter_Shopify_Adapter.php';
|
||||||
|
|
||||||
@ -3381,17 +3383,21 @@ class Shopimporter_Shopify extends ShopimporterBase
|
|||||||
|
|
||||||
public function ImportUpdateAuftrag()
|
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]
|
// pruefe ob $tmp[datei] vorhanden wenn nicht lege an sonst update [inhalt] und [checksum]
|
||||||
$auftrag = $tmp['auftrag'];
|
$auftrag = $req->shopOrderId;
|
||||||
if(!empty($auftrag)){
|
if(!empty($auftrag)){
|
||||||
$zahlungok = $tmp['zahlung'];
|
|
||||||
$versandok = $tmp['versand'];
|
|
||||||
$tracking = $tmp['tracking'];
|
|
||||||
$versandart = $tmp['versandart'];
|
|
||||||
$data = array();
|
$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)){
|
if(!empty($this->location)){
|
||||||
$data['fulfillment']['location_id'] = $this->location;
|
$data['fulfillment']['location_id'] = $this->location;
|
||||||
}
|
}
|
||||||
@ -3410,16 +3416,10 @@ class Shopimporter_Shopify extends ShopimporterBase
|
|||||||
if($this->shopifytracking){
|
if($this->shopifytracking){
|
||||||
$data['fulfillment']['notify_customer'] = true;
|
$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);
|
$result = $this->adapter->call('orders/' . $auftrag . '/fulfillments.json', 'POST', $data);
|
||||||
if($this->logging){
|
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' => [
|
$this->adapter->call('orders/' . $auftrag . '/metafields.json', 'POST', array('metafield' => [
|
||||||
'key' => 'sync_status',
|
'key' => 'sync_status',
|
||||||
@ -3429,7 +3429,7 @@ class Shopimporter_Shopify extends ShopimporterBase
|
|||||||
]));
|
]));
|
||||||
}else{
|
}else{
|
||||||
if($this->logging){
|
if($this->logging){
|
||||||
$this->app->erp->LogFile(array($tmp, $auftrag,'Kein Auftrag'));
|
$this->app->erp->LogFile(array($data, $auftrag,'Kein Auftrag'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 'OK';
|
return 'OK';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||||
*
|
*
|
||||||
@ -10,10 +10,12 @@
|
|||||||
* to obtain the text of the corresponding license version.
|
* to obtain the text of the corresponding license version.
|
||||||
*
|
*
|
||||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
use Xentral\Components\Http\JsonResponse;
|
use Xentral\Components\Http\JsonResponse;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||||
|
|
||||||
class Shopimporter_Shopware extends ShopimporterBase
|
class Shopimporter_Shopware extends ShopimporterBase
|
||||||
{
|
{
|
||||||
@ -2520,38 +2522,19 @@ class Shopimporter_Shopware extends ShopimporterBase
|
|||||||
//TODO fuer AuftragImport
|
//TODO fuer AuftragImport
|
||||||
public function ImportUpdateAuftrag()
|
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]
|
// pruefe ob $tmp[datei] vorhanden wenn nicht lege an sonst update [inhalt] und [checksum]
|
||||||
$auftrag = $tmp['auftrag'];
|
$auftrag = $data->shopOrderId;
|
||||||
$zahlungok = $tmp['zahlung'];
|
|
||||||
$versandok = $tmp['versand'];
|
|
||||||
$tracking = $tmp['tracking'];
|
|
||||||
|
|
||||||
/*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(
|
$result = $this->adapter->put('orders/'.$auftrag, array(
|
||||||
// 'paymentStatusId' => $status_zahlung,
|
'orderStatusId' => $this->abgeschlossenStatusId,
|
||||||
'orderStatusId' => $this->abgeschlossenStatusId,//$status_versand,
|
'trackingCode' => join(',', $data->getTrackingNumberList())
|
||||||
'trackingCode' => $tracking
|
|
||||||
//'comment' => 'Neuer Kommentar',
|
|
||||||
//'transactionId' => '0',
|
|
||||||
// 'clearedDate' => $date,
|
|
||||||
));
|
));
|
||||||
$this->ShopwareLog("Abschlussstatusrückmeldung für Auftrag: $auftrag", print_r($result,true));
|
$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';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Xentral\Components\Http\JsonResponse;
|
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\Client\Shopware6Client;
|
||||||
use Xentral\Modules\Shopware6\Data\PriceData;
|
use Xentral\Modules\Shopware6\Data\PriceData;
|
||||||
|
|
||||||
@ -3408,9 +3410,12 @@ class Shopimporter_Shopware6 extends ShopimporterBase
|
|||||||
*/
|
*/
|
||||||
public function ImportUpdateAuftrag()
|
public function ImportUpdateAuftrag()
|
||||||
{
|
{
|
||||||
$tmp = $this->CatchRemoteCommand('data');
|
/** @var OrderStatusUpdateRequest $data */
|
||||||
$auftrag = $tmp['auftrag'];
|
$data = $this->CatchRemoteCommand('data');
|
||||||
$tracking = $tmp['tracking'];
|
if ($data->orderStatus !== OrderStatus::Completed)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$auftrag = $data->shopOrderId;
|
||||||
|
|
||||||
$this->shopwareRequest('POST', '_action/order/'.$auftrag.'/state/complete');
|
$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');
|
$this->shopwareRequest('POST', '_action/order_delivery/'.$deliveryId.'/state/ship');
|
||||||
|
|
||||||
$deliveryData = [
|
$deliveryData = [
|
||||||
'trackingCodes' => [$tracking]
|
'trackingCodes' => [$data->getTrackingNumberList()]
|
||||||
];
|
];
|
||||||
$this->shopwareRequest('PATCH', 'order-delivery/'.$deliveryId,$deliveryData);
|
$this->shopwareRequest('PATCH', 'order-delivery/'.$deliveryId,$deliveryData);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendInvoce($auftrag);
|
$this->sendInvoce($auftrag);
|
||||||
$this->addCustomFieldToOrder((string)$auftrag);
|
$this->addCustomFieldToOrder($auftrag);
|
||||||
if(empty($tmp['orderId'])) {
|
if(empty($data->orderId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->updateStorageForOrderIntId((int)$tmp['orderId']);
|
$this->updateStorageForOrderIntId($data->orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ImportStorniereAuftrag()
|
public function ImportStorniereAuftrag()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||||
*
|
*
|
||||||
@ -10,10 +10,12 @@
|
|||||||
* to obtain the text of the corresponding license version.
|
* to obtain the text of the corresponding license version.
|
||||||
*
|
*
|
||||||
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
use Xentral\Components\Http\JsonResponse;
|
use Xentral\Components\Http\JsonResponse;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatus;
|
||||||
|
use Xentral\Modules\Onlineshop\Data\OrderStatusUpdateRequest;
|
||||||
|
|
||||||
class Shopimporter_Woocommerce extends ShopimporterBase
|
class Shopimporter_Woocommerce extends ShopimporterBase
|
||||||
{
|
{
|
||||||
@ -442,47 +444,35 @@ class Shopimporter_Woocommerce extends ShopimporterBase
|
|||||||
*/
|
*/
|
||||||
public function ImportUpdateAuftrag()
|
public function ImportUpdateAuftrag()
|
||||||
{
|
{
|
||||||
$tmp = $this->CatchRemoteCommand('data');
|
/** @var OrderStatusUpdateRequest $data */
|
||||||
|
$data = $this->CatchRemoteCommand('data');
|
||||||
|
if ($data->orderStatus !== OrderStatus::Completed)
|
||||||
|
return;
|
||||||
|
|
||||||
$orderId = $tmp['auftrag'];
|
$trackingCode = $data->shipments[0]?->trackingNumber;
|
||||||
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($trackingCode)) {
|
if (!empty($trackingCode)) {
|
||||||
$this->client->post('orders/'.$orderId.'/notes', [
|
$this->client->post('orders/'.$data->orderId.'/notes', [
|
||||||
'note' => 'Tracking Code: ' . $trackingCode
|
'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 = [
|
||||||
$updateData = [
|
'status' => $this->statusCompleted,
|
||||||
'status' => $this->statusCompleted,
|
'meta_data' => [
|
||||||
'meta_data' => [
|
[
|
||||||
[
|
'key' => 'tracking_code',
|
||||||
'key' => 'tracking_code',
|
'value' => $data->shipments[0]?->trackingNumber
|
||||||
'value' => $trackingCode
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'key' => 'shipping_carrier',
|
|
||||||
'value' => $carrier
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
];
|
[
|
||||||
$this->client->put('orders/'.$orderId, $updateData);
|
'key' => 'shipping_carrier',
|
||||||
$this->WooCommerceLog("Statusrückmeldung 'completed' für Auftrag: $orderId",$this->statusCompleted );
|
'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';
|
return 'ok';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user