From 1775f133365a3ce8d1b9baf4a7d6ff2356be9893 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 14 Dec 2025 18:17:38 +0300 Subject: [PATCH 1/6] fix pl update --- .../classes/general/RCrmActions.php | 2 + .../classes/general/user/RetailCrmUser.php | 44 +++++++++++++------ 2 files changed, 32 insertions(+), 14 deletions(-) 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..bb41c891 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,16 @@ public static function updateLoyaltyAccountIds(): bool 'UF_CARD_NUM_INTARO' => $cardNumber ]; - if ($updateUser->Update($user['ID'], $fields)) { + try { + if ($updateUser->Update($user['ID'], $fields)) { + Logger::getInstance()->write( + sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']), + 'loyaltyIdsUpdate' + ); + } + } catch (Throwable $exception) { Logger::getInstance()->write( - sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']), + sprintf('Ошибка обновления участия для пользователя с ID %s', $user['ID']), 'loyaltyIdsUpdate' ); } From 41f06e6534a6b91e84653988b65871f800171052 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 14 Dec 2025 18:25:02 +0300 Subject: [PATCH 2/6] bump --- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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..c3b45d14 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -2,5 +2,5 @@ $arModuleVersion = [ 'VERSION' => '6.7.6', - 'VERSION_DATE' => '2025-12-15 9:30:00' + 'VERSION_DATE' => '2025-12-14 9:30:00' ]; From 3aa352f4e5ac1887a0580aca0faf30c5b18abb24 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 15 Dec 2025 11:49:39 +0300 Subject: [PATCH 3/6] rebase --- .../classes/general/user/RetailCrmUser.php | 11 ++++++++++- intaro.retailcrm/install/version.php | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index bb41c891..c8e1705a 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -349,10 +349,19 @@ public static function updateLoyaltyAccountIds(): bool sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']), 'loyaltyIdsUpdate' ); + } else { + Logger::getInstance()->write( + 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/install/version.php b/intaro.retailcrm/install/version.php index c3b45d14..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-14 9:30:00' + 'VERSION' => '6.7.7', + 'VERSION_DATE' => '2025-12-15 12:30:00' ]; From 52b83dc56204be93153eecf0dd7ea9d8b17997e1 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 15 Dec 2025 11:52:39 +0300 Subject: [PATCH 4/6] bump --- intaro.retailcrm/lib/component/constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'; From eb7b77b70b3140faa8d9b485daaa9b0df6dab026 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 15 Dec 2025 11:54:00 +0300 Subject: [PATCH 5/6] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) 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 - Исправлена логика обработки скидок при использовании программы лояльности From f91274734f48f7aecbe0dcb18656db25a2d57c71 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 15 Dec 2025 13:15:54 +0300 Subject: [PATCH 6/6] thernat --- .../classes/general/user/RetailCrmUser.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index c8e1705a..b69a2bc5 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -344,17 +344,14 @@ public static function updateLoyaltyAccountIds(): bool ]; try { - if ($updateUser->Update($user['ID'], $fields)) { - Logger::getInstance()->write( - sprintf('Обновлен идентификатор участия ПЛ для пользователя с ID %s', $user['ID']), - 'loyaltyIdsUpdate' - ); - } else { - Logger::getInstance()->write( - sprintf('Не удалось обновить данные пользователя с ID %s', $user['ID']), - 'loyaltyIdsUpdate' - ); - } + $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(