parent
4c61df9701
commit
6cd01dd572
@ -1,3 +1,6 @@
|
||||
## 2023-02-16 v.6.1.16
|
||||
- Добавление передачи магазина для корпоративных клиентов
|
||||
|
||||
## 2023-01-10 v.6.1.15
|
||||
- Добавлен фильтр активности менеджеров
|
||||
|
||||
|
@ -170,9 +170,9 @@ class RetailCrmEvent
|
||||
|
||||
if (
|
||||
('Y' === $optionCorpClient)
|
||||
&& true === RetailCrmCorporateClient::isCorpTookExternalId((string)$arOrder['USER_ID'], $api)
|
||||
&& true === RetailCrmCorporateClient::isCorpTookExternalId((string)$arOrder['USER_ID'], $api, $site)
|
||||
) {
|
||||
RetailCrmCorporateClient::setPrefixForExternalId((string) $arOrder['USER_ID'], $api);
|
||||
RetailCrmCorporateClient::setPrefixForExternalId((string) $arOrder['USER_ID'], $api, $site);
|
||||
}
|
||||
|
||||
//TODO эта управляющая конструкция по функционалу дублирует RetailCrmOrder::createCustomerForOrder.
|
||||
|
@ -543,12 +543,15 @@ class RetailCrmOrder
|
||||
$cachedCorporateIds = [];
|
||||
|
||||
foreach ($ordersPack as $lid => $lidOrdersList) {
|
||||
$site = self::getCrmShopCodeByLid($lid, $arParams['optionsSitesList']);
|
||||
|
||||
foreach ($lidOrdersList as $key => $orderData) {
|
||||
$lidOrdersList[$key] = self::addCorporateCustomerToOrder(
|
||||
$orderData,
|
||||
$api,
|
||||
$resCustomersCorporate,
|
||||
$cachedCorporateIds
|
||||
$cachedCorporateIds,
|
||||
$site
|
||||
);
|
||||
}
|
||||
|
||||
@ -605,8 +608,8 @@ class RetailCrmOrder
|
||||
}
|
||||
|
||||
if ('Y' === RetailcrmConfigProvider::getCorporateClientStatus()) {
|
||||
if (true === RetailCrmCorporateClient::isCorpTookExternalId((string) $user['ID'], $api)) {
|
||||
RetailCrmCorporateClient::setPrefixForExternalId((string) $user['ID'], $api);
|
||||
if (true === RetailCrmCorporateClient::isCorpTookExternalId((string) $user['ID'], $api, $site)) {
|
||||
RetailCrmCorporateClient::setPrefixForExternalId((string) $user['ID'], $api, $site);
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,7 +668,8 @@ class RetailCrmOrder
|
||||
array $orderData,
|
||||
ApiClient $api,
|
||||
array $resCustomersCorporate,
|
||||
array &$cachedCorporateIds
|
||||
array &$cachedCorporateIds,
|
||||
$site = null
|
||||
): array {
|
||||
$customerLegalName = $orderData['contragent']['legalName'];
|
||||
|
||||
@ -700,7 +704,8 @@ class RetailCrmOrder
|
||||
);
|
||||
} elseif (array_key_exists($customerLegalName, $resCustomersCorporate)) {
|
||||
$createResponse = $api->customersCorporateCreate(
|
||||
$resCustomersCorporate[$customerLegalName]
|
||||
$resCustomersCorporate[$customerLegalName],
|
||||
$site
|
||||
);
|
||||
|
||||
if ($createResponse && $createResponse->isSuccessful()) {
|
||||
|
@ -170,13 +170,14 @@ class RetailCrmCorporateClient
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCorpTookExternalId(string $bitrixUserId, ApiClient $api): bool
|
||||
public static function isCorpTookExternalId(string $bitrixUserId, ApiClient $api, $site = null): bool
|
||||
{
|
||||
$response = RCrmActions::apiMethod(
|
||||
$api,
|
||||
'customersCorporateGet',
|
||||
__METHOD__,
|
||||
$bitrixUserId
|
||||
$bitrixUserId,
|
||||
$site
|
||||
);
|
||||
|
||||
if (false === $response) {
|
||||
@ -194,7 +195,7 @@ class RetailCrmCorporateClient
|
||||
* @param string $externalId
|
||||
* @param \RetailCrm\ApiClient $api
|
||||
*/
|
||||
public static function setPrefixForExternalId(string $externalId, ApiClient $api)
|
||||
public static function setPrefixForExternalId(string $externalId, ApiClient $api, $site = null)
|
||||
{
|
||||
$response = RCrmActions::apiMethod(
|
||||
$api,
|
||||
@ -203,7 +204,8 @@ class RetailCrmCorporateClient
|
||||
[
|
||||
'urlId' => $externalId,
|
||||
'externalId' => self::CORP_PREFIX . $externalId
|
||||
]
|
||||
],
|
||||
$site
|
||||
);
|
||||
|
||||
if (false === $response) {
|
||||
|
@ -1 +1 @@
|
||||
- Добавлен фильтр активности менеджеров
|
||||
- Добавлена поддержка работы с корпоративными клиентами при мультисайтовости cms системы
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.1.15',
|
||||
'VERSION_DATE' => '2023-01-26 12:00:00'
|
||||
'VERSION' => '6.1.16',
|
||||
'VERSION_DATE' => '2023-02-16 12:00:00'
|
||||
];
|
||||
|
46
tests/classes/general/user/RetailCrmCorporateClientTest.php
Normal file
46
tests/classes/general/user/RetailCrmCorporateClientTest.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use RetailCrm\ApiClient;
|
||||
use RetailCrm\Response\ApiResponse;
|
||||
|
||||
/**
|
||||
* Class RetailCrmCorporateClientTest
|
||||
*/
|
||||
class RetailCrmCorporateClientTest extends \BitrixTestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5');
|
||||
CModule::IncludeModule('intaro.retailcrm');
|
||||
}
|
||||
|
||||
public function testCorpTookAndSetPrefix(): void
|
||||
{
|
||||
$apiClientMock = $this->getMockBuilder(ApiClient::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['customersCorporateGet', 'customersCorporateEdit'])
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$apiResponse = new ApiResponse('200', json_encode(['customerCorporate' => 'test']));
|
||||
$apiClientMock
|
||||
->method('customersCorporateGet')
|
||||
->withAnyParameters()
|
||||
->willReturn($apiResponse)
|
||||
;
|
||||
|
||||
$response = \RetailCrmCorporateClient::isCorpTookExternalId('15', $apiClientMock, 'testSite');
|
||||
|
||||
$this->assertTrue($response);
|
||||
|
||||
$apiClientMock
|
||||
->method('customersCorporateEdit')
|
||||
->withAnyParameters()
|
||||
->willReturn($apiResponse)
|
||||
;
|
||||
|
||||
RetailCrmCorporateClient::setPrefixForExternalId(15, $apiClientMock, 'testSite');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user