1
0
mirror of synced 2025-01-31 15:22:01 +03:00

Merge pull request #22 from ghostrainman/master

v.2.0.9
This commit is contained in:
Alex Lushpai 2016-11-01 15:44:44 +04:00 committed by GitHub
commit 8ee4e81104
11 changed files with 80 additions and 21 deletions

View File

@ -1,3 +1,12 @@
## 2016-10-31 v.2.1.0
* Добавлена передача адреса из карточки клиента в retailCRM
* Добавлено больше информации в журнале битрикса и дополнительное логирование
* Небольшие исправления
## 2016-10-25 v.2.0.9
* Исправлена ошибка с неверной кодировкой ФИО
* Исправлена ошибка с отсутствием местоположения
## 2016-10-20 v.2.0.8
* Исправлена ошибка с отсутствием LID
* Изменены методы для совместимости с ранними версиями sale 16 версии

View File

@ -236,6 +236,12 @@ class RCrmActions
case 'customersEdit':
try {
$result = $api->$methodApi($params, 'externalId', $site);
if (isset($result['errorMsg'])) {
self::eventLog(__CLASS__.'::'.$method, 'RetailCrm\ApiClient::'.$methodApi, $result['errorMsg']);
$log = new Logger();
$log->write(array($methodApi, $result['errorMsg'], $result['errors'], $params), 'apiErrors');
}
} catch (\RetailCrm\Exception\CurlException $e) {
self::eventLog(
__CLASS__.'::'.$method, 'RetailCrm\ApiClient::'.$methodApi.'::CurlException',
@ -256,6 +262,13 @@ class RCrmActions
default:
try {
$result = $api->$methodApi($params, $site);
if (isset($result['errorMsg'])) {
if ($methodApi != 'customersUpload') {
self::eventLog(__CLASS__.'::'.$method, 'RetailCrm\ApiClient::'.$methodApi, $result['errorMsg']);
}
$log = new Logger();
$log->write(array($methodApi, $result['errorMsg'], $result['errors'], $params), 'apiErrors');
}
} catch (\RetailCrm\Exception\CurlException $e) {
self::eventLog(
__CLASS__.'::'.$method, 'RetailCrm\ApiClient::'.$methodApi.'::CurlException',

View File

@ -64,7 +64,7 @@ class RestNormalizer
if (is_null($file) || is_file($file) === false
|| json_decode(file_get_contents($file)) === null
|| $this->parseConfig($file) === false) {
ICrmOrderActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect file normalize.');
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect file normalize.');
return false;
}
@ -79,7 +79,7 @@ class RestNormalizer
}
if (!is_array($data) || count($data) < 1) {
ICrmOrderActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect data array.');
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect data array.');
return false;
}
@ -123,7 +123,7 @@ class RestNormalizer
if ($skip === false) {
foreach ($this->validation as $code => $valid) {
if (isset($valid['required']) && $valid['required'] === true && isset($formatted[ $code ]) === false) {
ICrmOrderActions::eventLog('RestNormalizer', 'intaro.retailcrm', "NOT VALID: $code");
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', "NOT VALID: $code");
}
}

View File

@ -202,6 +202,12 @@ class RetailCrmHistory
}
}
}
if (array_key_exists('index', $customer['address'])) {
$arUser["PERSONAL_ZIP"] = $customer['address']['index'] ? RCrmActions::fromJSON($customer['address']['index']) : '';
}
if (array_key_exists('city', $customer['address'])) {
$arUser["PERSONAL_CITY"] = $customer['address']['city'] ? RCrmActions::fromJSON($customer['address']['city']) : '';
}
$u = $newUser->Update($customer['externalId'], $arUser);
if (!$u) {
@ -539,10 +545,23 @@ class RetailCrmHistory
foreach ($optionsOrderProps[$personType] as $key => $orderProp) {
if (array_key_exists($key, $order)) {
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);
self::setProp($somePropValue, RCrmActions::fromJSON($order[$key]));
if ($key == 'fio') {
self::setProp($somePropValue, $order[$key]);
} else {
self::setProp($somePropValue, RCrmActions::fromJSON($order[$key]));
}
} elseif (array_key_exists($key, $order['delivery']['address'])) {
if ($propsKey[$key]['TYPE'] == 'LOCATION') {
$parameters['filter']['NAME'] = RCrmActions::fromJSON($order['delivery']['address'][$key]);
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;
}
$parameters['filter']['LANGUAGE_ID'] = 'ru';
$location = \Bitrix\Sale\Location\LocationTable::getListFast($parameters)->fetch();
$somePropValue = $propertyCollection->getItemByOrderPropertyId($propsKey[$orderProp]['ID']);

View File

@ -297,7 +297,7 @@ class RetailCrmOrder
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),
'CURRENCY' => $obOrder->getCurrency(),
'PAYMENTS' => $obOrder->getPaymentSystemId(),
'PAYED' => $obOrder->isPaid(),
'PAYED' => $obOrder->isPaid() ? 'Y' : 'N',
'DELIVERYS' => array(),
'PRICE_DELIVERY' => $obOrder->getDeliveryPrice(),
'PROPS' => $obOrder->getPropertyCollection()->getArray(),

View File

@ -8,7 +8,7 @@ class RetailCrmUser
return false;
}
if (empty($arFields)) {
RCrmActions::eventLog('ICrmOrderActions::orderCreate', 'empty($arFields)', 'incorrect customer');
RCrmActions::eventLog('RetailCrmUser::customerSend', 'empty($arFields)', 'incorrect customer');
return false;
}
@ -17,6 +17,8 @@ class RetailCrmUser
'firstName' => $arFields['NAME'],
'lastName' => $arFields['LAST_NAME'],
'patronymic' => $arFields['SECOND_NAME'],
'email' => $arFields['EMAIL'],
'address' => array('city' => $arFields['PERSONAL_CITY'], 'text' => $arFields['PERSONAL_STREET'], 'index' => $arFields['PERSONAL_ZIP']),
'createdAt' => new \DateTime($arFields['DATE_REGISTER']),
'contragentType' => $contragentType
);
@ -54,7 +56,7 @@ class RetailCrmUser
public static function customerEdit($arFields, $api, $optionsSitesList = array()){
if (empty($arFields)) {
RCrmActions::eventLog('RetailCrmUser::orderEdit', 'empty($arFields)', 'incorrect customer');
RCrmActions::eventLog('RetailCrmUser::customerEdit', 'empty($arFields)', 'incorrect customer');
return false;
}
@ -63,7 +65,8 @@ class RetailCrmUser
'firstName' => $arFields['NAME'],
'lastName' => $arFields['LAST_NAME'],
'patronymic' => $arFields['SECOND_NAME'],
'email' => $arFields['EMAIL']
'email' => $arFields['EMAIL'],
'address' => array('city' => $arFields['PERSONAL_CITY'], 'text' => $arFields['PERSONAL_STREET'], 'index' => $arFields['PERSONAL_ZIP']),
);
if (isset($arFields['PERSONAL_PHONE'])) {
$customer['phones'][]['number'] = $arFields['PERSONAL_PHONE'];

View File

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

View File

@ -613,6 +613,13 @@ class intaro_retailcrm extends CModule
$e->getCode() . ': ' . $e->getMessage()
);
}
$delivTypes = array();
foreach ($arResult['deliveryTypesList'] as $delivType) {
if ($delivType['active'] === true) {
$delivTypes[$delivType['code']] = $delivType;
}
}
$arResult['deliveryTypesList'] = $delivTypes;
//bitrix personTypes
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);

