From 61177b712d8dfd1c4211b6e99341de7c53ecde5e Mon Sep 17 00:00:00 2001 From: Vlad <48670792+Mozgito@users.noreply.github.com> Date: Wed, 7 Sep 2022 10:35:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?/=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D0=B0=20=D0=B2=20Bitrix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 ++ .../classes/general/CustomerBuilder.php | 15 ++++---- .../general/history/RetailCrmHistory_v5.php | 36 ++++++++++--------- intaro.retailcrm/description.ru | 2 +- intaro.retailcrm/install/version.php | 4 +-- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af05a87f..ac1b55c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2022-09-07 v.6.1.6 +- Корректировка редактирования данных пользователя Bitrix при выгрузке истории изменений + ## 2022-08-22 v.6.1.5 - Корректировка получения НДС товаров в каталоге diff --git a/intaro.retailcrm/classes/general/CustomerBuilder.php b/intaro.retailcrm/classes/general/CustomerBuilder.php index 1fad30b0..368893b1 100644 --- a/intaro.retailcrm/classes/general/CustomerBuilder.php +++ b/intaro.retailcrm/classes/general/CustomerBuilder.php @@ -189,12 +189,6 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa $this->customer->setPersonalGender($this->fromJSON($this->dataCrm['sex'])); } - if (empty($this->dataCrm['externalId'])) { - $userPassword = uniqid("R"); - $this->customer->setPassword($userPassword) - ->setConfirmPassword($userPassword); - } - if ((!isset($this->dataCrm['email']) || $this->dataCrm['email'] == '') && (!isset($this->dataCrm['externalId'])) ) { @@ -208,6 +202,15 @@ class CustomerBuilder extends AbstractBuilder implements RetailcrmBuilderInterfa } } + public function buildPassword() + { + $userPassword = uniqid("R"); + $this->customer->setPassword($userPassword) + ->setConfirmPassword($userPassword); + + return $this; + } + public function buildAddress() { if (isset($this->dataCrm['address'])) { diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 12c2cb46..2e3ce931 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -131,6 +131,7 @@ class RetailCrmHistory case 0: $login = $customer['email']; $customerBuilder->setLogin($login); + $customerBuilder->buildPassword(); break; case 1: $arUser = $dbUser->Fetch(); @@ -140,6 +141,7 @@ class RetailCrmHistory default: $login = uniqid('user_' . time()) . '@example.com'; $customerBuilder->setLogin($login); + $customerBuilder->buildPassword(); break; } } @@ -158,15 +160,15 @@ class RetailCrmHistory continue; } + } - if(RCrmActions::apiMethod( - $api, - 'customersFixExternalIds', - __METHOD__, - array(array('id' => $customer['id'], 'externalId' => $registeredUserID))) == false - ) { - continue; - } + if(RCrmActions::apiMethod( + $api, + 'customersFixExternalIds', + __METHOD__, + array(array('id' => $customer['id'], 'externalId' => $registeredUserID))) == false + ) { + continue; } $customer['externalId'] = $registeredUserID; @@ -856,13 +858,6 @@ class RetailCrmHistory if (isset($order['contact']['id'])) { $ExtId = null; - $response = RCrmActions::apiMethod( - $api, - 'customersGetById', - __METHOD__, - $order['contact']['id'], - $order['site'] - ); if (isset($order['contact']['externalId'])) { $ExtId = $order['contact']['externalId']; @@ -871,6 +866,14 @@ class RetailCrmHistory if (isset($ExtId)) { $newOrder->setFieldNoDemand('USER_ID', $ExtId); } else { + $response = RCrmActions::apiMethod( + $api, + 'customersGetById', + __METHOD__, + $order['contact']['id'], + $order['site'] + ); + $newUser = new CUser(); $customerBuilder = new CustomerBuilder(); $customerBuilder->setDataCrm($response['customer'])->build(); @@ -887,6 +890,7 @@ class RetailCrmHistory case 0: $login = $response['customer']['email']; $customerBuilder->setLogin($login); + $customerBuilder->buildPassword(); break; case 1: $arUser = $dbUser->Fetch(); @@ -896,6 +900,7 @@ class RetailCrmHistory default: $login = uniqid('user_' . time()) . '@example.com'; $customerBuilder->setLogin($login); + $customerBuilder->buildPassword(); break; } @@ -926,7 +931,6 @@ class RetailCrmHistory continue; } } - $newOrder->setFieldNoDemand('USER_ID', $registeredUserID); } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 70b299e5..8f280352 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1 @@ -- Корректировка получения НДС товаров в каталоге \ No newline at end of file +- Корректировка редактирования данных пользователя Bitrix при выгрузке истории изменений \ No newline at end of file diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 0fb01188..b6d0fa74 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.1.5', - 'VERSION_DATE' => '2022-08-22 11:00:00' + 'VERSION' => '6.1.6', + 'VERSION_DATE' => '2022-09-07 10:00:00' ];