From 0b4c15d81918a60842669e933f8482bc70903fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=A2=D1=8B?= =?UTF-8?q?=D1=89=D0=B8=D1=86=D0=BA=D0=B8=D0=B9?= Date: Wed, 12 Oct 2016 11:40:18 +0300 Subject: [PATCH 1/2] v.2.0.5 --- CHANGELOG.md | 5 ++ .../classes/general/RCrmActions.php | 12 +++-- .../general/history/RetailCrmHistory.php | 50 +++++++------------ .../classes/general/order/RetailCrmOrder.php | 2 +- intaro.retailcrm/description.ru | 5 +- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e3d9a9..5b85dc0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2016-10-11 v.2.0.5 +* Исправлена ошибка при обработке Ф.И.О. +* Исправлена ошибка с неверной кодировкой свойств +* Исправлена ошибка формирования списка статусов + ## 2016-10-06 v.2.0.4 * Оптимизация History * Исправлена ошибка выгрузки доставок при установке diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index f55f7493..c7bf2895 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -67,9 +67,15 @@ class RCrmActions public static function StatusesList() { $bitrixPaymentStatusesList = array(); - $arStatusesAll = \Bitrix\Sale\OrderStatus::getAllStatusesNames(); - foreach ($arStatusesAll as $key => $arStatus) { - $bitrixPaymentStatusesList[$key] = array('ID' => $key, 'NAME' => $arStatus); + $obStatuses = \Bitrix\Sale\Internals\StatusTable::getList(array( + 'filter' => array('TYPE' => 'O'), + 'select' => array('ID', "NAME" => 'Bitrix\Sale\Internals\StatusLangTable:STATUS.NAME') + )); + while ($arStatus = $obStatuses->fetch()) { + $bitrixPaymentStatusesList[$arStatus['ID']] = array( + 'ID' => $arStatus['ID'], + 'NAME' => $arStatus['NAME'], + ); } return $bitrixPaymentStatusesList; diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory.php index 8b841162..3eb1c970 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory.php @@ -477,7 +477,7 @@ class RetailCrmHistory } if (array_key_exists('statusComment', $order)) { - self::setProp($newOrder, $order['statusComment'], 'REASON_CANCELED'); + self::setProp($newOrder, RCrmActions::fromJSON($order['statusComment']), 'REASON_CANCELED'); } $propertyCollection = $newOrder->getPropertyCollection(); @@ -520,53 +520,41 @@ class RetailCrmHistory $fio = ''; foreach ($propertyCollectionArr['properties'] as $prop) { if (in_array($optionsOrderProps[$personType]['fio'], $prop)) { - $fio = $newOrder->getPropertyCollection()->getItemByOrderPropertyId($prop['ID']); + $fio = $newOrder->getPropertyCollection()->getItemByOrderPropertyId($prop['ID'])->getValue(); } } $fio = RCrmActions::explodeFIO($fio); + $newFio = array(); if ($fio) { - $order['fio'] = trim( - implode( - ' ', - array( - isset($order['lastName']) ? $order['lastName'] : (isset($fio['lastName']) ? $fio['lastName'] : ''), - isset($order['firstName']) ? $order['firstName'] : (isset($fio['firstName']) ? $fio['firstName'] : ''), - isset($order['patronymic']) ? $order['patronymic'] : (isset($fio['patronymic']) ? $fio['patronymic'] : ''), - ) - ) - ); + $newFio[] = isset($order['lastName']) ? RCrmActions::fromJSON($order['lastName']) : (isset($fio['lastName']) ? $fio['lastName'] : ''); + $newFio[] = isset($order['firstName']) ? RCrmActions::fromJSON($order['firstName']) : (isset($fio['firstName']) ? $fio['firstName'] : ''); + $newFio[] = isset($order['patronymic']) ? RCrmActions::fromJSON($order['patronymic']) : (isset($fio['patronymic']) ? $fio['patronymic'] : ''); + $order['fio'] = trim(implode(' ', $newFio)); } else { - $order['fio'] = trim( - implode( - ' ', - array( - isset($order['lastName']) ? $order['lastName'] : '', - isset($order['firstName']) ? $order['firstName'] : '', - isset($order['patronymic']) ? $order['patronymic'] : '', - ) - ) - ); + $newFio[] = isset($order['lastName']) ? RCrmActions::fromJSON($order['lastName']) : ''; + $newFio[] = isset($order['firstName']) ? RCrmActions::fromJSON($order['firstName']) : ''; + $newFio[] = isset($order['patronymic']) ? RCrmActions::fromJSON($order['patronymic']) : ''; + $order['fio'] = trim(implode(' ', $newFio)); } } //optionsOrderProps - if ($optionsOrderProps[$personType]) { foreach ($optionsOrderProps[$personType] as $key => $orderProp) { if (array_key_exists($key, $order)) { $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); - self::setProp($somePropValue, $order[$key]); + self::setProp($somePropValue, RCrmActions::fromJSON($order[$key])); } elseif (array_key_exists($key, $order['delivery']['address'])) { if ($propsKey[$key]['TYPE'] == 'LOCATION') { - $parameters['filter']['NAME'] = $order['delivery']['address'][$key]; + $parameters['filter']['NAME'] = RCrmActions::fromJSON($order['delivery']['address'][$key]); $parameters['filter']['LANGUAGE_ID'] = 'ru'; $location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch(); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); self::setProp($somePropValue, $location['CODE']); } else { $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); - self::setProp($somePropValue, $order['delivery']['address'][$key]); + self::setProp($somePropValue, RCrmActions::fromJSON($order['delivery']['address'][$key])); } } } @@ -590,10 +578,10 @@ class RetailCrmHistory } //comments if (array_key_exists('customerComment', $order)) { - self::setProp($newOrder, $order['customerComment'], 'USER_DESCRIPTION'); + self::setProp($newOrder, RCrmActions::fromJSON($order['customerComment']), 'USER_DESCRIPTION'); } if (array_key_exists('managerComment', $order)) { - self::setProp($newOrder, $order['managerComment'], 'COMMENTS'); + self::setProp($newOrder, RCrmActions::fromJSON($order['managerComment']), 'COMMENTS'); } //items @@ -608,12 +596,12 @@ class RetailCrmHistory } $item = $basket->createItem('catalog', $product['offer']['externalId']); if ($item instanceof \Bitrix\Sale\Basket) { - $elem = self::getInfoElement(); + $elem = self::getInfoElement($product['offer']['externalId']); $item->setFields(array( 'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(), 'LID' => \Bitrix\Main\Context::getCurrent()->getSite(), 'BASE_PRICE' => $product['initialPrice'], - 'NAME' => $elem['NAME'], + 'NAME' => $product['name'] ? RCrmActions::fromJSON($product['name']) : $elem['NAME'], 'DETAIL_PAGE_URL' => $elem['URL'] )); } else { @@ -1129,7 +1117,7 @@ class RetailCrmHistory public static function newValue($value) { - if (isset($value['code'])) { + if (array_key_exists('code', $value)) { return $value['code']; } else { return $value; diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder.php index 099992ae..562242e7 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder.php @@ -128,7 +128,7 @@ class RetailCrmOrder //отправка if (function_exists('retailCrmBeforeOrderSend')) { - $newResOrder = retailCrmBeforeOrderSend($order); + $newResOrder = retailCrmBeforeOrderSend($order, $arFields); if (is_array($newResOrder) && !empty($newResOrder)) { $order = $newResOrder; } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 1ccfa339..afa761f8 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1,2 +1,3 @@ -- Оптимизация History -- Исправлена ошибка выгрузки доставок при установке \ No newline at end of file +- Исправлена ошибка в истории при обработке Ф.И.О. +- Исправлена ошибка с неверной кодировкой свойств +- Исправлена ошибка формирования списка статусов \ No newline at end of file From 1482c93cdc3167aa31538b39137cebd55d88585d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9=20=D0=A2=D1=8B?= =?UTF-8?q?=D1=89=D0=B8=D1=86=D0=BA=D0=B8=D0=B9?= Date: Fri, 14 Oct 2016 15:25:02 +0300 Subject: [PATCH 2/2] v.2.0.6 --- CHANGELOG.md | 4 ++++ .../classes/general/history/RetailCrmHistory.php | 15 ++++++++++----- .../classes/general/order/RetailCrmOrder.php | 13 +++++++------ intaro.retailcrm/description.ru | 5 ++--- intaro.retailcrm/install/version.php | 4 ++-- 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b85dc0e..48525d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2016-10-14 v.2.0.6 +* Оптимизация History +* Исправлены ошибки + ## 2016-10-11 v.2.0.5 * Исправлена ошибка при обработке Ф.И.О. * Исправлена ошибка с неверной кодировкой свойств diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory.php index 3eb1c970..98c37ac6 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory.php @@ -327,6 +327,8 @@ class RetailCrmHistory } } + $log->write($order, 'assemblyOrderHistory'); + if (isset($order['deleted'])) { continue; } @@ -470,9 +472,9 @@ class RetailCrmHistory if ($optionsPayStatuses[$order['status']]) { $newOrder->setField('STATUS_ID', $optionsPayStatuses[$order['status']]); if (in_array($optionsPayStatuses[$order['status']], $optionsCanselOrder)) { - $newOrder->setField('CANCELED', 'Y'); + $newOrder->setFieldNoDemand('CANCELED', 'Y'); } else { - $newOrder->setField('CANCELED', 'N'); + $newOrder->setFieldNoDemand('CANCELED', 'N'); } } @@ -520,7 +522,10 @@ class RetailCrmHistory $fio = ''; foreach ($propertyCollectionArr['properties'] as $prop) { if (in_array($optionsOrderProps[$personType]['fio'], $prop)) { - $fio = $newOrder->getPropertyCollection()->getItemByOrderPropertyId($prop['ID'])->getValue(); + $getFio = $newOrder->getPropertyCollection()->getItemByOrderPropertyId($prop['ID']); + if (method_exists($getFio, 'getValue')) { + $fio = $getFio->getValue(); + } } } @@ -1141,12 +1146,12 @@ class RetailCrmHistory return $outputArray; } - public static function setProp($obj, $value, $prop) + public static function setProp($obj, $value = '', $prop) { if (!isset($obj)) { return false; } - if ($prop && $value) { + if ($prop) { $obj->setField($prop, $value); } elseif ($value) { $obj->setValue($value); diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder.php index 562242e7..7e3df3a1 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder.php @@ -83,12 +83,13 @@ class RetailCrmOrder $order[$search] = $prop['VALUE'][0];//телефон и почта } } else {//остальное - адрес - if ($prop['TYPE'] == 'LOCATION') { + if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') { $arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch(); - $location = \Bitrix\Sale\Location\Name\LocationTable::getList(array( - 'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID'=>'ru') - ))->fetch(); - + if ($arLoc) { + $location = \Bitrix\Sale\Location\Name\LocationTable::getList(array( + 'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru') + ))->fetch(); + } $prop['VALUE'][0] = $location['NAME']; } @@ -100,7 +101,7 @@ class RetailCrmOrder //доставки if (array_key_exists($arFields['DELIVERYS'][0]['id'], $arParams['optionsDelivTypes'])) { $order['delivery']['code'] = $arParams['optionsDelivTypes'][$arFields['DELIVERYS'][0]['id']]; - if (isset($arFields['DELIVERYS'][0]['service'])) { + if (isset($arFields['DELIVERYS'][0]['service']) && $arFields['DELIVERYS'][0]['service'] != '') { $order['delivery']['service'] = $arFields['DELIVERYS'][0]['service']; } } diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index afa761f8..0347839e 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1,3 +1,2 @@ -- Исправлена ошибка в истории при обработке Ф.И.О. -- Исправлена ошибка с неверной кодировкой свойств -- Исправлена ошибка формирования списка статусов \ No newline at end of file +- Оптимизация History +- Исправлены ошибки \ No newline at end of file diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index 87a40ad2..8f87522f 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ "2.0.4", - "VERSION_DATE" => "2016-10-06 18:00:00" + "VERSION" => "2.0.6", + "VERSION_DATE" => "2016-10-14 18:00:00" );