1
0
mirror of synced 2024-11-25 14:56:09 +03:00

Merge pull request #23 from ghostrainman/master

v.2.1.1
This commit is contained in:
Alex Lushpai 2016-11-15 17:51:05 +03:00 committed by GitHub
commit c330a7fbd2
9 changed files with 2829 additions and 29 deletions

View File

@ -1,3 +1,7 @@
## 2016-11-15 v.2.1.1
* Исправлена проблема с отсутствием в настройках доставок
* Небольшие исправления
## 2016-10-31 v.2.1.0 ## 2016-10-31 v.2.1.0
* Добавлена передача адреса из карточки клиента в retailCRM * Добавлена передача адреса из карточки клиента в retailCRM
* Добавлено больше информации в журнале битрикса и дополнительное логирование * Добавлено больше информации в журнале битрикса и дополнительное логирование

View File

@ -42,7 +42,7 @@ class RCrmActions
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(); $noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
foreach ($arDeliveryServiceAll as $arDeliveryService) { foreach ($arDeliveryServiceAll as $arDeliveryService) {
if ($arDeliveryService['PARENT_ID'] == '0' && $arDeliveryService['ID'] != $noOrderId) { if (($arDeliveryService['PARENT_ID'] == '0' || $arDeliveryService['PARENT_ID'] == null) && $arDeliveryService['ID'] != $noOrderId) {
$bitrixDeliveryTypesList[] = $arDeliveryService; $bitrixDeliveryTypesList[] = $arDeliveryService;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -189,6 +189,9 @@
"site": { "site": {
"type": "string" "type": "string"
}, },
"countryIso": {
"type": "string"
},
"call": { "call": {
"type": "bool", "type": "bool",
"default": false "default": false

View File

@ -497,7 +497,7 @@ class RetailCrmHistory
} }
try { try {
$orderCrm = $api->ordersGet($order['id'], 'id'); $orderCrm = $api->ordersGet($order['id'], 'id', $order['site']);
} catch (\RetailCrm\Exception\CurlException $e) { } catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog( RCrmActions::eventLog(
'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet0::CurlException', 'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet0::CurlException',
@ -552,18 +552,20 @@ class RetailCrmHistory
} }
} elseif (array_key_exists($key, $order['delivery']['address'])) { } elseif (array_key_exists($key, $order['delivery']['address'])) {
if ($propsKey[$orderProp]['TYPE'] == 'LOCATION') { if ($propsKey[$orderProp]['TYPE'] == 'LOCATION') {
$parameters = array(); if(!empty($order['delivery']['address'][$key])){
$loc = explode('.', $order['delivery']['address'][$key]); $parameters = array();
if (count($loc) == 1) { $loc = explode('.', $order['delivery']['address'][$key]);
$parameters['filter']['NAME'] = RCrmActions::fromJSON(trim($loc[0])); if (count($loc) == 1) {
} elseif (count($loc) == 2) { $parameters['filter']['NAME'] = RCrmActions::fromJSON(trim($loc[0]));
$parameters['filter']['NAME'] = RCrmActions::fromJSON(trim($loc[1])); } elseif (count($loc) == 2) {
} else{ $parameters['filter']['NAME'] = RCrmActions::fromJSON(trim($loc[1]));
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location ' . $order['delivery']['address'][$key] . ' not found add in order id=' . $order['externalId']); } else{
continue; RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'RetailCrmHistory::setProp', 'Error location ' . $order['delivery']['address'][$key] . ' not found add in order id=' . $order['externalId']);
continue;
}
$parameters['filter']['LANGUAGE_ID'] = 'ru';
$location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch();
} }
$parameters['filter']['LANGUAGE_ID'] = 'ru';
$location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch();
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']); $somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, $location['CODE']); self::setProp($somePropValue, $location['CODE']);
} else { } else {
@ -635,22 +637,22 @@ class RetailCrmHistory
if (array_key_exists('discount', $product) || array_key_exists('discountPercent', $product)) { if (array_key_exists('discount', $product) || array_key_exists('discountPercent', $product)) {
if (!isset($orderCrm)) { if (!isset($orderCrm)) {
try { try {
$orderCrm = $api->ordersGet($order['id'], 'id'); $orderCrm = $api->ordersGet($order['id'], 'id', $order['site']);
} catch (\RetailCrm\Exception\CurlException $e) { } catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog( RCrmActions::eventLog(
'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet::CurlException', 'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet1::CurlException',
$e->getCode() . ': ' . $e->getMessage() $e->getCode() . ': ' . $e->getMessage()
); );
} }
} }
if (isset($orderCrm['order']['items'])) {
foreach ($orderCrm['order']['items'] as $itemCrm) { foreach ($orderCrm['order']['items'] as $itemCrm) {
if ($itemCrm['offer']['externalId'] == $product['offer']['externalId']) { if ($itemCrm['offer']['externalId'] == $product['offer']['externalId']) {
$itemCost = $itemCrm['initialPrice'] - $itemCrm['discount'] - round(($itemCrm['initialPrice'] / 100 * $itemCrm['discountPercent']), 2); $itemCost = $itemCrm['initialPrice'] - $itemCrm['discount'] - round(($itemCrm['initialPrice'] / 100 * $itemCrm['discountPercent']), 2);
break; break;
}
} }
} }
if (isset($itemCost) && $itemCost > 0) { if (isset($itemCost) && $itemCost > 0) {
$item->setField('CUSTOM_PRICE', 'Y'); $item->setField('CUSTOM_PRICE', 'Y');
$item->setField('PRICE', $itemCost); $item->setField('PRICE', $itemCost);
@ -691,7 +693,7 @@ class RetailCrmHistory
//если пусто, удаляем, если нет, update или add //если пусто, удаляем, если нет, update или add
if (!isset($orderCrm)) { if (!isset($orderCrm)) {
try { try {
$orderCrm = $api->ordersGet($order['id'], 'id'); $orderCrm = $api->ordersGet($order['id'], 'id', $order['site']);
} catch (\RetailCrm\Exception\CurlException $e) { } catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog( RCrmActions::eventLog(
'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet2::CurlException', 'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet2::CurlException',

View File

@ -57,7 +57,7 @@ class RetailCrmOrder
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '', $arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
'status' => isset($arParams['optionsPayStatuses'][$arFields['STATUS_ID']]) ? 'status' => isset($arParams['optionsPayStatuses'][$arFields['STATUS_ID']]) ?
$arParams['optionsPayStatuses'][$arFields['STATUS_ID']] : '', $arParams['optionsPayStatuses'][$arFields['STATUS_ID']] : '',
//'statusComment' => $arFields['REASON_CANCELED'], 'statusComment' => $arFields['REASON_CANCELED'],
'customerComment' => $arFields['USER_DESCRIPTION'], 'customerComment' => $arFields['USER_DESCRIPTION'],
'managerComment' => $arFields['COMMENTS'], 'managerComment' => $arFields['COMMENTS'],
'delivery' => array( 'delivery' => array(
@ -86,9 +86,26 @@ class RetailCrmOrder
if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') { if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') {
$arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch(); $arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch();
if ($arLoc) { if ($arLoc) {
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
$countrys = array();
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
foreach ($countrysFile->country as $country) {
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
}
}
$location = \Bitrix\Sale\Location\Name\LocationTable::getList(array( $location = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru') 'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru')
))->fetch(); ))->fetch();
if (count($countrys) > 0) {
$countryOrder = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
'filter' => array('=LOCATION_ID' => $arLoc['COUNTRY_ID'], 'LANGUAGE_ID' => 'ru')
))->fetch();
if(isset($countrys[$countryOrder['NAME']])){
$order['countryIso'] = $countrys[$countryOrder['NAME']];
}
}
} }
$prop['VALUE'][0] = $location['NAME']; $prop['VALUE'][0] = $location['NAME'];
} }
@ -305,6 +322,7 @@ class RetailCrmOrder
'BASKET' => array(), 'BASKET' => array(),
'USER_DESCRIPTION' => $obOrder->getField('USER_DESCRIPTION'), 'USER_DESCRIPTION' => $obOrder->getField('USER_DESCRIPTION'),
'COMMENTS' => $obOrder->getField('COMMENTS'), 'COMMENTS' => $obOrder->getField('COMMENTS'),
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
); );
$shipmentList = $obOrder->getShipmentCollection(); $shipmentList = $obOrder->getShipmentCollection();

View File

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

View File

@ -333,7 +333,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
class="property-export" class="property-export"
onchange="propertyChange(this);"> onchange="propertyChange(this);">
<option value=""></option> <option value=""></option>
<?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName) && $arIBlock['PROPERTIES_SKU'] == null) :?> <?if (version_compare(SM_VERSION, '14.0.0', '>=') && array_key_exists($key, $iblockFieldsName)) :?>
<optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>"> <optgroup label="<?=GetMessage("SELECT_FIELD_NAME");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?> <? foreach ($iblockFieldsName as $keyField => $field): ?>
@ -554,7 +554,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
'catalog', 'catalog',
'export_default_path', 'export_default_path',
'/bitrix/catalog_export/')) '/bitrix/catalog_export/'))
.'retailcrm'/* .mt_rand(0, 999999) */.'.xml' .'retailcrm'.'.xml'
); ?>" size="50"> ); ?>" size="50">
<br> <br>
<br> <br>

View File

@ -1,6 +1,6 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "2.1.0", "VERSION" => "2.1.1",
"VERSION_DATE" => "2016-10-31 17:00:00" "VERSION_DATE" => "2016-11-15 17:00:00"
); );