1
0
mirror of synced 2024-11-22 13:26:10 +03:00
This commit is contained in:
Евгений Тыщицкий 2016-11-15 17:17:09 +03:00
parent 02b4e5cf08
commit 6504288ab4
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
* Добавлена передача адреса из карточки клиента в retailCRM
* Добавлено больше информации в журнале битрикса и дополнительное логирование

View File

@ -42,7 +42,7 @@ class RCrmActions
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
$noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId();
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;
}
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -57,7 +57,7 @@ class RetailCrmOrder
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
'status' => isset($arParams['optionsPayStatuses'][$arFields['STATUS_ID']]) ?
$arParams['optionsPayStatuses'][$arFields['STATUS_ID']] : '',
//'statusComment' => $arFields['REASON_CANCELED'],
'statusComment' => $arFields['REASON_CANCELED'],
'customerComment' => $arFields['USER_DESCRIPTION'],
'managerComment' => $arFields['COMMENTS'],
'delivery' => array(
@ -86,9 +86,26 @@ class RetailCrmOrder
if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') {
$arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch();
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(
'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru')
))->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'];
}
@ -305,6 +322,7 @@ class RetailCrmOrder
'BASKET' => array(),
'USER_DESCRIPTION' => $obOrder->getField('USER_DESCRIPTION'),
'COMMENTS' => $obOrder->getField('COMMENTS'),
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
);
$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"
onchange="propertyChange(this);">
<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");?>">
<? foreach ($iblockFieldsName as $keyField => $field): ?>
@ -554,7 +554,7 @@ if (file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/retailcrm/expor
'catalog',
'export_default_path',
'/bitrix/catalog_export/'))
.'retailcrm'/* .mt_rand(0, 999999) */.'.xml'
.'retailcrm'.'.xml'
); ?>" size="50">
<br>
<br>

View File

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