1
0
mirror of synced 2024-11-29 00:36:07 +03:00

ref #87970 Передача менеджера при изменени заказа по истории (#280)

This commit is contained in:
Uryvskiy Dima 2023-03-28 18:12:03 +03:00 committed by GitHub
parent 2e6b105d8d
commit c7aad78e5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 9 deletions

View File

@ -1,3 +1,6 @@
## 2023-03-17 v.6.2.1
- Добавлена передача менеджера при изменении заказа по истории
## 2023-03-10 v.6.2.0 ## 2023-03-10 v.6.2.0
- Добавлена поддержка PHP 8.0 - Добавлена поддержка PHP 8.0

View File

@ -494,11 +494,7 @@ class RetailCrmHistory
$newOrder = Order::create($site, $orderCustomerExtId, $currency); $newOrder = Order::create($site, $orderCustomerExtId, $currency);
if (array_key_exists('managerId', $order)) { self::setManager($newOrder, $order);
$service = ManagerService::getInstance();
$newOrder->setField('RESPONSIBLE_ID', $service->getManagerBitrixId($order['managerId']));
}
if (isset($buyerProfileToAppend['ID']) && isset($optionsLegalDetails['legalName'])) { if (isset($buyerProfileToAppend['ID']) && isset($optionsLegalDetails['legalName'])) {
$newOrder->setFields([ $newOrder->setFields([
@ -564,6 +560,8 @@ class RetailCrmHistory
continue; continue;
} }
self::setManager($newOrder, $order);
$propsRemove = false; $propsRemove = false;
$personType = $newOrder->getField('PERSON_TYPE_ID'); $personType = $newOrder->getField('PERSON_TYPE_ID');
@ -608,7 +606,10 @@ class RetailCrmHistory
if ($optionsPayStatuses[$order['status']]) { if ($optionsPayStatuses[$order['status']]) {
$newOrder->setField('STATUS_ID', $optionsPayStatuses[$order['status']]); $newOrder->setField('STATUS_ID', $optionsPayStatuses[$order['status']]);
if (in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)) { if (
is_array($optionsCanselOrder)
&& in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)
) {
self::unreserveShipment($newOrder); self::unreserveShipment($newOrder);
$newOrder->setFieldNoDemand('CANCELED', 'Y'); $newOrder->setFieldNoDemand('CANCELED', 'Y');
} else { } else {
@ -1948,6 +1949,20 @@ class RetailCrmHistory
return false; return false;
} }
public static function setManager($newOrder, $order)
{
if (array_key_exists('managerId', $order)) {
$service = ManagerService::getInstance();
$newOrder->setField('RESPONSIBLE_ID', $service->getManagerBitrixId($order['managerId']));
// If the order exists in CRM, need to save the changes in the CMS order
if (!empty($order['externalId'])) {
self::orderSave($newOrder);
}
}
}
public static function getInfoElement($offerId) public static function getInfoElement($offerId)
{ {
$elementInfo = CIBlockElement::GetByID($offerId)->fetch(); $elementInfo = CIBlockElement::GetByID($offerId)->fetch();

View File

@ -1 +1 @@
- Добавлена поддержка PHP 8.0 - Добавлена передача менеджера при изменении заказа по истории

View File

@ -1,6 +1,6 @@
<?php <?php
$arModuleVersion = [ $arModuleVersion = [
'VERSION' => '6.2.0', 'VERSION' => '6.2.1',
'VERSION_DATE' => '2023-03-10 12:00:00' 'VERSION_DATE' => '2023-03-17 18:00:00'
]; ];

View File

@ -1,6 +1,7 @@
<?php <?php
use Bitrix\Sale\Order; use Bitrix\Sale\Order;
use Bitrix\Currency\CurrencyManager;
/** /**
* Class RetailCrmHistory_v5Test * Class RetailCrmHistory_v5Test
*/ */
@ -88,6 +89,18 @@ class RetailCrmHistory_v5Test extends \BitrixTestCase
$this->assertEquals(null, RetailCrmHistory::shipmentItemReset($order)); $this->assertEquals(null, RetailCrmHistory::shipmentItemReset($order));
} }
public function testSetManager()
{
$currency = CurrencyManager::getBaseCurrency();
$cmsOrder = Order::create('bitrix', 1, $currency);
$crmManagerId = 123;
RetailcrmConfigProvider::setUsersMap(['bitrixUserId-1515' => $crmManagerId]);
RetailCrmHistory::setManager($cmsOrder, ['externalId' => 1, 'managerId' => $crmManagerId]);
$this->assertEquals(1515, $cmsOrder->getField('RESPONSIBLE_ID'));
}
private function getCustomers(): array private function getCustomers(): array
{ {
return [ return [