diff --git a/intaro.retailcrm/classes/general/RCrmActions.php b/intaro.retailcrm/classes/general/RCrmActions.php index fdf3bb16..b035d310 100644 --- a/intaro.retailcrm/classes/general/RCrmActions.php +++ b/intaro.retailcrm/classes/general/RCrmActions.php @@ -343,6 +343,11 @@ class RCrmActions 'params' => $params ), 'apiErrors'); } + + if (function_exists('retailCrmApiResult')) { + retailCrmApiResult($methodApi, false, $result->getStatusCode()); + } + if ($result->getStatusCode() == 460) { return true; } @@ -361,6 +366,10 @@ class RCrmActions 'errors' => $e->getCode(), 'params' => $params ), 'apiErrors'); + + if (function_exists('retailCrmApiResult')) { + retailCrmApiResult($methodApi, false, 'CurlException'); + } return false; } catch (InvalidArgumentException $e) { @@ -375,10 +384,18 @@ class RCrmActions 'errors' => $e->getCode(), 'params' => $params ), 'apiErrors'); + + if (function_exists('retailCrmApiResult')) { + retailCrmApiResult($methodApi, false, 'ArgumentException'); + } return false; } + if (function_exists('retailCrmApiResult')) { + retailCrmApiResult($methodApi, true, $result->getStatusCode()); + } + return $result; } } diff --git a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php index 612d5b2a..a3e2b38d 100644 --- a/intaro.retailcrm/classes/general/events/RetailCrmEvent.php +++ b/intaro.retailcrm/classes/general/events/RetailCrmEvent.php @@ -107,7 +107,7 @@ class RetailCrmEvent return true; } - //проверка на существование getParameter("ENTITY") + //exists getParameter("ENTITY") if (method_exists($event, 'getId')) { $obOrder = $event; } elseif (method_exists($event, 'getParameter')) { @@ -150,14 +150,14 @@ class RetailCrmEvent 'optionsCustomFields' => $optionsCustomFields )); - //многосайтовость + //many sites? if(!empty($optionsSitesList) && array_key_exists($arOrder['LID'], $optionsSitesList)) { $site = $optionsSitesList[$arOrder['LID']]; } else { $site = null; } - //проверка на новый заказ + //new order? $orderCrm = RCrmActions::apiMethod($api, 'ordersGet', __METHOD__, $arOrder['ID'], $site); if (isset($orderCrm['order'])) { $methodApi = 'ordersEdit'; diff --git a/intaro.retailcrm/classes/general/history/FastOrderHistory.php b/intaro.retailcrm/classes/general/history/FastOrderHistory.php new file mode 100644 index 00000000..1149acf2 --- /dev/null +++ b/intaro.retailcrm/classes/general/history/FastOrderHistory.php @@ -0,0 +1,31 @@ +RestartBuffer(); +$moduleId = 'intaro.retailcrm'; +$historyTime = 'history_time'; +$idOrderCRM = (int)$_REQUEST['idOrderCRM']; + +if (CModule::IncludeModule($moduleId) && $idOrderCRM && $idOrderCRM > 0) { + $timeBd = COption::GetOptionString($moduleId, $historyTime, 0); + $nowDate = date('Y-m-d H:i:s'); + if (!empty($timeBd)) { + $timeBdObj = new \DateTime($timeBd); + $newTimeBdObj = $timeBdObj->modify('+5 min'); + $nowDateObj = new \DateTime($nowDate); + //If there is a record, but it is older than 5 minutes, overwrite + if ($newTimeBdObj < $nowDateObj) { + COption::SetOptionString($moduleId, $historyTime, $nowDate); + //call history + RCrmActions::orderAgent(); + + COption::RemoveOption($moduleId, $historyTime); + } + } else { + COption::SetOptionString($moduleId, $historyTime, $nowDate); + //call history + RCrmActions::orderAgent(); + + COption::RemoveOption($moduleId, $historyTime); + } +} \ No newline at end of file diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php index 51b75f7b..240c5887 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v4.php @@ -208,14 +208,14 @@ class RetailCrmHistory $GLOBALS['RETAIL_CRM_HISTORY'] = false; - //запоминаем номер последнего изменения + //last id $end = array_pop($customerH); COption::SetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY, $end['id']); if ($customerHistory['pagination']['totalPageCount'] == 1) { return true; } - //новый фильтр для истории + //new filter $historyFilter['sinceId'] = $end['id']; } } @@ -288,7 +288,7 @@ class RetailCrmHistory $GLOBALS['RETAIL_CRM_HISTORY'] = true; - //обработка заказа + //orders with changes foreach ($orders as $order) { if (function_exists('retailCrmBeforeOrderSave')) { $newResOrder = retailCrmBeforeOrderSave($order); @@ -883,7 +883,7 @@ class RetailCrmHistory $crmService = $orderCrm['delivery']['service']['code']; } - //подбираем код битриксового сервиса + //select bitrix service code $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); foreach ($arDeliveryServiceAll as $arDeliveryService) { $arDeliveryCode[$arDeliveryService['CODE']] = $arDeliveryService['ID']; @@ -892,7 +892,7 @@ class RetailCrmHistory $dCode = $arDeliveryService['CODE'] . ':' . $crmService; } } - //будем менять доставку на этот id + //We will change delivery to this id if ($crmService && $arDeliveryCode[$dCode]) { $nowDelivery = $arDeliveryCode[$dCode]; } elseif (!empty($optionsDelivTypes[$crmCode])) { @@ -903,9 +903,9 @@ class RetailCrmHistory return false; } - //найти текущую доставку в заказе + //Find the current delivery in the order $cnt = Bitrix\Sale\Internals\ShipmentTable::getCount(array('ORDER_ID' => $orderCrm['externalId'])); - if ($cnt > 0) {//обновляем + if ($cnt > 0) {//update $obDeliverys = \Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']), 'order' => array('ID'))); while ($arDelivery = $obDeliverys->fetch()) { @@ -914,7 +914,29 @@ class RetailCrmHistory \Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $nowDelivery, 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'])); } } - } else {//создаем + if ($cnt = 1 && $arDelivery['DELIVERY_ID'] == 0) { + $shipment = Bitrix\Sale\Internals\ShipmentTable::add(array( + 'ORDER_ID' => $orderCrm['externalId'], + 'STATUS_ID' => 'DN', + 'PRICE_DELIVERY' => 0, + 'BASE_PRICE_DELIVERY' => 0, + 'CUSTOM_PRICE_DELIVERY' => 'N', + 'ALLOW_DELIVERY' => 'N', + 'DEDUCTED' => 'N', + 'RESERVED' => 'N', + 'DELIVERY_ID' => $nowDelivery, + 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'], + 'CANCELED' => 'N', + 'MARKED' => 'N', + 'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(), + 'SYSTEM' => 'N', + 'ACCOUNT_NUMBER' => $accountNumber . '/2', + 'EXTERNAL_DELIVERY' => 'N', + 'UPDATED_1C' => 'N', + 'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime() + )); + } + } else {//create \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery)); $shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array( 'ORDER_ID' => $orderCrm['externalId'], @@ -955,7 +977,7 @@ class RetailCrmHistory )); } } else { - //ищем у заказа на сайте доставки и удаляем/заменяем на без доставки + //search for the order on the delivery site and delete / replace with no delivery $noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(); \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId)); $obDeliverys = Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']), @@ -1044,13 +1066,13 @@ class RetailCrmHistory $found = false; foreach ($arShipmentItems as $elShipmentItem) { if (!in_array($elShipmentItem['BASKET_ID'], $bItems)) { - //удаляем элемент + //delete the element \Bitrix\Sale\Internals\ShipmentItemTable::delete($elShipmentItem['ID']); } if ($elShipmentItem['BASKET_ID'] == $basketItem['ID']) { - //нашли + //found $found = true; - //проверяем кол-во, если нужно, обновляем + //update quantity if ($elShipmentItem['QUANTITY'] != $basketItem['QUANTITY']) { \Bitrix\Sale\Internals\ShipmentItemTable::update($elShipmentItem['ID'], array('QUANTITY' => $basketItem['QUANTITY'])); } @@ -1058,7 +1080,7 @@ class RetailCrmHistory } } if (!$found) { - //добавляем + //create \Bitrix\Sale\Internals\ShipmentItemTable::add(array( 'ORDER_DELIVERY_ID' => $key, 'BASKET_ID' => $basketItem['ID'], @@ -1095,7 +1117,7 @@ class RetailCrmHistory 'filter' => array('ORDER_ID' => $order['externalId']), 'order' => array('ID') ))->fetch(); - if ($payment) {//если уже существует, update + if ($payment) {//update payment \Bitrix\Sale\Internals\PaymentTable::update($payment['ID'], array('PAY_SYSTEM_ID' => $optionsPayment[$order['paymentType']], 'PAY_SYSTEM_NAME' => $arPaymentsName[$optionsPayment[$order['paymentType']]], 'SUM' => $order['summ'])); } else { \Bitrix\Sale\Internals\PaymentTable::add(array( @@ -1112,11 +1134,10 @@ class RetailCrmHistory 'UPDATED_1C' => 'N' )); } - //запись в историю - } else {//ошибка, нет такой активной платежной системы + } else { RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found in order id=' . $order['externalId']); } - } else {//ошибка, возможно платежная система не сопоставлена + } else { RCrmActions::eventLog('RetailCrmHistory::paySystemUpdate', 'RCrmActions::PaymentList()', 'Error paySystem not found in option in order id=' . $order['externalId']);; } } else { @@ -1129,7 +1150,6 @@ class RetailCrmHistory if ($payment['ID']) { \Bitrix\Sale\Internals\PaymentTable::delete($payment['ID']); } - //запись в историю } } diff --git a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php index a8764547..b4916b9f 100644 --- a/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php +++ b/intaro.retailcrm/classes/general/history/RetailCrmHistory_v5.php @@ -207,7 +207,7 @@ class RetailCrmHistory $GLOBALS['RETAIL_CRM_HISTORY'] = false; - //number of last edit + //last id $end = array_pop($customerH); COption::SetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY, $end['id']); @@ -243,7 +243,7 @@ class RetailCrmHistory $api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0); $api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0); -//проверить $optionsOrderTypes = unserialize + $optionsOrderTypes = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_TYPES_ARR, 0)); $optionsDelivTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_TYPES_ARR, 0))); $optionsPayStatuses = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0))); // --statuses @@ -919,7 +919,7 @@ class RetailCrmHistory $crmService = $orderCrm['delivery']['service']['code']; } - //подбираем код битриксового сервиса + //select bitrix service code $arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList(); foreach ($arDeliveryServiceAll as $arDeliveryService) { $arDeliveryCode[$arDeliveryService['CODE']] = $arDeliveryService['ID']; @@ -928,7 +928,7 @@ class RetailCrmHistory $dCode = $arDeliveryService['CODE'] . ':' . $crmService; } } - //будем менять доставку на этот id + //We will change delivery to this id if ($crmService && $arDeliveryCode[$dCode]) { $nowDelivery = $arDeliveryCode[$dCode]; } elseif (!empty($optionsDelivTypes[$crmCode])) { @@ -939,9 +939,9 @@ class RetailCrmHistory return false; } - //найти текущую доставку в заказе + //Find the current delivery in the order $cnt = Bitrix\Sale\Internals\ShipmentTable::getCount(array('ORDER_ID' => $orderCrm['externalId'])); - if ($cnt > 0) {//обновляем + if ($cnt > 0) {//update $obDeliverys = \Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']), 'order' => array('ID'))); while ($arDelivery = $obDeliverys->fetch()) { @@ -950,7 +950,29 @@ class RetailCrmHistory \Bitrix\Sale\Internals\ShipmentTable::update($arDelivery['ID'], array('DELIVERY_ID' => $nowDelivery, 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'])); } } - } else {//создаем + if ($cnt = 1 && $arDelivery['DELIVERY_ID'] == 0) { + $shipment = Bitrix\Sale\Internals\ShipmentTable::add(array( + 'ORDER_ID' => $orderCrm['externalId'], + 'STATUS_ID' => 'DN', + 'PRICE_DELIVERY' => 0, + 'BASE_PRICE_DELIVERY' => 0, + 'CUSTOM_PRICE_DELIVERY' => 'N', + 'ALLOW_DELIVERY' => 'N', + 'DEDUCTED' => 'N', + 'RESERVED' => 'N', + 'DELIVERY_ID' => $nowDelivery, + 'DELIVERY_NAME' => $arDeliveryID[$nowDelivery]['NAME'], + 'CANCELED' => 'N', + 'MARKED' => 'N', + 'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(), + 'SYSTEM' => 'N', + 'ACCOUNT_NUMBER' => $accountNumber . '/2', + 'EXTERNAL_DELIVERY' => 'N', + 'UPDATED_1C' => 'N', + 'DATE_INSERT'=> new \Bitrix\Main\Type\DateTime() + )); + } + } else {//create \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $nowDelivery)); $shipmentSystem = \Bitrix\Sale\Internals\ShipmentTable::add(array( 'ORDER_ID' => $orderCrm['externalId'], @@ -991,7 +1013,7 @@ class RetailCrmHistory )); } } else { - //ищем у заказа на сайте доставки и удаляем/заменяем на без доставки + //search for the order on the delivery site and delete / replace with no delivery $noOrderId = \Bitrix\Sale\Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(); \Bitrix\Sale\OrderTable::update($orderCrm['externalId'], array('DELIVERY_ID' => $noOrderId)); $obDeliverys = Bitrix\Sale\Internals\ShipmentTable::getList(array('filter' => array('ORDER_ID' => $orderCrm['externalId']), @@ -1080,13 +1102,13 @@ class RetailCrmHistory $found = false; foreach ($arShipmentItems as $elShipmentItem) { if (!in_array($elShipmentItem['BASKET_ID'], $bItems)) { - //удаляем элемент + //delete the element \Bitrix\Sale\Internals\ShipmentItemTable::delete($elShipmentItem['ID']); } if ($elShipmentItem['BASKET_ID'] == $basketItem['ID']) { - //нашли + //found $found = true; - //проверяем кол-во, если нужно, обновляем + //update quantity if ($elShipmentItem['QUANTITY'] != $basketItem['QUANTITY']) { \Bitrix\Sale\Internals\ShipmentItemTable::update($elShipmentItem['ID'], array('QUANTITY' => $basketItem['QUANTITY'])); } @@ -1094,7 +1116,7 @@ class RetailCrmHistory } } if (!$found) { - //добавляем + //create \Bitrix\Sale\Internals\ShipmentItemTable::add(array( 'ORDER_DELIVERY_ID' => $key, 'BASKET_ID' => $basketItem['ID'], @@ -1122,13 +1144,13 @@ class RetailCrmHistory $paymentsList[$data['ID']] = $paymentData; } - //проходим по данным из crm + //data from crm $paySumm = 0; foreach ($paymentsCrm['payments'] as $paymentCrm) { if (!empty($paymentCrm['externalId'])) { - //находим оплату + //find the payment $nowPayment = $paymentsList[$paymentCrm['externalId']]; - //обновляем в ней данные + //update data if ($nowPayment instanceof \Bitrix\Sale\Payment) { $nowPayment->setField('SUM', $paymentCrm['amount']); if ($optionsPayTypes[$paymentCrm['type']] != $nowPayment->getField('PAY_SYSTEM_ID')) { @@ -1159,7 +1181,7 @@ class RetailCrmHistory unset($paymentsList[$newPaymentId]); - RCrmActions::apiMethod($api, 'ordersPaymentEdit', __METHOD__, array('id' => $paymentCrm['id'], 'externalId' => $newPaymentId)); + //RCrmActions::apiMethod($api, 'ordersPaymentEdit', __METHOD__, array('id' => $paymentCrm['id'], 'externalId' => $newPaymentId)); } if ($optionsPayment[$paymentCrm['status']] == 'Y') { diff --git a/intaro.retailcrm/classes/general/inventories/RetailCrmInventories.php b/intaro.retailcrm/classes/general/inventories/RetailCrmInventories.php index ef359520..3b373bcd 100644 --- a/intaro.retailcrm/classes/general/inventories/RetailCrmInventories.php +++ b/intaro.retailcrm/classes/general/inventories/RetailCrmInventories.php @@ -123,7 +123,7 @@ class RetailCrmInventories 'available' => self::switchCount($arStoreProduct['AMOUNT'], $inventoriesType[$stores[$arStoreProduct['STORE_ID']]]), ); } - //инфу в лог + //for log $splitedItems = array_chunk($invUpload, 200); foreach ($splitedItems as $chunk) { $log->write($chunk, 'inventoriesUpload'); diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php index 567fc8f4..de7db1d6 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v4.php @@ -68,20 +68,20 @@ class RetailCrmOrder } $order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']]; - //свойства + //fields foreach ($arFields['PROPS']['properties'] as $prop) { if ($search = array_search($prop['CODE'], $arParams['optionsLegalDetails'][$arFields['PERSON_TYPE_ID']])) { - $order['contragent'][$search] = $prop['VALUE'][0];//юр данные заказа + $order['contragent'][$search] = $prop['VALUE'][0];//legal order data } elseif ($search = array_search($prop['CODE'], $arParams['optionsCustomFields'][$arFields['PERSON_TYPE_ID']])) { - $order['customFields'][$search] = $prop['VALUE'][0];//кастомные свойства - } elseif ($search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arFields['PERSON_TYPE_ID']])) {//остальное - if (in_array($search, array('fio', 'phone', 'email'))) {//фио, телефон, почта + $order['customFields'][$search] = $prop['VALUE'][0];//custom properties + } elseif ($search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arFields['PERSON_TYPE_ID']])) {//other + if (in_array($search, array('fio', 'phone', 'email'))) {//fio, phone, email if ($search == 'fio') { - $order = array_merge($order, RCrmActions::explodeFIO($prop['VALUE'][0]));//добавляем поля фио + $order = array_merge($order, RCrmActions::explodeFIO($prop['VALUE'][0]));//add fio fields } else { - $order[$search] = $prop['VALUE'][0];//телефон и почта + $order[$search] = $prop['VALUE'][0];//phone, email } - } else {//остальное - адрес + } else {//address if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') { $arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch(); if ($arLoc) { @@ -113,7 +113,7 @@ class RetailCrmOrder } } - //доставки + //deliverys 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']) && $arFields['DELIVERYS'][0]['service'] != '') { @@ -121,7 +121,7 @@ class RetailCrmOrder } } - //корзина + //basket foreach ($arFields['BASKET'] as $product) { $item = array( 'quantity' => $product['QUANTITY'], @@ -142,7 +142,7 @@ class RetailCrmOrder $order['items'][] = $item; } - //отправка + //send if (function_exists('retailCrmBeforeOrderSend')) { $newResOrder = retailCrmBeforeOrderSend($order, $arFields); if (is_array($newResOrder) && !empty($newResOrder)) { diff --git a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php index e93681cc..02a2af7d 100644 --- a/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php +++ b/intaro.retailcrm/classes/general/order/RetailCrmOrder_v5.php @@ -64,20 +64,20 @@ class RetailCrmOrder } $order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']]; - //свойства + //fields foreach ($arFields['PROPS']['properties'] as $prop) { if ($search = array_search($prop['CODE'], $arParams['optionsLegalDetails'][$arFields['PERSON_TYPE_ID']])) { - $order['contragent'][$search] = $prop['VALUE'][0];//юр данные заказа + $order['contragent'][$search] = $prop['VALUE'][0];//legal order data } elseif ($search = array_search($prop['CODE'], $arParams['optionsCustomFields'][$arFields['PERSON_TYPE_ID']])) { - $order['customFields'][$search] = $prop['VALUE'][0];//кастомные свойства - } elseif ($search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arFields['PERSON_TYPE_ID']])) {//остальное - if (in_array($search, array('fio', 'phone', 'email'))) {//фио, телефон, почта + $order['customFields'][$search] = $prop['VALUE'][0];//custom properties + } elseif ($search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arFields['PERSON_TYPE_ID']])) {//other + if (in_array($search, array('fio', 'phone', 'email'))) {//fio, phone, email if ($search == 'fio') { - $order = array_merge($order, RCrmActions::explodeFIO($prop['VALUE'][0]));//добавляем поля фио + $order = array_merge($order, RCrmActions::explodeFIO($prop['VALUE'][0]));//add fio fields } else { - $order[$search] = $prop['VALUE'][0];//телефон и почта + $order[$search] = $prop['VALUE'][0];//phone, email } - } else {//остальное - адрес + } else {//address if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') { $arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch(); if ($arLoc) { @@ -109,7 +109,7 @@ class RetailCrmOrder } } - //доставки + //deliverys 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']) && $arFields['DELIVERYS'][0]['service'] != '') { @@ -117,7 +117,7 @@ class RetailCrmOrder } } - //корзина + //basket foreach ($arFields['BASKET'] as $product) { $item = array( 'quantity' => $product['QUANTITY'], @@ -138,8 +138,7 @@ class RetailCrmOrder $order['items'][] = $item; } - //оплаты - + //payments $payments = array(); foreach ($arFields['PAYMENTS'] as $payment) { $pm = array( @@ -160,7 +159,8 @@ class RetailCrmOrder if (count($payments) > 0) { $order['payments'] = $payments; } - //отправка + + //send if (function_exists('retailCrmBeforeOrderSend')) { $newResOrder = retailCrmBeforeOrderSend($order, $arFields); if (is_array($newResOrder) && !empty($newResOrder)) { diff --git a/intaro.retailcrm/classes/general/prices/RetailCrmPrices.php b/intaro.retailcrm/classes/general/prices/RetailCrmPrices.php index 1ba4c3f5..242fb9c2 100644 --- a/intaro.retailcrm/classes/general/prices/RetailCrmPrices.php +++ b/intaro.retailcrm/classes/general/prices/RetailCrmPrices.php @@ -112,7 +112,7 @@ class RetailCrmPrices } } - //инфу в лог + //for log $splitedItems = array_chunk($pricesUpload, 200); foreach ($splitedItems as $chunk) { $log->write($chunk, 'storePricesUpload'); diff --git a/intaro.retailcrm/description.ru b/intaro.retailcrm/description.ru index 70139d54..6d13e466 100644 --- a/intaro.retailcrm/description.ru +++ b/intaro.retailcrm/description.ru @@ -1,8 +1,3 @@ -- API V5 -- Возможность выбора версии API -- Добавлена возможность выгрузки остатков в разрезе складов -- Добавлена возможность выгрузки типов цен -- Добавлена базовая интеграция Demon Collector -- Добавлена интеграция с Universal Analytics -- Доработана логика работы встроенных функций для модификации данных +- Добавлена встроенная функция retailCrmApiResult +- Добавлен триггерный вариант истории изменений - Исправлены ошибки \ No newline at end of file diff --git a/intaro.retailcrm/install/index.php b/intaro.retailcrm/install/index.php index 2651f988..ef7f2ab4 100644 --- a/intaro.retailcrm/install/index.php +++ b/intaro.retailcrm/install/index.php @@ -65,6 +65,7 @@ class intaro_retailcrm extends CModule var $CRM_UA_KEYS = 'ua_keys'; var $CRM_API_VERSION = 'api_version'; + var $HISTORY_TIME = 'history_time'; var $INSTALL_PATH; @@ -632,7 +633,7 @@ class intaro_retailcrm extends CModule $customerH = self::historyLoad($api, 'customersHistory'); COption::SetOptionString($this->MODULE_ID, $this->CRM_CUSTOMER_HISTORY, $customerH); - //если есть старое значение, переделываем его на новый лад, иначе вычисляем + //new data if ($historyDate = COption::GetOptionString($this->OLD_MODULE_ID, 'order_history_date', 0)) { try { $history = $api->ordersHistory(array('startDate' => $historyDate)); @@ -1005,6 +1006,7 @@ class intaro_retailcrm extends CModule COption::RemoveOption($this->MODULE_ID, $this->CRM_UA_KEYS); COption::RemoveOption($this->MODULE_ID, $this->CRM_API_VERSION); + COption::RemoveOption($this->MODULE_ID, $this->HISTORY_TIME); UnRegisterModuleDependences("sale", "OnOrderUpdate", $this->MODULE_ID, "RetailCrmEvent", "onUpdateOrder"); UnRegisterModuleDependences("sale", "OnBeforeOrderAdd", $this->MODULE_ID, "RetailCrmEvent", "onBeforeOrderAdd"); diff --git a/intaro.retailcrm/install/version.php b/intaro.retailcrm/install/version.php index a2d8faee..bb592d04 100644 --- a/intaro.retailcrm/install/version.php +++ b/intaro.retailcrm/install/version.php @@ -1,6 +1,6 @@ $arModuleVersion = array( - "VERSION" => "2.2.0", - "VERSION_DATE" => "2017-08-21 12:00:00" + "VERSION" => "2.2.1", + "VERSION_DATE" => "2017-09-01 12:00:00" ); diff --git a/intaro.retailcrm/lang/ru/install/step6.php b/intaro.retailcrm/lang/ru/install/step6.php index d52d84d6..19a978b2 100644 --- a/intaro.retailcrm/lang/ru/install/step6.php +++ b/intaro.retailcrm/lang/ru/install/step6.php @@ -6,7 +6,7 @@ $MESS ['INTAROCRM_INFO'] = ' через некоторое время по этим заказам будет подготовлены аналитические отчеты в Панели KPI.
- Новые заказы будут отправляться агентом ICrmOrderActions::uploadOrdersAgent(); + Новые заказы будут отправляться агентом RCrmActions::uploadOrdersAgent(); в retailCRM каждые 10 минут (интервал можно изменить в разделе Агенты).
diff --git a/intaro.retailcrm/updater.php b/intaro.retailcrm/updater.php deleted file mode 100644 index f4324e17..00000000 --- a/intaro.retailcrm/updater.php +++ /dev/null @@ -1,22 +0,0 @@ -