1
0
mirror of synced 2025-02-16 15:03:14 +03:00

Merge pull request #87 from Evgeniy-Goroh/master

Исправлены мелкие ошибки и недочеты
This commit is contained in:
Ilyas Salikhov 2019-11-14 17:06:38 +03:00 committed by GitHub
commit 202e0ffd17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 27 deletions

View File

@ -1,3 +1,8 @@
## 2019-11-1 v.2.5.3
* Исправление при обработке полученных изменений о контрагенте
* При обработки истории по клиентам добавлены кастомные поля
* Исправлены мелкие ошибки и недочеты
## 2019-09-17 v.2.5.2
* Поддержка функции добавления одинакового товара в заказ как разные товарные позиции из CRM

View File

@ -462,6 +462,9 @@
"text": {
"type": "string"
},
"address": {
"type": "string"
},
"shipmentStore": {
"type": "string"
},
@ -505,4 +508,4 @@
"type": "string"
}
}
}
}

View File

@ -612,6 +612,9 @@ class RetailCrmHistory
if (array_key_exists($key, $order)) {
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, RCrmActions::fromJSON($order[$key]));
} elseif(array_key_exists($key, $order['contragent'])) {
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, RCrmActions::fromJSON($order['contragent'][$key]));
}
}
}
@ -814,13 +817,16 @@ class RetailCrmHistory
if ($paymentExternalId) {
$newHistoryPayments[$orderPayment->getField('XML_ID')]['externalId'] = $paymentExternalId;
RCrmActions::apiMethod($api, 'paymentEditById', __METHOD__, $newHistoryPayments[$orderPayment->getField('XML_ID')]);
\Bitrix\Sale\Internals\PaymentTable::update($paymentId, array('XML_ID' => ''));
if ($paymentId) {
\Bitrix\Sale\Internals\PaymentTable::update($paymentId, array('XML_ID' => ''));
}
}
}
}
}
if (!$order['externalId']) {
$order["externalId"] = $newOrder->getId();
if (RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false){
continue;
}
@ -907,6 +913,8 @@ class RetailCrmHistory
$customers[$change['customer']['id']]['contragent'][$fields['customerContragent'][$change['field']]] = $change['newValue'];
} elseif ($fields['customer'][$change['field']]) {
$customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']);
} elseif (strripos($change['field'], 'custom_') !== false) {
$customers[$change['customer']['id']]['customFields'][str_replace('custom_', '', $change['field'])] = self::newValue($change['newValue']);
}
if (isset($change['created'])) {

View File

@ -119,7 +119,9 @@ class RetailCrmOrder
$prop['VALUE'][0] = $location['NAME'];
}
$order['delivery']['address'][$search] = $prop['VALUE'][0];
if (!empty($prop['VALUE'][0])) {
$order['delivery']['address'][$search] = $prop['VALUE'][0];
}
}
}
}

View File

