diff --git a/CHANGELOG.md b/CHANGELOG.md index b3ec79b6..77151519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2022-12-01 v.6.1.9 +- Исправление ошибки создания клиента без email по истории +- Добавление передачи комментария к статусу заказа в CRM + ## 2022-09-30 v.6.1.8 - Исправление ошибки в работе модуля при отмене заказа в Bitrix diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index 9fa768a7..2fe9402d 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -131,7 +131,6 @@ class RetailCrmHistory case 0: $login = $customer['email']; $customerBuilder->setLogin($login); - $customerBuilder->buildPassword(); break; case 1: $arUser = $dbUser->Fetch(); @@ -141,12 +140,12 @@ class RetailCrmHistory default: $login = uniqid('user_' . time()) . '@example.com'; $customerBuilder->setLogin($login); - $customerBuilder->buildPassword(); break; } } if ($registerNewUser === true) { + $customerBuilder->buildPassword(); $registeredUserID = $newUser->Add( $customerBuilder->getCustomer()->getObjectToArray() ); diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index ca1b61d9..923e3c25 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -76,6 +76,10 @@ class RetailCrmOrder 'delivery' => ['cost' => $arOrder['PRICE_DELIVERY']], ]; + if (!empty($arOrder['REASON_CANCELED'])) { + $order['statusComment'] = $arOrder['REASON_CANCELED']; + } + if (isset($arParams['contactExId'])) { $order['contact']['externalId'] = $arParams['contactExId']; } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index ab7cb3c1..778a2608 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1 +1,2 @@ -- Исправлена работа агента получения истории при отмене заказа в Bitrix \ No newline at end of file +- Исправление ошибки создания клиента без email по истории +- Добавление передачи комментария к статусу заказа в CRM \ No newline at end of file diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 15b9596a..234d7f73 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ '6.1.8', - 'VERSION_DATE' => '2022-09-30 14:00:00' + 'VERSION' => '6.1.9', + 'VERSION_DATE' => '2022-12-01 11:30:00' ]; diff --git a/tests/BitrixTestCase.php b/tests/BitrixTestCase.php index 2b844537..ff6c6061 100644 --- a/tests/BitrixTestCase.php +++ b/tests/BitrixTestCase.php @@ -59,7 +59,8 @@ class BitrixTestCase extends \PHPUnit\Framework\TestCase 'SUM' => 1000, 'DATE_PAID' => $this->getDateTime(), 'PAID' => 'Y' - ]] + ]], + 'REASON_CANCELED' => 'test comment' ]; } diff --git a/tests/classes/general/history/RetailCrmHistory_v5Test.php b/tests/classes/general/history/RetailCrmHistory_v5Test.php new file mode 100644 index 00000000..a27e6063 --- /dev/null +++ b/tests/classes/general/history/RetailCrmHistory_v5Test.php @@ -0,0 +1,78 @@ +getCustomers(); + + foreach ($customers as $customer) { + $customerBuilder = new CustomerBuilder(); + $dbUser = $customer['countRows']; + $registerNewUser = true; + + if (!empty($customer['email'])) { + switch ($dbUser) { + case 0: + $login = $customer['email']; + $customerBuilder->setLogin($login); + break; + case 1: + $this->assertContains($customer['id'], [1]); + $registerNewUser = false; + break; + default: + $login = uniqid('user_' . time()) . '@example.com'; + $customerBuilder->setLogin($login); + break; + } + } + + if ($registerNewUser === true) { + $customerBuilder->buildPassword(); + $array = $customerBuilder->getCustomer()->getObjectToArray(); + $this->assertNotEmpty($array["PASSWORD"]); + } + } + } + + private function getCustomers(): array + { + return [ + [ + 'email' => 'test@test.ru', + 'id' => 1, + 'countRows' => 1 + ], + [ + 'email' => null, + 'id' => 2, + 'countRows' => 1 + ], + [ + 'email' => 'test@test.ru', + 'id' => 3, + 'countRows' => 2 + ], + [ + 'email' => 'test@test.ru', + 'id' => 4, + 'countRows' => 0 + ], + ]; + } +} \ No newline at end of file diff --git a/tests/classes/general/order/RetailCrmOrder_v5Test.php b/tests/classes/general/order/RetailCrmOrder_v5Test.php index 5ff94755..02093240 100644 --- a/tests/classes/general/order/RetailCrmOrder_v5Test.php +++ b/tests/classes/general/order/RetailCrmOrder_v5Test.php @@ -63,6 +63,20 @@ class RetailCrmOrder_v5Test extends BitrixTestCase { static::assertEquals($expected['payments'][0], $orderSend['payments'][0]); } + public function testFieldExists(): void + { + $order = \Bitrix\Sale\Order::create('s1', 1, 'RUB'); + $flag = true; + + try { + $order->setField('REASON_CANCELED', 'тестовый заказ'); + } catch(\Exception $e) { + $flag = false; + } + + $this->assertTrue($flag, 'Переменной не существует'); + } + public function initSystemData(): void { RetailcrmConfigProvider::setOrderTypes(['bitrixType' => 'crmType']); @@ -117,7 +131,8 @@ class RetailCrmOrder_v5Test extends BitrixTestCase { 'status' => 'paid', 'paidAt' => $this->getDateTime()->format('Y-m-d H:i:s') ]], - 'privilegeType' => 'none' + 'privilegeType' => 'none', + 'statusComment' => $arFields['REASON_CANCELED'] ], ]]; }