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);