From e918317f6a8a5fdce5c8dfb231f3ed740193220c Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Wed, 13 Dec 2023 17:22:33 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#93307=20=D0=98=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=D0=BC=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=BE=D1=8F=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=B0?= =?UTF-8?q?=D0=B4=D0=BC=D0=B8=D0=BD=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=B8=D0=B7=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B7=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=20=D0=B2=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=B5=20(#327)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ .../general/order/RetailCrmOrder_v5.php | 8 +++--- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +-- .../lib/service/loyaltyaccountservice.php | 27 ++++++++++++------- 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dd94d1a..98b17f2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2023-12-13 v.6.4.13 +- Исправлена ошибка с получением данных программы лояльности администратора при изменении заказа в админке + ## 2023-12-12 v.6.4.12 - Исправлена критическая ошибка при переходе в настройки модуля diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 9a1f95f7..e5a80115 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -8,6 +8,7 @@ use Bitrix\Sale\Internals\Fields; use Bitrix\Sale\Internals\OrderTable; use Bitrix\Sale\Location\LocationTable; use Bitrix\Sale\Order; +use Intaro\RetailCrm\Component\ApiClient\ClientAdapter; use Intaro\RetailCrm\Component\Factory\ClientFactory; use Intaro\RetailCrm\Component\ServiceLocator; use Intaro\RetailCrm\Service\LoyaltyService; @@ -422,13 +423,14 @@ class RetailCrmOrder Logger::getInstance()->write($order, 'orderSend'); - /** @var \Intaro\RetailCrm\Component\ApiClient\ClientAdapter $client */ + /** @var ClientAdapter $client */ $client = ClientFactory::createClientAdapter(); + $userId = $arOrder['USER_ID']; + $arUser = UserTable::getById($userId)->fetch(); // Check and set privilegeType - $order['privilegeType'] = LoyaltyAccountService::getPrivilegeType($client, $arParams); + $order['privilegeType'] = LoyaltyAccountService::getPrivilegeType($client, $userId, $arParams); - $arUser = UserTable::getById($arOrder['USER_ID'])->fetch(); $fioCrm = [$order['firstName'] ?? null, $order['lastName'] ?? null, $order['patronymic'] ?? null]; if ($arUser['NAME'] !== '' && in_array($arUser['NAME'], $fioCrm)) { diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index da60ca69..e78f9750 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена критическая ошибка при переходе в настройки модуля +- Исправлена ошибка с получением данных программы лояльности администратора при изменении заказа в админке diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 984a8cae..5dffb772 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.12', - 'VERSION_DATE' => '2023-12-12 17:00:00' + 'VERSION' => '6.4.13', + 'VERSION_DATE' => '2023-12-13 17:00:00' ]; diff --git a/intaro.retailcrm/lib/service/loyaltyaccountservice.php b/intaro.retailcrm/lib/service/loyaltyaccountservice.php index dfa81a3a..c2d76f77 100644 --- a/intaro.retailcrm/lib/service/loyaltyaccountservice.php +++ b/intaro.retailcrm/lib/service/loyaltyaccountservice.php @@ -211,13 +211,19 @@ class LoyaltyAccountService /** * Возвращает статус пользователя в системе лояльности * + * @param $userId + * * @return bool */ - public static function getLoyaltyPersonalStatus(): bool + public static function getLoyaltyPersonalStatus($userId = null): bool { - global $USER; + if ($userId === null) { + global $USER; - $userFields = CUser::GetByID($USER->GetID())->Fetch(); + $userId = $USER->GetID(); + } + + $userFields = CUser::GetByID($userId)->Fetch(); return isset($userFields['UF_EXT_REG_PL_INTARO']) && $userFields['UF_EXT_REG_PL_INTARO'] === '1'; } @@ -225,13 +231,13 @@ class LoyaltyAccountService /** * Возвращает ID аккаунта в программе лояльности * + * @param $userId + * * @return int|null */ - public static function getLoyaltyAccountId(): ?int + public static function getLoyaltyAccountId($userId): ?int { - global $USER; - - $userFields = CUser::GetByID($USER->GetID())->Fetch(); + $userFields = CUser::GetByID($userId)->Fetch(); return $userFields['UF_LP_ID_INTARO'] ?? null; } @@ -244,18 +250,19 @@ class LoyaltyAccountService * 4. Программа лояльности деактивирована в CRM. * * @param $client + * @param $userId * @param array $arParams * * @return string */ - public static function getPrivilegeType($client, array $arParams = []): string + public static function getPrivilegeType($client, $userId, array $arParams = []): string { $file = 'loyaltyStatus'; $privilegeType = 'none'; if (!empty($arParams['customerCorporate']['privilegeType'])) { $privilegeType = $arParams['crmOrder']['privilegeType']; - } elseif (ConfigProvider::getLoyaltyProgramStatus() === 'Y' && self::getLoyaltyPersonalStatus()) { + } elseif (ConfigProvider::getLoyaltyProgramStatus() === 'Y' && self::getLoyaltyPersonalStatus($userId)) { $privilegeType = 'loyalty_level'; } @@ -267,7 +274,7 @@ class LoyaltyAccountService return 'none'; } - $loyaltyAccountId = self::getLoyaltyAccountId(); + $loyaltyAccountId = self::getLoyaltyAccountId($userId); if ($loyaltyAccountId === null) { Logger::getInstance()->write('Участие клиента не найдено', $file);