v2.3.10
This commit is contained in:
parent
c81b2e0038
commit
cccc4072c7
@ -1,3 +1,8 @@
|
|||||||
|
## 2018-09-26 v.2.3.10
|
||||||
|
* Исправлена некорректная генерация скрипта UA
|
||||||
|
* Исправлена выгрузка остатков, если для товара указано более 50 складов
|
||||||
|
* Добавлен перехват исключений при сохранении заказа в Битрикс
|
||||||
|
|
||||||
## 2018-08-08 v.2.3.9
|
## 2018-08-08 v.2.3.9
|
||||||
* Устранено резервирование товара в отмененном заказе
|
* Устранено резервирование товара в отмененном заказе
|
||||||
* Исправлен некорректный расчет скидки на товар
|
* Исправлен некорректный расчет скидки на товар
|
||||||
|
@ -300,6 +300,7 @@ class RetailCrmEvent
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'payments', 'OrderID = ' . $arPayment['ID'] . '. Payment not found.');
|
RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'payments', 'OrderID = ' . $arPayment['ID'] . '. Payment not found.');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists($arPayment['ID'], $paymentsExternalIds)) {
|
if (!array_key_exists($arPayment['ID'], $paymentsExternalIds)) {
|
||||||
|
@ -46,9 +46,9 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
$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);
|
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||||
|
|
||||||
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
$api = new RetailCrm\ApiClient($api_host, $api_key);
|
||||||
|
|
||||||
$historyFilter = array();
|
$historyFilter = array();
|
||||||
$historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY);
|
$historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY);
|
||||||
|
|
||||||
@ -63,23 +63,23 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
$log = new Logger();
|
$log = new Logger();
|
||||||
$log->write($customerH, 'customerHistory');
|
$log->write($customerH, 'customerHistory');
|
||||||
|
|
||||||
if (count($customerH) == 0) {
|
if (count($customerH) == 0) {
|
||||||
if ($customerHistory['history']['totalPageCount'] > $customerHistory['history']['currentPage']) {
|
if ($customerHistory['history']['totalPageCount'] > $customerHistory['history']['currentPage']) {
|
||||||
$historyFilter['page'] = $customerHistory['history']['currentPage'] + 1;
|
$historyFilter['page'] = $customerHistory['history']['currentPage'] + 1;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$customers = self::assemblyCustomer($customerH);
|
$customers = self::assemblyCustomer($customerH);
|
||||||
|
|
||||||
$GLOBALS['RETAIL_CRM_HISTORY'] = true;
|
$GLOBALS['RETAIL_CRM_HISTORY'] = true;
|
||||||
|
|
||||||
$newUser = new CUser;
|
$newUser = new CUser;
|
||||||
|
|
||||||
foreach ($customers as $customer) {
|
foreach ($customers as $customer) {
|
||||||
if (function_exists('retailCrmBeforeCustomerSave')) {
|
if (function_exists('retailCrmBeforeCustomerSave')) {
|
||||||
$newResCustomer = retailCrmBeforeCustomerSave($customer);
|
$newResCustomer = retailCrmBeforeCustomerSave($customer);
|
||||||
@ -91,11 +91,11 @@ class RetailCrmHistory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($customer['deleted'])) {
|
if (isset($customer['deleted'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($customer['externalId'])) {
|
if (!isset($customer['externalId'])) {
|
||||||
if (!isset($customer['id'])) {
|
if (!isset($customer['id'])) {
|
||||||
continue;
|
continue;
|
||||||
@ -138,13 +138,13 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(RCrmActions::apiMethod($api, 'customersFixExternalIds', __METHOD__, array(array('id' => $customer['id'], 'externalId' => $registeredUserID))) == false) {
|
if(RCrmActions::apiMethod($api, 'customersFixExternalIds', __METHOD__, array(array('id' => $customer['id'], 'externalId' => $registeredUserID))) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer['externalId'] = $registeredUserID;
|
$customer['externalId'] = $registeredUserID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($customer['externalId'])) {
|
if (isset($customer['externalId'])) {
|
||||||
$arUser = array();
|
$arUser = array();
|
||||||
if (array_key_exists('firstName', $customer)) {
|
if (array_key_exists('firstName', $customer)) {
|
||||||
@ -156,11 +156,11 @@ class RetailCrmHistory
|
|||||||
if (array_key_exists('patronymic', $customer)) {
|
if (array_key_exists('patronymic', $customer)) {
|
||||||
$arUser["SECOND_NAME"] = $customer['patronymic'] ? RCrmActions::fromJSON($customer['patronymic']) : '';
|
$arUser["SECOND_NAME"] = $customer['patronymic'] ? RCrmActions::fromJSON($customer['patronymic']) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (array_key_exists('email', $customer)) {
|
// if (array_key_exists('email', $customer)) {
|
||||||
// $arUser["EMAIL"] = $customer['email'] ? RCrmActions::fromJSON($customer['email']) : '';
|
// $arUser["EMAIL"] = $customer['email'] ? RCrmActions::fromJSON($customer['email']) : '';
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (isset($customer['phones'])) {
|
if (isset($customer['phones'])) {
|
||||||
$user = CUser::GetList(($by = "ID"), ($order = "desc"), array('ID' => $customer['externalId']), array('FIELDS' => array('PERSONAL_PHONE', 'PERSONAL_MOBILE')))->fetch();
|
$user = CUser::GetList(($by = "ID"), ($order = "desc"), array('ID' => $customer['externalId']), array('FIELDS' => array('PERSONAL_PHONE', 'PERSONAL_MOBILE')))->fetch();
|
||||||
foreach ($customer['phones'] as $phone) {
|
foreach ($customer['phones'] as $phone) {
|
||||||
@ -199,19 +199,19 @@ class RetailCrmHistory
|
|||||||
if (!$u) {
|
if (!$u) {
|
||||||
RCrmActions::eventLog('RetailCrmHistory::customerHistory', 'Error update user', $newUser->LAST_ERROR);
|
RCrmActions::eventLog('RetailCrmHistory::customerHistory', 'Error update user', $newUser->LAST_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists('retailCrmAfterCustomerSave')) {
|
if (function_exists('retailCrmAfterCustomerSave')) {
|
||||||
retailCrmAfterCustomerSave($customer);
|
retailCrmAfterCustomerSave($customer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['RETAIL_CRM_HISTORY'] = false;
|
$GLOBALS['RETAIL_CRM_HISTORY'] = false;
|
||||||
|
|
||||||
//last id
|
//last id
|
||||||
$end = array_pop($customerH);
|
$end = array_pop($customerH);
|
||||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY, $end['id']);
|
COption::SetOptionString(self::$MODULE_ID, self::$CRM_CUSTOMER_HISTORY, $end['id']);
|
||||||
|
|
||||||
if ($customerHistory['pagination']['totalPageCount'] == 1) {
|
if ($customerHistory['pagination']['totalPageCount'] == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ class RetailCrmHistory
|
|||||||
$historyFilter['sinceId'] = $end['id'];
|
$historyFilter['sinceId'] = $end['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function orderHistory()
|
public static function orderHistory()
|
||||||
{
|
{
|
||||||
global $USER;
|
global $USER;
|
||||||
@ -249,7 +249,7 @@ class RetailCrmHistory
|
|||||||
$optionsDelivTypes = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_DELIVERY_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
|
$optionsPayStatuses = array_flip(unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_PAYMENT_STATUSES, 0))); // --statuses
|
||||||
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
$optionsOrderProps = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_PROPS, 0));
|
||||||
$optionsLegalDetails = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_LEGAL_DETAILS, 0));
|
$optionsLegalDetails = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_LEGAL_DETAILS, 0));
|
||||||
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
$optionsSitesList = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_SITES_LIST, 0));
|
||||||
$optionsOrderNumbers = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_NUMBERS, 0);
|
$optionsOrderNumbers = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_NUMBERS, 0);
|
||||||
$optionsCanselOrder = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CANSEL_ORDER, 0));
|
$optionsCanselOrder = unserialize(COption::GetOptionString(self::$MODULE_ID, self::$CRM_CANSEL_ORDER, 0));
|
||||||
@ -262,7 +262,7 @@ class RetailCrmHistory
|
|||||||
$historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY);
|
$historyStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY);
|
||||||
if ($historyStart && $historyStart > 0) {
|
if ($historyStart && $historyStart > 0) {
|
||||||
$historyFilter['sinceId'] = $historyStart;
|
$historyFilter['sinceId'] = $historyStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
$orderHistory = RCrmActions::apiMethod($api, 'ordersHistory', __METHOD__, $historyFilter);
|
$orderHistory = RCrmActions::apiMethod($api, 'ordersHistory', __METHOD__, $historyFilter);
|
||||||
@ -275,7 +275,7 @@ class RetailCrmHistory
|
|||||||
if (count($orderH) == 0) {
|
if (count($orderH) == 0) {
|
||||||
if ($orderHistory['history']['totalPageCount'] > $orderHistory['history']['currentPage']) {
|
if ($orderHistory['history']['totalPageCount'] > $orderHistory['history']['currentPage']) {
|
||||||
$historyFilter['page'] = $orderHistory['history']['currentPage'] + 1;
|
$historyFilter['page'] = $orderHistory['history']['currentPage'] + 1;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(RCrmActions::apiMethod($api, 'customersFixExternalIds', __METHOD__, array(array('id' => $order['customer']['id'], 'externalId' => $registeredUserID))) == false) {
|
if(RCrmActions::apiMethod($api, 'customersFixExternalIds', __METHOD__, array(array('id' => $order['customer']['id'], 'externalId' => $registeredUserID))) == false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
if (empty($site)) {
|
if (empty($site)) {
|
||||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Site = ' . $order['site'] . ' not found in setting. Order crm id=' . $order['id']);
|
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::create', 'Site = ' . $order['site'] . ' not found in setting. Order crm id=' . $order['id']);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,12 +439,12 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
if (empty($site)) {
|
if (empty($site)) {
|
||||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::edit', 'Site = ' . $order['site'] . ' not found in setting. Order number=' . $order['number']);
|
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'Bitrix\Sale\Order::edit', 'Site = ' . $order['site'] . ' not found in setting. Order number=' . $order['number']);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$personType = $newOrder->getField('PERSON_TYPE_ID');
|
$personType = $newOrder->getField('PERSON_TYPE_ID');
|
||||||
if (isset($order['orderType']) && $order['orderType']) {
|
if (isset($order['orderType']) && $order['orderType']) {
|
||||||
$nType = array();
|
$nType = array();
|
||||||
$tList = RCrmActions::OrderTypesList(array(array('LID' => $site)));
|
$tList = RCrmActions::OrderTypesList(array(array('LID' => $site)));
|
||||||
foreach($tList as $type){
|
foreach($tList as $type){
|
||||||
@ -492,7 +492,7 @@ class RetailCrmHistory
|
|||||||
$nProps[] = $orderProp;
|
$nProps[] = $orderProp;
|
||||||
}
|
}
|
||||||
$propertyCollectionArr['properties'] = $nProps;
|
$propertyCollectionArr['properties'] = $nProps;
|
||||||
|
|
||||||
if ($propsRemove) {//delete props
|
if ($propsRemove) {//delete props
|
||||||
foreach ($propertyCollectionArr['properties'] as $orderProp) {
|
foreach ($propertyCollectionArr['properties'] as $orderProp) {
|
||||||
if ($orderProp['PROPS_GROUP_ID'] == 0) {
|
if ($orderProp['PROPS_GROUP_ID'] == 0) {
|
||||||
@ -505,7 +505,7 @@ class RetailCrmHistory
|
|||||||
$orderDump = $order;
|
$orderDump = $order;
|
||||||
$order = $orderCrm['order'];
|
$order = $orderCrm['order'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$propsKey = array();
|
$propsKey = array();
|
||||||
foreach ($propertyCollectionArr['properties'] as $prop) {
|
foreach ($propertyCollectionArr['properties'] as $prop) {
|
||||||
if ($prop['PROPS_GROUP_ID'] != 0) {
|
if ($prop['PROPS_GROUP_ID'] != 0) {
|
||||||
@ -539,7 +539,7 @@ class RetailCrmHistory
|
|||||||
$order['fio'] = trim(implode(' ', $newFio));
|
$order['fio'] = trim(implode(' ', $newFio));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//optionsOrderProps
|
//optionsOrderProps
|
||||||
if ($optionsOrderProps[$personType]) {
|
if ($optionsOrderProps[$personType]) {
|
||||||
foreach ($optionsOrderProps[$personType] as $key => $orderProp) {
|
foreach ($optionsOrderProps[$personType] as $key => $orderProp) {
|
||||||
@ -661,7 +661,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
if ($product['delete']) {
|
if ($product['delete']) {
|
||||||
$item->delete();
|
$item->delete();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
$orderSumm = 0;
|
$orderSumm = 0;
|
||||||
foreach ($basket as $item) {
|
foreach ($basket as $item) {
|
||||||
$orderSumm += $item->getFinalPrice();
|
$orderSumm += $item->getFinalPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('cost', $order['delivery'])) {
|
if (array_key_exists('cost', $order['delivery'])) {
|
||||||
@ -734,28 +734,15 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($orderCrm)) {
|
if (isset($orderCrm)) {
|
||||||
unset($orderCrm);
|
unset($orderCrm);
|
||||||
}
|
}
|
||||||
|
|
||||||
$newOrder->setField('PRICE', $orderSumm);
|
$newOrder->setField('PRICE', $orderSumm);
|
||||||
$newOrder->save();
|
self::orderSave($newOrder);
|
||||||
|
|
||||||
if ($optionsOrderNumbers == 'Y' && isset($order['number'])) {
|
if ($optionsOrderNumbers == 'Y' && isset($order['number'])) {
|
||||||
$searchFilter = array(
|
|
||||||
'filter' => array('ACCOUNT_NUMBER' => $order['number']),
|
|
||||||
'select' => array('ID'),
|
|
||||||
);
|
|
||||||
$searchOrder = \Bitrix\Sale\OrderTable::GetList($searchFilter)->fetch();
|
|
||||||
if (!empty($searchOrder)) {
|
|
||||||
if ($searchOrder['ID'] != $order['externalId']) {
|
|
||||||
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'setField("ACCOUNT_NUMBER")', 'Error order load id=' . $order['externalId']) . '. Number ' . $order['number'] . ' already exists';
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newOrder->setField('ACCOUNT_NUMBER', $order['number']);
|
$newOrder->setField('ACCOUNT_NUMBER', $order['number']);
|
||||||
$newOrder->save();
|
self::orderSave($newOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($newHistoryPayments)) {
|
if (!empty($newHistoryPayments)) {
|
||||||
@ -767,13 +754,13 @@ class RetailCrmHistory
|
|||||||
$newHistoryPayments[$orderPayment->getField('XML_ID')]['externalId'] = $paymentExternalId;
|
$newHistoryPayments[$orderPayment->getField('XML_ID')]['externalId'] = $paymentExternalId;
|
||||||
RCrmActions::apiMethod($api, 'paymentEditById', __METHOD__, $newHistoryPayments[$orderPayment->getField('XML_ID')]);
|
RCrmActions::apiMethod($api, 'paymentEditById', __METHOD__, $newHistoryPayments[$orderPayment->getField('XML_ID')]);
|
||||||
\Bitrix\Sale\Internals\PaymentTable::update($paymentExternalId, array('XML_ID' => ''));
|
\Bitrix\Sale\Internals\PaymentTable::update($paymentExternalId, array('XML_ID' => ''));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$order['externalId']) {
|
if (!$order['externalId']) {
|
||||||
if(RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false){
|
if (RCrmActions::apiMethod($api, 'ordersFixExternalIds', __METHOD__, array(array('id' => $order['id'], 'externalId' => $newOrder->getId()))) == false){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -799,13 +786,13 @@ class RetailCrmHistory
|
|||||||
$historyFilter['sinceId'] = $end['id'];
|
$historyFilter['sinceId'] = $end['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function assemblyCustomer($customerHistory)
|
public static function assemblyCustomer($customerHistory)
|
||||||
{
|
{
|
||||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||||
$fields = array();
|
$fields = array();
|
||||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
||||||
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
|
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
|
||||||
foreach ($objects->fields->field as $object) {
|
foreach ($objects->fields->field as $object) {
|
||||||
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
||||||
}
|
}
|
||||||
@ -813,17 +800,17 @@ class RetailCrmHistory
|
|||||||
$customers = array();
|
$customers = array();
|
||||||
foreach ($customerHistory as $change) {
|
foreach ($customerHistory as $change) {
|
||||||
$change['customer'] = self::removeEmpty($change['customer']);
|
$change['customer'] = self::removeEmpty($change['customer']);
|
||||||
if ($customers[$change['customer']['id']]) {
|
if ($customers[$change['customer']['id']]) {
|
||||||
$customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']);
|
$customers[$change['customer']['id']] = array_merge($customers[$change['customer']['id']], $change['customer']);
|
||||||
} else {
|
} else {
|
||||||
$customers[$change['customer']['id']] = $change['customer'];
|
$customers[$change['customer']['id']] = $change['customer'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($change['customer']['contragent']['contragentType']) {
|
if ($change['customer']['contragent']['contragentType']) {
|
||||||
$change['customer']['contragentType'] = self::newValue($change['customer']['contragent']['contragentType']);
|
$change['customer']['contragentType'] = self::newValue($change['customer']['contragent']['contragentType']);
|
||||||
unset($change['customer']['contragent']);
|
unset($change['customer']['contragent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fields['customer'][$change['field']] == 'phones') {
|
if ($fields['customer'][$change['field']] == 'phones') {
|
||||||
$key = count($customers[$change['customer']['id']]['phones']);
|
$key = count($customers[$change['customer']['id']]['phones']);
|
||||||
if (isset($change['oldValue'])) {
|
if (isset($change['oldValue'])) {
|
||||||
@ -840,7 +827,7 @@ class RetailCrmHistory
|
|||||||
} elseif ($fields['customer'][$change['field']]) {
|
} elseif ($fields['customer'][$change['field']]) {
|
||||||
$customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']);
|
$customers[$change['customer']['id']][$fields['customer'][$change['field']]] = self::newValue($change['newValue']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($change['created'])) {
|
if (isset($change['created'])) {
|
||||||
$customers[$change['customer']['id']]['create'] = 1;
|
$customers[$change['customer']['id']]['create'] = 1;
|
||||||
}
|
}
|
||||||
@ -853,12 +840,12 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return $customers;
|
return $customers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function assemblyOrder($orderHistory)
|
public static function assemblyOrder($orderHistory)
|
||||||
{
|
{
|
||||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
||||||
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
|
$objects = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml');
|
||||||
foreach ($objects->fields->field as $object) {
|
foreach ($objects->fields->field as $object) {
|
||||||
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
$fields[(string)$object["group"]][(string)$object["id"]] = (string)$object;
|
||||||
}
|
}
|
||||||
@ -870,13 +857,13 @@ class RetailCrmHistory
|
|||||||
$items = array();
|
$items = array();
|
||||||
foreach ($change['order']['items'] as $item) {
|
foreach ($change['order']['items'] as $item) {
|
||||||
if (isset($change['created'])) {
|
if (isset($change['created'])) {
|
||||||
$item['create'] = 1;
|
$item['create'] = 1;
|
||||||
}
|
}
|
||||||
$items[$item['id']] = $item;
|
$items[$item['id']] = $item;
|
||||||
}
|
}
|
||||||
$change['order']['items'] = $items;
|
$change['order']['items'] = $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($change['order']['payments']) {
|
if ($change['order']['payments']) {
|
||||||
$payments = array();
|
$payments = array();
|
||||||
foreach ($change['order']['payments'] as $payment) {
|
foreach ($change['order']['payments'] as $payment) {
|
||||||
@ -884,7 +871,7 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
$change['order']['payments'] = $payments;
|
$change['order']['payments'] = $payments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($change['order']['contragent']) && count($change['order']['contragent']) > 0) {
|
if (isset($change['order']['contragent']) && count($change['order']['contragent']) > 0) {
|
||||||
foreach ($change['order']['contragent'] as $name => $value) {
|
foreach ($change['order']['contragent'] as $name => $value) {
|
||||||
$change['order'][$name] = self::newValue($value);
|
$change['order'][$name] = self::newValue($value);
|
||||||
@ -892,14 +879,14 @@ class RetailCrmHistory
|
|||||||
unset($change['order']['contragent']);
|
unset($change['order']['contragent']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($orders[$change['order']['id']]) {
|
if ($orders[$change['order']['id']]) {
|
||||||
$orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']);
|
$orders[$change['order']['id']] = array_merge($orders[$change['order']['id']], $change['order']);
|
||||||
} else {
|
} else {
|
||||||
$orders[$change['order']['id']] = $change['order'];
|
$orders[$change['order']['id']] = $change['order'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($change['item']) {
|
if ($change['item']) {
|
||||||
if ($orders[$change['order']['id']]['items'][$change['item']['id']]) {
|
if ($orders[$change['order']['id']]['items'][$change['item']['id']]) {
|
||||||
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
|
$orders[$change['order']['id']]['items'][$change['item']['id']] = array_merge($orders[$change['order']['id']]['items'][$change['item']['id']], $change['item']);
|
||||||
} else {
|
} else {
|
||||||
$orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item'];
|
$orders[$change['order']['id']]['items'][$change['item']['id']] = $change['item'];
|
||||||
@ -916,7 +903,7 @@ class RetailCrmHistory
|
|||||||
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
|
$orders[$change['order']['id']]['items'][$change['item']['id']][$fields['item'][$change['field']]] = $change['newValue'];
|
||||||
}
|
}
|
||||||
} elseif ($change['payment']) {
|
} elseif ($change['payment']) {
|
||||||
if ($orders[$change['order']['id']]['payments'][$change['payment']['id']]) {
|
if ($orders[$change['order']['id']]['payments'][$change['payment']['id']]) {
|
||||||
$orders[$change['order']['id']]['payments'][$change['payment']['id']] = array_merge($orders[$change['order']['id']]['payments'][$change['payment']['id']], $change['payment']);
|
$orders[$change['order']['id']]['payments'][$change['payment']['id']] = array_merge($orders[$change['order']['id']]['payments'][$change['payment']['id']], $change['payment']);
|
||||||
} else {
|
} else {
|
||||||
$orders[$change['order']['id']]['payments'][$change['payment']['id']] = $change['payment'];
|
$orders[$change['order']['id']]['payments'][$change['payment']['id']] = $change['payment'];
|
||||||
@ -956,9 +943,9 @@ class RetailCrmHistory
|
|||||||
if (isset($change['deleted'])) {
|
if (isset($change['deleted'])) {
|
||||||
$orders[$change['order']['id']]['deleted'] = 1;
|
$orders[$change['order']['id']]['deleted'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,7 +955,7 @@ class RetailCrmHistory
|
|||||||
* @param order object
|
* @param order object
|
||||||
* @param options delivery types
|
* @param options delivery types
|
||||||
* @param order from crm
|
* @param order from crm
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function deliveryUpdate(Bitrix\Sale\Order $order, $optionsDelivTypes, $orderCrm)
|
public static function deliveryUpdate(Bitrix\Sale\Order $order, $optionsDelivTypes, $orderCrm)
|
||||||
@ -1038,9 +1025,9 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update shipment item colletion
|
* Update shipment item colletion
|
||||||
*
|
*
|
||||||
* @param \Bitrix\Sale\Order $order
|
* @param \Bitrix\Sale\Order $order
|
||||||
*
|
*
|
||||||
* @return void | boolean
|
* @return void | boolean
|
||||||
*/
|
*/
|
||||||
public static function shipmentItemReset($order)
|
public static function shipmentItemReset($order)
|
||||||
@ -1079,9 +1066,9 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unreserve items if order canceled
|
* Unreserve items if order canceled
|
||||||
*
|
*
|
||||||
* @param \Bitrix\Sale\Order $order
|
* @param \Bitrix\Sale\Order $order
|
||||||
*
|
*
|
||||||
* @return void | boolean
|
* @return void | boolean
|
||||||
*/
|
*/
|
||||||
public static function unreserveShipment($order)
|
public static function unreserveShipment($order)
|
||||||
@ -1107,11 +1094,11 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update payment in order
|
* Update payment in order
|
||||||
*
|
*
|
||||||
* @param object $order
|
* @param object $order
|
||||||
* @param array $paymentsCrm
|
* @param array $paymentsCrm
|
||||||
* @param array $newHistoryPayments
|
* @param array $newHistoryPayments
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function paymentsUpdate($order, $paymentsCrm, &$newHistoryPayments = array())
|
public static function paymentsUpdate($order, $paymentsCrm, &$newHistoryPayments = array())
|
||||||
@ -1128,7 +1115,7 @@ class RetailCrmHistory
|
|||||||
$data = $paymentData->getFields()->getValues();
|
$data = $paymentData->getFields()->getValues();
|
||||||
$paymentsList[$data['ID']] = $paymentData;
|
$paymentsList[$data['ID']] = $paymentData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//data from crm
|
//data from crm
|
||||||
$paySumm = 0;
|
$paySumm = 0;
|
||||||
foreach ($paymentsCrm['payments'] as $paymentCrm) {
|
foreach ($paymentsCrm['payments'] as $paymentCrm) {
|
||||||
@ -1177,7 +1164,7 @@ class RetailCrmHistory
|
|||||||
}
|
}
|
||||||
$payment->delete();
|
$payment->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($paymentsCrm['totalSumm'] == $paySumm) {
|
if ($paymentsCrm['totalSumm'] == $paySumm) {
|
||||||
$order->setFieldNoDemand('PAYED', 'Y');
|
$order->setFieldNoDemand('PAYED', 'Y');
|
||||||
} else {
|
} else {
|
||||||
@ -1212,7 +1199,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return $outputArray;
|
return $outputArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setProp($obj, $value = '', $prop = '')
|
public static function setProp($obj, $value = '', $prop = '')
|
||||||
{
|
{
|
||||||
if (!isset($obj)) {
|
if (!isset($obj)) {
|
||||||
@ -1228,7 +1215,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getExistsItem($basket, $moduleId, $productId)
|
public static function getExistsItem($basket, $moduleId, $productId)
|
||||||
{
|
{
|
||||||
foreach ($basket as $basketItem) {
|
foreach ($basket as $basketItem) {
|
||||||
@ -1241,7 +1228,7 @@ class RetailCrmHistory
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInfoElement($offerId)
|
public static function getInfoElement($offerId)
|
||||||
{
|
{
|
||||||
$elementInfo = CIBlockElement::GetByID($offerId)->fetch();
|
$elementInfo = CIBlockElement::GetByID($offerId)->fetch();
|
||||||
@ -1260,10 +1247,32 @@ class RetailCrmHistory
|
|||||||
'XML_ID' => $elementInfo["XML_ID"],
|
'XML_ID' => $elementInfo["XML_ID"],
|
||||||
'IBLOCK_XML_ID' => $elementInfo["IBLOCK_EXTERNAL_ID"]
|
'IBLOCK_XML_ID' => $elementInfo["IBLOCK_EXTERNAL_ID"]
|
||||||
);
|
);
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @param $order
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static function orderSave($order)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$order->save();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
RCrmActions::eventLog(
|
||||||
|
'RetailCrmHistory::orderHistory',
|
||||||
|
'Order saving',
|
||||||
|
$exception->getMessage()
|
||||||
|
);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class RetailUser extends CUser
|
class RetailUser extends CUser
|
||||||
{
|
{
|
||||||
|
@ -96,45 +96,48 @@ class RetailCrmInventories
|
|||||||
}
|
}
|
||||||
|
|
||||||
$elems = array();
|
$elems = array();
|
||||||
foreach ($products as $product) {
|
$chunkStores = array_chunk($stores, 50);
|
||||||
if (count($product['offers']) > 0) {
|
foreach ($chunkStores as $stores) {
|
||||||
$elems = array_merge($elems, $product['offers']);
|
foreach ($products as $product) {
|
||||||
} else {
|
if (count($product['offers']) > 0) {
|
||||||
$elems[] = $product['ID'];
|
$elems = array_merge($elems, $product['offers']);
|
||||||
|
} else {
|
||||||
|
$elems[] = $product['ID'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$invUpload = array();
|
|
||||||
$dbStoreProduct = CCatalogStoreProduct::GetList(
|
|
||||||
array(),
|
|
||||||
array('PRODUCT_ID' => $elems, 'STORE_ID' => array_keys($stores)),
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
array('PRODUCT_ID', 'STORE_ID', 'AMOUNT')
|
|
||||||
);
|
|
||||||
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
|
|
||||||
if (!isset($invUpload[$arStoreProduct['PRODUCT_ID']])) {
|
|
||||||
$invUpload[$arStoreProduct['PRODUCT_ID']] = array(
|
|
||||||
'externalId' => $arStoreProduct['PRODUCT_ID']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$invUpload[$arStoreProduct['PRODUCT_ID']]['stores'][] = array(
|
|
||||||
'code' => $stores[$arStoreProduct['STORE_ID']],
|
|
||||||
'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');
|
|
||||||
|
|
||||||
foreach ($shops as $shop) {
|
|
||||||
RCrmActions::apiMethod($api, 'storeInventoriesUpload', __METHOD__, $chunk, $shop);
|
|
||||||
time_nanosleep(0, 250000000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1;
|
$invUpload = array();
|
||||||
|
$dbStoreProduct = CCatalogStoreProduct::GetList(
|
||||||
|
array(),
|
||||||
|
array('PRODUCT_ID' => $elems, 'STORE_ID' => array_keys($stores)),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
array('PRODUCT_ID', 'STORE_ID', 'AMOUNT')
|
||||||
|
);
|
||||||
|
while ($arStoreProduct = $dbStoreProduct->Fetch()) {
|
||||||
|
if (!isset($invUpload[$arStoreProduct['PRODUCT_ID']])) {
|
||||||
|
$invUpload[$arStoreProduct['PRODUCT_ID']] = array(
|
||||||
|
'externalId' => $arStoreProduct['PRODUCT_ID']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$invUpload[$arStoreProduct['PRODUCT_ID']]['stores'][] = array(
|
||||||
|
'code' => $stores[$arStoreProduct['STORE_ID']],
|
||||||
|
'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');
|
||||||
|
|
||||||
|
foreach ($shops as $shop) {
|
||||||
|
RCrmActions::apiMethod($api, 'storeInventoriesUpload', __METHOD__, $chunk, $shop);
|
||||||
|
time_nanosleep(0, 250000000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1;
|
||||||
|
}
|
||||||
} while($dbResProductsIds->NavPageNomer < $dbResProductsIds->NavPageCount);
|
} while($dbResProductsIds->NavPageNomer < $dbResProductsIds->NavPageCount);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,9 +68,9 @@ class RetailCrmUa
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
$ua .= "ga('ecommerce:send');";
|
$ua .= "ga('ecommerce:send');";
|
||||||
|
$ua .= "</script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ua .= "</script>";
|
|
||||||
|
|
||||||
$APPLICATION->AddHeadString($ua);
|
$APPLICATION->AddHeadString($ua);
|
||||||
}
|
}
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
- Устранено резервирование товара в отмененном заказе
|
- Исправлена некорректная генерация скрипта UA
|
||||||
- Исправлен некорректный расчет скидки на товар
|
- Улучшена выгрузка остатков по складам в retailCRM
|
||||||
|
- Улучшена обработка истории изменений заказов
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?
|
<?
|
||||||
$arModuleVersion = array(
|
$arModuleVersion = array(
|
||||||
"VERSION" => "2.3.9",
|
"VERSION" => "2.3.10",
|
||||||
"VERSION_DATE" => "2018-08-08 11:00:00"
|
"VERSION_DATE" => "2018-09-26 13:30:00"
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user