1
0
mirror of synced 2024-11-25 06:46:08 +03:00

fix reg empty client email, sending a comment the order status

This commit is contained in:
Kocmonavtik 2022-12-05 16:32:28 +03:00 committed by GitHub
parent 6322f25c36
commit 6f5cd18a07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 7 deletions

View File

@ -1,3 +1,7 @@
## 2022-12-01 v.6.1.9
- Исправление ошибки создания клиента без email по истории
- Добавление передачи комментария к статусу заказа в CRM
## 2022-09-30 v.6.1.8
- Исправление ошибки в работе модуля при отмене заказа в Bitrix

View File

@ -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()
);

View File

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

View File

@ -1 +1,2 @@
- Исправлена работа агента получения истории при отмене заказа в Bitrix
- Исправление ошибки создания клиента без email по истории
- Добавление передачи комментария к статусу заказа в CRM

View File

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

View File

@ -59,7 +59,8 @@ class BitrixTestCase extends \PHPUnit\Framework\TestCase
'SUM' => 1000,
'DATE_PAID' => $this->getDateTime(),
'PAID' => 'Y'
]]
]],
'REASON_CANCELED' => 'test comment'
];
}

View 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
],
];
}
}

View File

@ -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']
],
]];
}