From 1355fac2f2a4fd52058cc1ed1c0f1904114bdbf0 Mon Sep 17 00:00:00 2001 From: Ivan Chaplygin Date: Wed, 23 Aug 2023 12:23:41 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#89535=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D1=87=D0=B8=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BE=D1=80=D0=BF=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BB=D0=B8?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=9B=D0=BE=D0=B3=D0=B8=20?= =?UTF-8?q?=D0=BF=D0=BE=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8E=20=D0=BA=D0=BE=D1=80=D0=B7=D0=B8=D0=BD=20=D0=BF=D0=BE=20?= =?UTF-8?q?=D0=B0=D0=BF=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B2=20=D0=BB=D0=BE=D0=B3=D0=B8=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ .../classes/general/RCrmActions.php | 10 ++++++++- .../general/order/RetailCrmOrder_v5.php | 22 ++++++++++++++++--- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 ++-- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b505f95..f04a2f8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-08-23 v.6.4.2 +- Исправлена работы корзин с корпоративными клиентами + ## 2023-08-22 v.6.4.1 - Исправлена передача даты регистрации клиента diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index 8b45346a..6c31d492 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -546,13 +546,21 @@ class RCrmActions 'errors' => !empty($result['errors']) ? $result['errors'] : '', 'params' => $params ), 'uploadApiErrors'); + } elseif ($methodApi == 'cartGet') { + Logger::getInstance()->write(array( + 'api' => $version, + 'methodApi' => $methodApi, + 'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '', + 'errors' => !empty($result['errors']) ? $result['errors'] : '', + 'params' => $params, + ), 'apiErrors'); } else { - self::eventLog( __CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi, !empty($result['errorMsg']) ? $result['errorMsg'] : '' ); + Logger::getInstance()->write(array( 'api' => $version, 'methodApi' => $methodApi, diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 05525ec4..343214ea 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -17,6 +17,7 @@ use Intaro\RetailCrm\Service\LoyaltyAccountService; use RetailCrm\Response\ApiResponse; use \Bitrix\Sale\Location\Name\LocationTable as LocationTableName; use Intaro\RetailCrm\Component\ConfigProvider; +use Intaro\RetailCrm\Model\Api\Response\OrdersCreateResponse; IncludeModuleLangFile(__FILE__); @@ -439,12 +440,27 @@ class RetailCrmOrder } $crmBasket = RCrmActions::apiMethod($api, 'cartGet', __METHOD__, $externalId, $site); + $orderResponse = $client->createOrder($order, $site); - if (!empty($crmBasket['cart'])) { - $order['isFromCart'] = true; + if (!empty($crmBasket['cart']) && $orderResponse instanceof OrdersCreateResponse && !empty($orderResponse->id) ) { + RCrmActions::apiMethod( + $api, + 'cartClear', + __METHOD__, + [ + 'clearedAt' => date('Y-m-d H:i:sP'), + 'customer' => [ + 'externalId' => $externalId + ], + 'order' => [ + 'id' => $orderResponse->id + ] + ], + $site + ); } - return $client->createOrder($order, $site); + return $orderResponse; } if ($methodApi === 'ordersEdit') { diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index ec98d01d..0a5a2953 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена передача даты регистрации клиента \ No newline at end of file +- Исправлена работы корзин с корпоративными клиентами diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index f76c8911..5c2eee18 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.1', - 'VERSION_DATE' => '2023-08-22 9:30:00' + 'VERSION' => '6.4.2', + 'VERSION_DATE' => '2023-08-23 12:30:00' ];