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' ];