add PRICE_DELIVERY for history exchange
This commit is contained in:
parent
a1d6e00d18
commit
34d9d6d576
@ -532,7 +532,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = self::getSite($order['site']);
|
$site = self::getSite($order['site']);
|
||||||
|
|
||||||
if (null === $site) {
|
if (null === $site) {
|
||||||
@ -1229,7 +1229,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $shopCode
|
* @param string $shopCode
|
||||||
*
|
*
|
||||||
@ -1238,18 +1238,18 @@ class RetailCrmHistory
|
|||||||
public static function getSite(string $shopCode): ?string
|
public static function getSite(string $shopCode): ?string
|
||||||
{
|
{
|
||||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||||
|
|
||||||
if ($optionsSitesList) {
|
if ($optionsSitesList) {
|
||||||
$searchResult = array_search($shopCode, $optionsSitesList, true);
|
$searchResult = array_search($shopCode, $optionsSitesList, true);
|
||||||
|
|
||||||
return is_string($searchResult) ? $searchResult : null;
|
return is_string($searchResult) ? $searchResult : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultSite = CSite::GetDefSite();
|
$defaultSite = CSite::GetDefSite();
|
||||||
|
|
||||||
return is_string($defaultSite) ? $defaultSite : null;
|
return is_string($defaultSite) ? $defaultSite : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $array
|
* @param $array
|
||||||
* @param $value
|
* @param $value
|
||||||
@ -1493,7 +1493,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters out history by these terms:
|
* Filters out history by these terms:
|
||||||
* - Changes from current API key will be added only if CMS changes are more actual than history.
|
* - Changes from current API key will be added only if CMS changes are more actual than history.
|
||||||
@ -1512,7 +1512,7 @@ class RetailCrmHistory
|
|||||||
$history = [];
|
$history = [];
|
||||||
$organizedHistory = [];
|
$organizedHistory = [];
|
||||||
$notOurChanges = [];
|
$notOurChanges = [];
|
||||||
|
|
||||||
foreach ($historyEntries as $entry) {
|
foreach ($historyEntries as $entry) {
|
||||||
if (!isset($entry[$recordType]['externalId'])) {
|
if (!isset($entry[$recordType]['externalId'])) {
|
||||||
if ($entry['source'] == 'api'
|
if ($entry['source'] == 'api'
|
||||||
@ -1522,23 +1522,23 @@ class RetailCrmHistory
|
|||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$history[] = $entry;
|
$history[] = $entry;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$externalId = $entry[$recordType]['externalId'];
|
$externalId = $entry[$recordType]['externalId'];
|
||||||
$field = $entry['field'];
|
$field = $entry['field'];
|
||||||
|
|
||||||
if (!isset($organizedHistory[$externalId])) {
|
if (!isset($organizedHistory[$externalId])) {
|
||||||
$organizedHistory[$externalId] = [];
|
$organizedHistory[$externalId] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($notOurChanges[$externalId])) {
|
if (!isset($notOurChanges[$externalId])) {
|
||||||
$notOurChanges[$externalId] = [];
|
$notOurChanges[$externalId] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entry['source'] == 'api'
|
if ($entry['source'] == 'api'
|
||||||
&& isset($entry['apiKey']['current'])
|
&& isset($entry['apiKey']['current'])
|
||||||
&& $entry['apiKey']['current'] == true
|
&& $entry['apiKey']['current'] == true
|
||||||
@ -1553,16 +1553,16 @@ class RetailCrmHistory
|
|||||||
$notOurChanges[$externalId][$field] = true;
|
$notOurChanges[$externalId][$field] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($notOurChanges);
|
unset($notOurChanges);
|
||||||
|
|
||||||
foreach ($organizedHistory as $historyChunk) {
|
foreach ($organizedHistory as $historyChunk) {
|
||||||
$history = array_merge($history, $historyChunk);
|
$history = array_merge($history, $historyChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $history;
|
return $history;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update shipment in order
|
* Update shipment in order
|
||||||
*
|
*
|
||||||
@ -1625,22 +1625,24 @@ class RetailCrmHistory
|
|||||||
if ($delivery) {
|
if ($delivery) {
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
$shipment = $shipmentColl->createItem($delivery);
|
$shipment = $shipmentColl->createItem($delivery);
|
||||||
$shipment->setFields(array(
|
$shipment->setFields([
|
||||||
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
||||||
'CURRENCY' => $order->getCurrency(),
|
'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
||||||
'DELIVERY_NAME' => $delivery->getName(),
|
'CURRENCY' => $order->getCurrency(),
|
||||||
|
'DELIVERY_NAME' => $delivery->getName(),
|
||||||
'CUSTOM_PRICE_DELIVERY' => 'Y'
|
'CUSTOM_PRICE_DELIVERY' => 'Y'
|
||||||
));
|
]);
|
||||||
} else {
|
} else {
|
||||||
foreach ($shipmentColl as $shipment) {
|
foreach ($shipmentColl as $shipment) {
|
||||||
if (!$shipment->isSystem()) {
|
if (!$shipment->isSystem()) {
|
||||||
$shipment->setFields(array(
|
$shipment->setFields([
|
||||||
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
||||||
'CURRENCY' => $order->getCurrency(),
|
'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
|
||||||
'DELIVERY_ID' => $deliveryId,
|
'CURRENCY' => $order->getCurrency(),
|
||||||
'DELIVERY_NAME' => $delivery->getName(),
|
'DELIVERY_ID' => $deliveryId,
|
||||||
|
'DELIVERY_NAME' => $delivery->getName(),
|
||||||
'CUSTOM_PRICE_DELIVERY' => 'Y'
|
'CUSTOM_PRICE_DELIVERY' => 'Y'
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user