View File

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

View File

@ -13,7 +13,7 @@ $MESS ['CANCELED'] = 'Является флагом «Отменен»';
$MESS ['INFO_1'] = 'Задайте соответствие между справочниками 1C-Битрикс и справочниками retailCRM.';
$MESS ['INFO_2'] = 'В случае, если вы не нашли подходящих значений в справочниках retailCRM, вы можете внести их в разделе';
$MESS ['URL_1'] = 'Администрирование';
$MESS ['INFO_3'] = 'После этого подгрузите новые значения, нажав кнопку «Обновить справочники»';
$MESS ['INFO_3'] = 'После этого подгрузите новые значения обновив страницу';//, нажав кнопку «Обновить справочники»';
$MESS ['UPDATE_CATS'] = 'Обновить справочники';
$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.';
$MESS ['DELIV_TYPES_EXPORT'] = 'Выгрузить список доставок из 1С-Битрикс';

View File

@ -249,15 +249,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$orderDischarge = (int) htmlspecialchars(trim($_POST['order-discharge']));
if (($orderDischarge != $previousDischarge) && ($orderDischarge == 0)) {
// remove depenedencies
UnRegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
UnRegisterModuleDependences("sale", "OnBeforeOrderAdd", $mid, "ICrmOrderEvent", "onBeforeOrderAdd");
UnRegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
UnRegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
UnRegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $mid, "RetailCrmEvent", "orderDelete");
} elseif (($orderDischarge != $previousDischarge) && ($orderDischarge == 1)) {
// event dependencies
RegisterModuleDependences("sale", "OnOrderNewSendEmail", $mid, "ICrmOrderEvent", "onSendOrderMail");
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "ICrmOrderEvent", "onUpdateOrder");
RegisterModuleDependences("sale", "OnBeforeOrderAdd", $mid, "ICrmOrderEvent", "onBeforeOrderAdd");
RegisterModuleDependences("sale", "OnSaleOrderEntitySaved", $mid, "RetailCrmEvent", "orderSave");
RegisterModuleDependences("sale", "OnOrderUpdate", $mid, "RetailCrmEvent", "onUpdateOrder");
RegisterModuleDependences("sale", "OnSaleOrderEntityDelete", $mid, "RetailCrmEvent", "orderDelete");
}
$orderPropsArr = array();
@ -343,6 +343,13 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$badKey = true;
echo CAdminMessage::ShowMessage(GetMessage('ERR_403'));
}
$delivTypes = array();
foreach ($arResult['deliveryTypesList'] as $delivType) {
if ($delivType['active'] === true) {
$delivTypes[$delivType['code']] = $delivType;
}
}
$arResult['deliveryTypesList'] = $delivTypes;
//bitrix orderTypesList -- personTypes
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);