From 992162c01e4c46cdfe23d87208145156f1cb5e53 Mon Sep 17 00:00:00 2001 From: Uryvskiy Dima Date: Tue, 12 Dec 2023 16:51:15 +0300 Subject: [PATCH] =?UTF-8?q?ref=20#93434=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=BA=D1=80=D0=B8=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B5=20=D0=B2=20=D0=BD=D0=B0=D1=81=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B9=D0=BA=D0=B8=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB?= =?UTF-8?q?=D1=8F=20(#326)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +- .../classes/general/RCrmActions.php | 134 ++++++++---------- .../general/history/RetailCrmHistory_v5.php | 1 - .../general/order/RetailCrmOrder_v5.php | 4 +- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/index.php | 84 +++++------ intaro.retailcrm/install/version.php | 4 +- intaro.retailcrm/lang/en/install/index.php | 1 + intaro.retailcrm/lang/en/install/step1.php | 2 + intaro.retailcrm/lang/en/install/step11.php | 2 + intaro.retailcrm/lang/en/options.php | 5 +- intaro.retailcrm/lang/ru/install/index.php | 1 + intaro.retailcrm/lang/ru/install/step1.php | 3 +- intaro.retailcrm/lang/ru/install/step11.php | 4 +- intaro.retailcrm/lang/ru/options.php | 3 + intaro.retailcrm/lib/component/constants.php | 1 - .../lib/service/currencyservice.php | 22 +++ intaro.retailcrm/options.php | 44 +++--- tests/lib/service/CurrencyServiceTest.php | 17 +++ 19 files changed, 186 insertions(+), 153 deletions(-) create mode 100644 intaro.retailcrm/lib/service/currencyservice.php create mode 100644 tests/lib/service/CurrencyServiceTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f98d2450..6dd94d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ -## 2023-10-25 v.6.4.11 +## 2023-12-12 v.6.4.12 +- Исправлена критическая ошибка при переходе в настройки модуля + +## 2023-12-08 v.6.4.11 - Исправлена ошибка при передаче подписки на рекламно-информационные рассылки ## 2023-10-25 v.6.4.10 diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index f96fc76e..3667acc2 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -1,13 +1,16 @@ Query( - "SELECT DISTINCT site.SMN_SITE_ID, hook_data.VALUE - FROM `b_landing_site` site - LEFT JOIN `b_landing_hook_data` hook_data on site.ID = hook_data.ENTITY_ID - WHERE site.SMN_SITE_ID IN ('" . implode("', '", $sitesLID) . "') - AND hook_data.CODE = 'CURRENCY_ID'; - " - ); - - while ($currencySite = $currencies->Fetch()) { - if (!empty($currencySite['SMN_SITE_ID'])) { - $sitesCurrency[$currencySite['SMN_SITE_ID']] = $currencySite['VALUE']; - } + $sitesCurrency[$site['LID']] = !empty($siteCurrency['CURRENCY']) + ? $siteCurrency['CURRENCY'] + : $baseCurrency; } return $sitesCurrency; @@ -68,17 +57,21 @@ class RCrmActions public static function OrderTypesList($arSites) { - $orderTypesList = array(); + $orderTypesList = []; + foreach ($arSites as $site) { - $personTypes = \Bitrix\Sale\PersonType::load($site['LID']); - $bitrixOrderTypesList = array(); + $personTypes = PersonType::load($site['LID']); + $bitrixOrderTypesList = []; + foreach ($personTypes as $personType) { if (!array_key_exists($personType['ID'], $orderTypesList)) { $bitrixOrderTypesList[$personType['ID']] = $personType; } + asort($bitrixOrderTypesList); } - $orderTypesList = $orderTypesList + $bitrixOrderTypesList; + + $orderTypesList += $bitrixOrderTypesList; } return $orderTypesList; @@ -86,10 +79,11 @@ class RCrmActions public static function DeliveryList() { - $bitrixDeliveryTypesList = array(); + $bitrixDeliveryTypesList = []; $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); $noOrderId = EmptyDeliveryService::getEmptyDeliveryServiceId(); - $groups = array(); + $groups = []; + foreach ($arDeliveryServiceAll as $arDeliveryService) { if ($arDeliveryService['CLASS_NAME'] == '\Bitrix\Sale\Delivery\Services\Group') { $groups[] = $arDeliveryService['ID']; @@ -112,11 +106,9 @@ class RCrmActions public static function PaymentList() { - $bitrixPaymentTypesList = array(); - $dbPaymentAll = Manager::getList(array( - 'select' => array('ID', 'NAME'), - 'filter' => array('ACTIVE' => 'Y') - )); + $bitrixPaymentTypesList = []; + $dbPaymentAll = Manager::getList(['select' => ['ID', 'NAME'], 'filter' => ['ACTIVE' => 'Y']]); + while ($payment = $dbPaymentAll->fetch()) { $bitrixPaymentTypesList[] = $payment; } @@ -126,16 +118,14 @@ class RCrmActions public static function StatusesList() { - $bitrixPaymentStatusesList = array(); - $obStatuses = StatusTable::getList(array( - 'filter' => array('TYPE' => 'O', '=Bitrix\Sale\Internals\StatusLangTable:STATUS.LID' => LANGUAGE_ID), - 'select' => array('ID', 'NAME' => 'Bitrix\Sale\Internals\StatusLangTable:STATUS.NAME') - )); + $bitrixPaymentStatusesList = []; + $obStatuses = StatusTable::getList([ + 'filter' => ['TYPE' => 'O', '=Bitrix\Sale\Internals\StatusLangTable:STATUS.LID' => LANGUAGE_ID], + 'select' => ['ID', 'NAME' => 'Bitrix\Sale\Internals\StatusLangTable:STATUS.NAME'], + ]); + while ($arStatus = $obStatuses->fetch()) { - $bitrixPaymentStatusesList[$arStatus['ID']] = array( - 'ID' => $arStatus['ID'], - 'NAME' => $arStatus['NAME'], - ); + $bitrixPaymentStatusesList[$arStatus['ID']] = ['ID' => $arStatus['ID'], 'NAME' => $arStatus['NAME']]; } return $bitrixPaymentStatusesList; @@ -143,11 +133,9 @@ class RCrmActions public static function OrderPropsList() { - $bitrixPropsList = array(); - $arPropsAll = OrderPropsTable::getList(array( - 'select' => array('*'), - 'filter' => array('CODE' => '_%') - )); + $bitrixPropsList = []; + $arPropsAll = OrderPropsTable::getList(['select' => ['*'], 'filter' => ['CODE' => '_%']]); + while ($prop = $arPropsAll->Fetch()) { $bitrixPropsList[$prop['PERSON_TYPE_ID']][] = $prop; } @@ -157,14 +145,8 @@ class RCrmActions public static function PricesExportList() { - $catalogExportPrices = array(); - $dbPriceType = CCatalogGroup::GetList( - array(), - array(), - false, - false, - array('ID', 'NAME', 'NAME_LANG') - ); + $catalogExportPrices = []; + $dbPriceType = CCatalogGroup::GetList([], [], false, false, ['ID', 'NAME', 'NAME_LANG']); while ($arPriceType = $dbPriceType->Fetch()) { @@ -176,8 +158,9 @@ class RCrmActions public static function StoresExportList() { - $catalogExportStores = array(); - $dbStores = CCatalogStore::GetList(array(), array('ACTIVE' => 'Y'), false, false, array('ID', 'TITLE')); + $catalogExportStores = []; + $dbStores = CCatalogStore::GetList([], ['ACTIVE' => 'Y'], false, false, ['ID', 'TITLE']); + while ($stores = $dbStores->Fetch()) { $catalogExportStores[] = $stores; } @@ -187,18 +170,19 @@ class RCrmActions public static function IblocksExportList() { - $catalogExportIblocks = array(); - $dbIblocks = CIBlock::GetList(array('IBLOCK_TYPE' => 'ASC', 'NAME' => 'ASC'), array('CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'W')); + $catalogExportIblocks = []; + $dbIblocks = CIBlock::GetList(['IBLOCK_TYPE' => 'ASC', 'NAME' => 'ASC'], ['CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'W']); + while ($iblock = $dbIblocks->Fetch()) { if ($arCatalog = CCatalog::GetByIDExt($iblock['ID'])) { if($arCatalog['CATALOG_TYPE'] == 'D' || $arCatalog['CATALOG_TYPE'] == 'X' || $arCatalog['CATALOG_TYPE'] == 'P') { - $catalogExportIblocks[$iblock['ID']] = array( + $catalogExportIblocks[$iblock['ID']] = [ 'ID' => $iblock['ID'], 'IBLOCK_TYPE_ID' => $iblock['IBLOCK_TYPE_ID'], 'LID' => $iblock['LID'], 'CODE' => $iblock['CODE'], 'NAME' => $iblock['NAME'], - ); + ]; if ($arCatalog['CATALOG_TYPE'] == 'X' || $arCatalog['CATALOG_TYPE'] == 'P') { $iblockOffer = CCatalogSKU::GetInfoByProductIBlock($iblock['ID']); @@ -289,8 +273,9 @@ class RCrmActions */ public static function clearArr(array $arr): array { - /** @var \Intaro\RetailCrm\Service\Utils $utils */ - $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + /** @var Utils $utils */ + $utils = ServiceLocator::getOrCreate(Utils::class); + return $utils->clearArray($arr); } @@ -302,8 +287,9 @@ class RCrmActions */ public static function toJSON($str) { - /** @var \Intaro\RetailCrm\Service\Utils $utils */ - $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + /** @var Utils $utils */ + $utils = ServiceLocator::getOrCreate(Utils::class); + return $utils->toUTF8($str); } @@ -319,8 +305,8 @@ class RCrmActions return ''; } - /** @var \Intaro\RetailCrm\Service\Utils $utils */ - $utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class); + /** @var Utils $utils */ + $utils = ServiceLocator::getOrCreate(Utils::class); return $utils->fromUTF8($str); } @@ -523,14 +509,14 @@ class RCrmActions case 'cartClear': return self::proxy($api, $methodApi, $method, [$params, $site]); default: - return self::proxy($api, $methodApi, $method, array($params, $site)); + return self::proxy($api, $methodApi, $method, [$params, $site]); } } private static function proxy($api, $methodApi, $method, $params) { $version = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_VERSION, 0); try { - $result = call_user_func_array(array($api, $methodApi), $params); + $result = call_user_func_array([$api, $methodApi], $params); if (!$result) { $err = new RuntimeException( @@ -551,21 +537,21 @@ class RCrmActions || $methodApi == 'customersGet' || $methodApi == 'customersCorporateGet' ) { - Logger::getInstance()->write(array( + Logger::getInstance()->write([ 'api' => $version, 'methodApi' => $methodApi, 'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '', 'errors' => !empty($result['errors']) ? $result['errors'] : '', 'params' => $params - ), 'apiErrors'); + ], 'apiErrors'); } elseif ($methodApi == 'customersUpload' || $methodApi == 'ordersUpload') { - Logger::getInstance()->write(array( + Logger::getInstance()->write([ 'api' => $version, 'methodApi' => $methodApi, 'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '', 'errors' => !empty($result['errors']) ? $result['errors'] : '', 'params' => $params - ), 'uploadApiErrors'); + ], 'uploadApiErrors'); } elseif ($methodApi == 'cartGet') { Logger::getInstance()->write( [ @@ -584,13 +570,13 @@ class RCrmActions !empty($result['errorMsg']) ? $result['errorMsg'] : '' ); - Logger::getInstance()->write(array( + Logger::getInstance()->write([ 'api' => $version, 'methodApi' => $methodApi, 'errorMsg' => !empty($result['errorMsg']) ? $result['errorMsg'] : '', 'errors' => !empty($result['errors']) ? $result['errors'] : '', 'params' => $params, - ), 'apiErrors'); + ], 'apiErrors'); } if (function_exists('retailCrmApiResult')) { @@ -671,13 +657,13 @@ class RCrmActions $exception->getCode() . ': ' . $exception->getMessage() ); - Logger::getInstance()->write(array( + Logger::getInstance()->write([ 'api' => $version, 'methodApi' => $methodApi, 'errorMsg' => $exception->getMessage(), 'errors' => $exception->getCode(), 'params' => $params - ), 'apiErrors'); + ], 'apiErrors'); if (function_exists('retailCrmApiResult')) { retailCrmApiResult($methodApi, false, $apiResultExceptionName); diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 8ca952f2..6c6298fe 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -51,7 +51,6 @@ class RetailCrmHistory public static $CRM_DISCOUNT_ROUND = 'discount_round'; const PAGE_LIMIT = 25; - const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; public static function customerHistory() { diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index 5292c5f3..9a1f95f7 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -431,11 +431,11 @@ class RetailCrmOrder $arUser = UserTable::getById($arOrder['USER_ID'])->fetch(); $fioCrm = [$order['firstName'] ?? null, $order['lastName'] ?? null, $order['patronymic'] ?? null]; - if (in_array($arUser['NAME'], $fioCrm)) { + if ($arUser['NAME'] !== '' && in_array($arUser['NAME'], $fioCrm)) { $order['firstName'] = $arUser['NAME']; } - if (in_array($arUser['LAST_NAME'], $fioCrm)) { + if ($arUser['LAST_NAME'] !== '' && in_array($arUser['LAST_NAME'], $fioCrm)) { $order['lastName'] = $arUser['LAST_NAME']; } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 079bda7c..da60ca69 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Исправлена ошибка при передаче подписки на рекламно-информационные рассылки +- Исправлена критическая ошибка при переходе в настройки модуля diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index a728841d..f37afa67 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -15,6 +15,7 @@ use Bitrix\Sale\EventActions; use Bitrix\Sale\Internals\OrderTable; use Intaro\RetailCrm\Component\ConfigProvider; use Intaro\RetailCrm\Component\Installer\InstallerTrait; +use Intaro\RetailCrm\Service\CurrencyService; use Intaro\RetailCrm\Service\OrderLoyaltyDataService; use Intaro\RetailCrm\Vendor\Symfony\Component\Process\PhpExecutableFinder; use RetailCrm\ApiClient; @@ -242,6 +243,7 @@ class intaro_retailcrm extends CModule include($this->INSTALL_PATH . '/../lib/component/constants.php'); include($this->INSTALL_PATH . '/../lib/repository/agreementrepository.php'); include($this->INSTALL_PATH . '/../lib/service/orderloyaltydataservice.php'); + include($this->INSTALL_PATH . '/../lib/service/currencyservice.php'); include($this->INSTALL_PATH . '/../lib/component/factory/clientfactory.php'); include($this->INSTALL_PATH . '/../lib/component/apiclient/clientadapter.php'); @@ -311,9 +313,11 @@ class intaro_retailcrm extends CModule // form correct url $api_host = parse_url($api_host); + if ($api_host['scheme'] !== 'https') { $api_host['scheme'] = 'https'; } + $api_host = $api_host['scheme'] . '://' . $api_host['host']; if (!$api_host || !$api_key) { @@ -374,15 +378,14 @@ class intaro_retailcrm extends CModule $api_key = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_KEY_OPTION, 0); foreach ($arResult['arSites'] as $site) { + $siteCode[$site['LID']] = null; + if ($_POST['sites-id-' . $site['LID']] && !empty($_POST['sites-id-' . $site['LID']])) { $siteCode[$site['LID']] = htmlspecialchars(trim($_POST['sites-id-' . $site['LID']])); - } else { - $siteCode[$site['LID']] = null; } } $arResult['arCurrencySites'] = RCrmActions::getCurrencySites(); - $bitrixBaseCurrency = CCurrency::GetBaseCurrency(); $result = $this->getReferenceShops($api_host, $api_key); if (isset($result['errCode'])) { @@ -392,26 +395,18 @@ class intaro_retailcrm extends CModule } foreach ($arResult['arSites'] as $bitrixSite) { - $currentCurrency = $bitrixBaseCurrency; - $LID = $bitrixSite['LID']; + $LID = $bitrixSite['LID'] ?? null; + $cmsCurrency = $arResult['arCurrencySites'][$LID] ?? null; + $crmCurrency = $arResult['sitesList'][$siteCode[$LID]]['currency'] ?? null; - if (isset($arResult['arCurrencySites'][$LID])) { - $currentCurrency = $arResult['arCurrencySites'][$LID]; - } - - if ( - isset($arResult['sitesList'][$siteCode[$LID]]) - && $currentCurrency !== $arResult['sitesList'][$siteCode[$LID]]['currency']) - { - $arResult['errCode'] = 'ERR_CURRENCY_SITES'; - } + $arResult['errCode'] = CurrencyService::validateCurrency($cmsCurrency, $crmCurrency); } if (count($arResult['arSites']) != count($siteCode)) { $arResult['errCode'] = 'ERR_FIELDS_API_HOST'; } - if (isset($arResult['errCode'])) { + if (!empty($arResult['errCode'])) { $APPLICATION->IncludeAdminFile( GetMessage('MODULE_INSTALL_TITLE'), $this->INSTALL_PATH . '/step11.php' ); @@ -1458,11 +1453,11 @@ class intaro_retailcrm extends CModule global $APPLICATION; $client = new Client($api_host . '/api/'.self::V5, ['apiKey' => $api_key]); + $result = []; try { - $result = $client->makeRequest('/reference/sites', 'GET'); + $siteResponse = $client->makeRequest('/reference/sites', 'GET'); $bitrixSites = RCrmActions::getSitesList(); - $bitrixBaseCurrency = CCurrency::GetBaseCurrency(); $currencySites = RCrmActions::getCurrencySites(); } catch (CurlException $e) { RCrmActions::eventLog( @@ -1470,47 +1465,44 @@ class intaro_retailcrm extends CModule $e->getCode() . ': ' . $e->getMessage() ); - $res['errCode'] = 'ERR_' . $e->getCode(); + $result['errCode'] = 'ERR_' . $e->getCode(); - return $res; + return $result; } - //Проверка, что был получен корректный ответ - if (isset($result) && $result->getStatusCode() == 200) { - //Проверка количества магазинов, доступных по апи - if (count($bitrixSites) === 1 && count($result->sites) > 1) { - $res['errCode'] = 'ERR_COUNT_SITES'; + // Проверка, что был получен корректный ответ + if (isset($siteResponse) && $siteResponse->getStatusCode() === 200) { + $sites = $siteResponse->sites ?? null; + + if ($sites === null) { + $result['errCode'] = 'UNKNOWN_ERROR'; } - if (!isset($res['errCode']) && count($bitrixSites) === 1 ) { - $currentCurrency = $bitrixBaseCurrency; - $LID = $bitrixSites[0]['LID']; - - if (isset($currencySites[$LID])) { - $currentCurrency = $currencySites[$LID]; - } - - $crmSite = reset($result->sites); - - if ($currentCurrency !== $crmSite['currency']) { - $res['errCode'] = 'ERR_CURRENCY_SITES'; - } + //Проверка количества магазинов, доступных по API + if (count($bitrixSites) === 1 && count($sites) > 1) { + $result['errCode'] = 'ERR_COUNT_SITES'; } - if (!isset($res)) { + if (!isset($result['errCode']) && count($bitrixSites) === 1 ) { + $LID = $bitrixSites[0]['LID'] ?? null; + $cmsCurrency = $currencySites[$LID] ?? null; + + $crmSiteData = reset($sites); + $crmCurrency = $crmSiteData['currency'] ?? null; + + $result['errCode'] = CurrencyService::validateCurrency($cmsCurrency, $crmCurrency); + } + + if (empty($result['errCode'])) { ConfigProvider::setApiVersion(self::V5); - $res['sitesList'] = $APPLICATION->ConvertCharsetArray( - $result->sites, - 'utf-8', - SITE_CHARSET - ); + $result['sitesList'] = $APPLICATION->ConvertCharsetArray($sites, 'utf-8', SITE_CHARSET); } } else { - $res['errCode'] = 'ERR_METHOD_NOT_FOUND'; + $result['errCode'] = 'ERR_METHOD_NOT_FOUND'; } - return $res; + return $result; } /** diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 4db47efb..984a8cae 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.4.11', - 'VERSION_DATE' => '2023-12-08 13:00:00' + 'VERSION' => '6.4.12', + 'VERSION_DATE' => '2023-12-12 17:00:00' ]; diff --git a/intaro.retailcrm/lang/en/install/index.php b/intaro.retailcrm/lang/en/install/index.php index a1414f85..f9b50076 100644 --- a/intaro.retailcrm/lang/en/install/index.php +++ b/intaro.retailcrm/lang/en/install/index.php @@ -17,3 +17,4 @@ $MESS ['ERR_ARTICLE_IBLOCK'] = 'Articles are not set'; $MESS ['DATE_TIMEZONE_ERR'] = 'Timezone is not specified in php settings.'; $MESS ['SALE_VERSION_ERR'] = '\'Online-store\' module version must be higher than 16.'; $MESS['UF_SUBSCRIBE_USER_EMAIL_TITLE'] = 'Agree to receive promotional newsletters'; +$MESS ['CRM_SITES_ERROR'] = 'Failed to get list of CRM stores, please try another API key or contact RetailCRM support.'; diff --git a/intaro.retailcrm/lang/en/install/step1.php b/intaro.retailcrm/lang/en/install/step1.php index 6f4fd825..296cbc53 100644 --- a/intaro.retailcrm/lang/en/install/step1.php +++ b/intaro.retailcrm/lang/en/install/step1.php @@ -19,3 +19,5 @@ $MESS ['ERR_COUNT_SITES'] = 'The API Key you entered relates to more than one st Change the access settings for the API key, it should work with only one store in CRM'; $MESS ['ERR_CURRENCY_SITES'] = 'The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match'; +$MESS ['ERR_CMS_CURRENCY'] = 'Failed to get Bitrix site currency'; +$MESS ['ERR_CRM_CURRENCY'] = 'Failed to get CRM store currency'; diff --git a/intaro.retailcrm/lang/en/install/step11.php b/intaro.retailcrm/lang/en/install/step11.php index df60160e..cdfaec77 100644 --- a/intaro.retailcrm/lang/en/install/step11.php +++ b/intaro.retailcrm/lang/en/install/step11.php @@ -12,3 +12,5 @@ $MESS ['INFO_1'] = 'Set the correspondence between 1C-Bitrix and RetailCRM store $MESS ['INFO_2'] = 'All your stores in RetailCRM must have a common API key!'; $MESS ['ERR_CURRENCY_SITES'] = 'The currency of the site differs from the currency of the store in CRM. For the integration to work correctly, the currencies in CRM and CMS must match'; +$MESS ['ERR_CMS_CURRENCY'] = 'Failed to get Bitrix site currency'; +$MESS ['ERR_CRM_CURRENCY'] = 'Failed to get CRM store currency'; diff --git a/intaro.retailcrm/lang/en/options.php b/intaro.retailcrm/lang/en/options.php index 3206b0dd..f9163d76 100644 --- a/intaro.retailcrm/lang/en/options.php +++ b/intaro.retailcrm/lang/en/options.php @@ -105,7 +105,10 @@ $MESS ['INTEGRATIONS'] = ' (integration)'; $MESS ['ERR_COUNT_SITES'] = 'The API Key you entered relates to more than one store. Change the access settings for the API key, it should work with only one store in CRM'; $MESS ['ERR_CURRENCY_SITES'] = 'The currency of the site differs from the currency of the store in CRM. -For the integration to work correctly, the currencies in CRM and CMS must match'; +For the integration to work correctly, the currencies in CRM and CMS must match #NAME#'; +$MESS ['ERR_CMS_CURRENCY'] = 'Failed to get Bitrix site currency'; +$MESS ['ERR_CRM_CURRENCY'] = 'Failed to get CRM store currency'; +$MESS ['CRM_STORE'] = 'CRM store: '; $MESS ['ACTIVITY_SETTINGS'] = 'Module activity settings'; $MESS ['DEACTIVATE_MODULE'] = 'Deactivate the module'; diff --git a/intaro.retailcrm/lang/ru/install/index.php b/intaro.retailcrm/lang/ru/install/index.php index 63c66930..ff079619 100644 --- a/intaro.retailcrm/lang/ru/install/index.php +++ b/intaro.retailcrm/lang/ru/install/index.php @@ -16,6 +16,7 @@ $MESS ['DATE_TIMEZONE_ERR'] = 'Не указана временная зона $MESS ['SALE_VERSION_ERR'] = 'Версия модуля \'Интернет-магазин\' должна быть выше 16.'; $MESS ['AGREEMENT_LOYALTY_PROGRAM_TEXT'] = 'Вставить текст Правил программы лояльности'; $MESS ['AGREEMENT_PERSONAL_DATA_TEXT'] = 'Вставить текст соглашения на обработку персональных данных'; +$MESS ['CRM_SITES_ERROR'] = 'Не удалось получить список магазинов CRM, попробуйте другой ключ API или обратитесь в службу поддержки RetailCRM.'; $MESS ['RETAIL_MODULE_NAME'] = 'RetailCRM'; $MESS ['MODULE_DESCRIPTION'] = 'Модуль интеграции с RetailCRM - специализированной CRM для e-commerce'; diff --git a/intaro.retailcrm/lang/ru/install/step1.php b/intaro.retailcrm/lang/ru/install/step1.php index 7d53f532..c7256822 100644 --- a/intaro.retailcrm/lang/ru/install/step1.php +++ b/intaro.retailcrm/lang/ru/install/step1.php @@ -15,7 +15,8 @@ $MESS ['ERR_COUNT_SITES'] = 'Введенный вами API Ключ относ Измените настройки доступа для API ключа, он должен работать только с одним магазином в CRM'; $MESS ['ERR_CURRENCY_SITES'] = 'Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать'; -//$MESS ['URL_NOT_FOUND'] = 'В настройках одного или нескольких сайтов не заполнено поле "URL сервера".'; +$MESS ['ERR_CMS_CURRENCY'] = 'Не удалось получить валюту сайта Bitrix'; +$MESS ['ERR_CRM_CURRENCY'] = 'Не удалось получить валюту магазина CRM'; $MESS ['INFO_1'] = 'Введите адрес экземпляра RetailCRM (например, https://demo.retailcrm.ru) и API-ключ.'; $MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в RetailCRM (Администрирование > Интеграция).'; $MESS ['INFO_3'] = 'Код сайта в 1С-Битрикс должен совпадать с кодом сайта в RetailCRM (Администрирование > Магазины).'; diff --git a/intaro.retailcrm/lang/ru/install/step11.php b/intaro.retailcrm/lang/ru/install/step11.php index 81ca7627..67d296cf 100644 --- a/intaro.retailcrm/lang/ru/install/step11.php +++ b/intaro.retailcrm/lang/ru/install/step11.php @@ -11,4 +11,6 @@ $MESS ['ERR_FIELDS_API_HOST'] = 'Неверно заполнены поля.'; $MESS ['INFO_1'] = 'Задайте соответствия между Вашими магазинами в 1С-Битрикс и RetailCRM.'; $MESS ['INFO_2'] = 'У всех Ваших магазинов в RetailCRM должен быть общий API-ключ!'; $MESS ['ERR_CURRENCY_SITES'] = 'Валюта сайта отличается от валюты магазина в CRM. -Для корректной работы интеграции, валюты в CRM и CMS должны совпадать'; \ No newline at end of file +Для корректной работы интеграции, валюты в CRM и CMS должны совпадать'; +$MESS ['ERR_CMS_CURRENCY'] = 'Не удалось получить валюту сайта Bitrix'; +$MESS ['ERR_CRM_CURRENCY'] = 'Не удалось получить валюту магазина CRM'; diff --git a/intaro.retailcrm/lang/ru/options.php b/intaro.retailcrm/lang/ru/options.php index 7aa480ca..67751e59 100644 --- a/intaro.retailcrm/lang/ru/options.php +++ b/intaro.retailcrm/lang/ru/options.php @@ -31,6 +31,9 @@ $MESS ['ERR_COUNT_SITES'] = 'Введенный вами API Ключ относ Измените настройки доступа для API ключа, он должен работать только с одним магазином в CRM'; $MESS ['ERR_CURRENCY_SITES'] = 'Валюта сайта отличается от валюты магазина в CRM. Для корректной работы интеграции, валюты в CRM и CMS должны совпадать'; +$MESS ['ERR_CMS_CURRENCY'] = 'Не удалось получить валюту сайта Bitrix'; +$MESS ['ERR_CRM_CURRENCY'] = 'Не удалось получить валюту магазина CRM'; +$MESS ['CRM_STORE'] = 'CRM магазин: '; $MESS ['ICRM_OPTIONS_SUBMIT_TITLE'] = 'Сохранить настройки'; $MESS ['ICRM_OPTIONS_SUBMIT_VALUE'] = 'Сохранить'; diff --git a/intaro.retailcrm/lib/component/constants.php b/intaro.retailcrm/lib/component/constants.php index 2e23bb55..d4bfb74e 100644 --- a/intaro.retailcrm/lib/component/constants.php +++ b/intaro.retailcrm/lib/component/constants.php @@ -73,7 +73,6 @@ class Constants public const CRM_ORDER_HISTORY_DATE = 'order_history_date'; public const CRM_CATALOG_BASE_PRICE = 'catalog_base_price'; public const CRM_ORDER_DIMENSIONS = 'order_dimensions'; - public const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED'; public const CRM_INTEGRATION_DELIVERY = 'integration_delivery'; public const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted'; public const CORPORATE_CONTRAGENT_TYPE = 'legal-entity'; diff --git a/intaro.retailcrm/lib/service/currencyservice.php b/intaro.retailcrm/lib/service/currencyservice.php new file mode 100644 index 00000000..0b906e23 --- /dev/null +++ b/intaro.retailcrm/lib/service/currencyservice.php @@ -0,0 +1,22 @@ +