@ -3,7 +3,7 @@ IncludeModuleLangFile(__FILE__);
class RetailCrmUser
{
public static function customerSend($arFields, $api, $contragentType, $send = false, $site = null)
{
{
if (!$api || empty($contragentType)) {
return false;
}
@ -11,7 +11,7 @@ class RetailCrmUser
RCrmActions::eventLog('RetailCrmUser::customerSend', 'empty($arFields)', 'incorrect customer');
return false;
}
$customer = array(
'externalId' => $arFields['ID'],
'email' => $arFields['EMAIL'],
@ -20,7 +20,7 @@ class RetailCrmUser
'contragentType' => $contragentType
)
);
if (!empty($arFields['NAME'])) {
$customer['firstName'] = $arFields['NAME'];
}
@ -30,14 +30,14 @@ class RetailCrmUser
if (!empty($arFields['SECOND_NAME'])) {
$customer['patronymic'] = $arFields['SECOND_NAME'];
}
if (!empty($arFields['PERSONAL_PHONE'])) {
$customer['phones'][]['number'] = $arFields['PERSONAL_PHONE'];
}
if (!empty($arFields['WORK_PHONE'])) {
$customer['phones'][]['number'] = $arFields['WORK_PHONE'];
}
if (!empty($arFields['PERSONAL_CITY'])) {
$customer['address']['city'] = $arFields['PERSONAL_CITY'];
}
@ -47,7 +47,7 @@ class RetailCrmUser
if (!empty($arFields['PERSONAL_ZIP'])) {
$customer['address']['index'] = $arFields['PERSONAL_ZIP'];
}
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
$customer['browserId'] = $_COOKIE['_rc'];
}
@ -58,37 +58,37 @@ class RetailCrmUser
$customer = $newResCustomer;
} elseif ($newResCustomer === false) {
RCrmActions::eventLog('RetailCrmUser::customerSend', 'retailCrmBeforeCustomerSend()', 'UserID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeCustomerSend');
return false;
}
}
$normalizer = new RestNormalizer();
$customer = $normalizer->normalize($customer, 'customers');
$log = new Logger();
$log->write($customer, 'customerSend');
if ($send) {
if (!RCrmActions::apiMethod($api, 'customersCreate', __METHOD__, $customer, $site)) {
return false;
}
}
return $customer;
}
public static function customerEdit($arFields, $api, $optionsSitesList = array()){
if (empty($arFields)) {
RCrmActions::eventLog('RetailCrmUser::customerEdit', 'empty($arFields)', 'incorrect customer');
return false;
}
$customer = array(
'externalId' => $arFields['ID'],
'email' => $arFields['EMAIL'],
);
if (!empty($arFields['NAME'])) {
$customer['firstName'] = $arFields['NAME'];
}
@ -98,14 +98,14 @@ class RetailCrmUser
if (!empty($arFields['SECOND_NAME'])) {
$customer['patronymic'] = $arFields['SECOND_NAME'];
}
if (!empty($arFields['PERSONAL_PHONE'])) {
$customer['phones'][]['number'] = $arFields['PERSONAL_PHONE'];
}
if (!empty($arFields['WORK_PHONE'])) {
$customer['phones'][]['number'] = $arFields['WORK_PHONE'];
}
if (!empty($arFields['PERSONAL_CITY'])) {
$customer['address']['city'] = $arFields['PERSONAL_CITY'];
}
@ -115,7 +115,7 @@ class RetailCrmUser
if (!empty($arFields['PERSONAL_ZIP'])) {
$customer['address']['index'] = $arFields['PERSONAL_ZIP'];
}
$found = false;
if (count($optionsSitesList) > 0) {
foreach ($optionsSitesList as $site) {
@ -137,9 +137,6 @@ class RetailCrmUser
$normalizer = new RestNormalizer();
$customer = $normalizer->normalize($customer, 'customers');
$log = new Logger();
$log->write($customer, 'customerSend');
if (function_exists('retailCrmBeforeCustomerSend')) {
$newResCustomer = retailCrmBeforeCustomerSend($customer);
if (is_array($newResCustomer) && !empty($newResCustomer)) {
@ -151,9 +148,12 @@ class RetailCrmUser
}
}
$log = new Logger();
$log->write($customer, 'customerSend');
RCrmActions::apiMethod($api, 'customersEdit', __METHOD__, $customer, $site);
}
return true;
}
}
}

View File

@ -1 +1,3 @@
- Поддержка функции добавления одинакового товара в заказ как разные товарные позиции из CRM
- Исправление при обработке полученных изменений о контрагенте
- При обработки истории по клиентам добавлены кастомные поля
- Исправлены мелкие ошибки и недочеты

View File

@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "2.5.2",
"VERSION_DATE" => "2019-09-17 15:20:00"
"VERSION" => "2.5.3",
"VERSION_DATE" => "2019-11-1 15:10:00"
);