From 46c50034f3c0ca3202189f98414a1dbabc788f1c Mon Sep 17 00:00:00 2001 From: gorokh Date: Fri, 1 Nov 2019 12:00:54 +0300 Subject: [PATCH] =?UTF-8?q?issues=20#75=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D1=8C=20=D0=B2=20=D0=BB=D0=BE=D0=B3=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=B2=20=D1=86=D1=80=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../classes/general/user/RetailCrmUser.php | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/intaro.retailcrm/classes/general/user/RetailCrmUser.php b/intaro.retailcrm/classes/general/user/RetailCrmUser.php index e9233afb..801cba2f 100644 --- a/intaro.retailcrm/classes/general/user/RetailCrmUser.php +++ b/intaro.retailcrm/classes/general/user/RetailCrmUser.php @@ -3,7 +3,7 @@ IncludeModuleLangFile(__FILE__); class RetailCrmUser { public static function customerSend($arFields, $api, $contragentType, $send = false, $site = null) - { + { if (!$api || empty($contragentType)) { return false; } @@ -11,7 +11,7 @@ class RetailCrmUser RCrmActions::eventLog('RetailCrmUser::customerSend', 'empty($arFields)', 'incorrect customer'); return false; } - + $customer = array( 'externalId' => $arFields['ID'], 'email' => $arFields['EMAIL'], @@ -20,7 +20,7 @@ class RetailCrmUser 'contragentType' => $contragentType ) ); - + if (!empty($arFields['NAME'])) { $customer['firstName'] = $arFields['NAME']; } @@ -30,14 +30,14 @@ class RetailCrmUser if (!empty($arFields['SECOND_NAME'])) { $customer['patronymic'] = $arFields['SECOND_NAME']; } - + if (!empty($arFields['PERSONAL_PHONE'])) { $customer['phones'][]['number'] = $arFields['PERSONAL_PHONE']; } if (!empty($arFields['WORK_PHONE'])) { $customer['phones'][]['number'] = $arFields['WORK_PHONE']; } - + if (!empty($arFields['PERSONAL_CITY'])) { $customer['address']['city'] = $arFields['PERSONAL_CITY']; } @@ -47,7 +47,7 @@ class RetailCrmUser if (!empty($arFields['PERSONAL_ZIP'])) { $customer['address']['index'] = $arFields['PERSONAL_ZIP']; } - + if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') { $customer['browserId'] = $_COOKIE['_rc']; } @@ -58,37 +58,37 @@ class RetailCrmUser $customer = $newResCustomer; } elseif ($newResCustomer === false) { RCrmActions::eventLog('RetailCrmUser::customerSend', 'retailCrmBeforeCustomerSend()', 'UserID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeCustomerSend'); - + return false; } } $normalizer = new RestNormalizer(); $customer = $normalizer->normalize($customer, 'customers'); - + $log = new Logger(); $log->write($customer, 'customerSend'); - + if ($send) { if (!RCrmActions::apiMethod($api, 'customersCreate', __METHOD__, $customer, $site)) { return false; } } - + return $customer; } - + public static function customerEdit($arFields, $api, $optionsSitesList = array()){ if (empty($arFields)) { RCrmActions::eventLog('RetailCrmUser::customerEdit', 'empty($arFields)', 'incorrect customer'); return false; } - + $customer = array( 'externalId' => $arFields['ID'], 'email' => $arFields['EMAIL'], ); - + if (!empty($arFields['NAME'])) { $customer['firstName'] = $arFields['NAME']; } @@ -98,14 +98,14 @@ class RetailCrmUser if (!empty($arFields['SECOND_NAME'])) { $customer['patronymic'] = $arFields['SECOND_NAME']; } - + if (!empty($arFields['PERSONAL_PHONE'])) { $customer['phones'][]['number'] = $arFields['PERSONAL_PHONE']; } if (!empty($arFields['WORK_PHONE'])) { $customer['phones'][]['number'] = $arFields['WORK_PHONE']; } - + if (!empty($arFields['PERSONAL_CITY'])) { $customer['address']['city'] = $arFields['PERSONAL_CITY']; } @@ -115,7 +115,7 @@ class RetailCrmUser if (!empty($arFields['PERSONAL_ZIP'])) { $customer['address']['index'] = $arFields['PERSONAL_ZIP']; } - + $found = false; if (count($optionsSitesList) > 0) { foreach ($optionsSitesList as $site) { @@ -137,9 +137,6 @@ class RetailCrmUser $normalizer = new RestNormalizer(); $customer = $normalizer->normalize($customer, 'customers'); - $log = new Logger(); - $log->write($customer, 'customerSend'); - if (function_exists('retailCrmBeforeCustomerSend')) { $newResCustomer = retailCrmBeforeCustomerSend($customer); if (is_array($newResCustomer) && !empty($newResCustomer)) { @@ -151,9 +148,12 @@ class RetailCrmUser } } + $log = new Logger(); + $log->write($customer, 'customerSend'); + RCrmActions::apiMethod($api, 'customersEdit', __METHOD__, $customer, $site); } - + return true; } -} \ No newline at end of file +}