diff --git a/CHANGELOG.md b/CHANGELOG.md index 4427cbac..6508f0ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2025-12-15 v6.7.7 +- Исправлена ошибка обновления ID участий в ПЛ + ## 2025-12-15 v6.7.6 - Исправлена логика обработки скидок при использовании программы лояльности diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index b19a6ad3..65516420 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -730,6 +730,8 @@ public static function apiMethod($api, $methodApi, $method, $params, $site = nul case 'cartSet': case 'cartClear': return self::proxy($api, $methodApi, $method, [$params, $site]); + case 'getLoyaltyAccounts': + return self::proxy($api, $methodApi, $method, [['filter' => $params], $site]); default: return self::proxy($api, $methodApi, $method, [$params, $site]); } diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index 28581211..b69a2bc5 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -310,18 +310,27 @@ public static function updateLoyaltyAccountIds(): bool $crmAccounts = RCrmActions::apiMethod($api, 'getLoyaltyAccounts', __METHOD__, $filter, $site); foreach ($crmAccounts['loyaltyAccounts'] as $crmAccount) { - $loyalty = $crmAccounts = RCrmActions::apiMethod( - $api, - 'getLoyaltyLoyalty', - __METHOD__, - $crmAccount['loyalty']['id'], - $site - ); - - if ($loyalty['loyalty']['active'] === true) { - $actualLoyalty = $crmAccount; - - break; + try { + $loyalty = RCrmActions::apiMethod( + $api, + 'getLoyaltyLoyalty', + __METHOD__, + $crmAccount['loyalty']['id'], + $site + ); + + if ($loyalty['loyalty']['active'] === true) { + $actualLoyalty = $crmAccount; + + break; + } + } catch (Throwable $exception) { + Logger::getInstance()->write( + sprintf('Ошибка получения участия в ПЛ пользователя с ID %s', $user['ID']), + 'loyaltyIdsUpdate' + ); + + continue; } } @@ -334,9 +343,22 @@ public static function updateLoyaltyAccountIds(): bool 'UF_CARD_NUM_INTARO' => $cardNumber ]; - if ($updateUser->Update($user['ID'], $fields)) { + try { + $result = $updateUser->Update($user['ID'], $fields); + + Logger::getInstance()->write( + $result + ? sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']) + : sprintf('Не удалось обновить данные пользователя с ID %s', $user['ID']), + 'loyaltyIdsUpdate' + ); + } catch (Throwable $exception) { Logger::getInstance()->write( - sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']), + sprintf( + 'Ошибка при обновлении участия для пользователя с ID %s. Подробнее: %s', + $user['ID'], + $exception->getMessage() + ), 'loyaltyIdsUpdate' ); } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 6b04d66d..99f5dfd4 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена логика обработки скидок при использовании программы лояльности +- Исправлена ошибка обновления ID участий в ПЛ diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index f1336c41..1f0819ac 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.7.6', - 'VERSION_DATE' => '2025-12-15 9:30:00' + 'VERSION' => '6.7.7', + 'VERSION_DATE' => '2025-12-15 12:30:00' ]; diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index e397785b..708799e5 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -18,7 +18,7 @@ */ class Constants { - public const MODULE_VERSION = '6.7.6'; + public const MODULE_VERSION = '6.7.7'; public const CRM_PURCHASE_PRICE_NULL = 'purchasePrice_null'; public const BITRIX_USER_ID_PREFIX = 'bitrixUserId-'; public const CRM_USERS_MAP = 'crm_users_map';