fix reg empty client email, sending a comment the order status
This commit is contained in:
parent
6322f25c36
commit
6f5cd18a07
@ -1,3 +1,7 @@
|
||||
## 2022-12-01 v.6.1.9
|
||||
- Исправление ошибки создания клиента без email по истории
|
||||
- Добавление передачи комментария к статусу заказа в CRM
|
||||
|
||||
## 2022-09-30 v.6.1.8
|
||||
- Исправление ошибки в работе модуля при отмене заказа в Bitrix
|
||||
|
||||
|
@ -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()
|
||||
);
|
||||
|
@ -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'];
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
- Исправлена работа агента получения истории при отмене заказа в Bitrix
|
||||
- Исправление ошибки создания клиента без email по истории
|
||||
- Добавление передачи комментария к статусу заказа в CRM
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.1.8',
|
||||
'VERSION_DATE' => '2022-09-30 14:00:00'
|
||||
'VERSION' => '6.1.9',
|
||||
'VERSION_DATE' => '2022-12-01 11:30:00'
|
||||
];
|
||||
|
@ -59,7 +59,8 @@ class BitrixTestCase extends \PHPUnit\Framework\TestCase
|
||||
'SUM' => 1000,
|
||||
'DATE_PAID' => $this->getDateTime(),
|
||||
'PAID' => 'Y'
|
||||
]]
|
||||
]],
|
||||
'REASON_CANCELED' => 'test comment'
|
||||
];
|
||||
}
|
||||
|
||||
|
78
tests/classes/general/history/RetailCrmHistory_v5Test.php
Normal file
78
tests/classes/general/history/RetailCrmHistory_v5Test.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class RetailCrmHistory_v5Test
|
||||
*/
|
||||
class RetailCrmHistory_v5Test extends \BitrixTestCase
|
||||
{
|
||||
/**
|
||||
* setUp method
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5');
|
||||
CModule::IncludeModule('intaro.retailcrm');
|
||||
}
|
||||
|
||||
public function testSetPasswordUser(): void
|
||||
{
|
||||
$customers = $this->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
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
@ -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']
|
||||
],
|
||||
]];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user