1
0
mirror of synced 2025-01-19 17:31:43 +03:00

Merge pull request #49 from iyzoer/master

v2.3.10
This commit is contained in:
Alex Lushpai 2018-09-26 13:59:53 +03:00 committed by GitHub
commit 71a057387d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 141 additions and 122 deletions

View File

@ -1,3 +1,8 @@
## 2018-09-26 v.2.3.10
* Исправлена некорректная генерация скрипта UA
* Исправлена выгрузка остатков, если для товара указано более 50 складов
* Добавлен перехват исключений при сохранении заказа в Битрикс
## 2018-08-08 v.2.3.9
* Устранено резервирование товара в отмененном заказе
* Исправлен некорректный расчет скидки на товар

View File

@ -300,6 +300,7 @@ class RetailCrmEvent
}
} else {
RCrmActions::eventLog('RetailCrmEvent::paymentSave', 'payments', 'OrderID = ' . $arPayment['ID'] . '. Payment not found.');
return;
}
if (!array_key_exists($arPayment['ID'], $paymentsExternalIds)) {

View File

@ -738,24 +738,11 @@ class RetailCrmHistory
}
$newOrder->setField('PRICE', $orderSumm);
$newOrder->save();
self::orderSave($newOrder);
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->save();
self::orderSave($newOrder);
}
if (!empty($newHistoryPayments)) {
@ -773,7 +760,7 @@ class RetailCrmHistory
}
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;
}
}
@ -1263,6 +1250,28 @@ class RetailCrmHistory
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

View File

@ -96,45 +96,48 @@ class RetailCrmInventories
}
$elems = array();
foreach ($products as $product) {
if (count($product['offers']) > 0) {
$elems = array_merge($elems, $product['offers']);
} else {
$elems[] = $product['ID'];
$chunkStores = array_chunk($stores, 50);
foreach ($chunkStores as $stores) {
foreach ($products as $product) {
if (count($product['offers']) > 0) {
$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 = 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']]]),
);
}
$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');
//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);
foreach ($shops as $shop) {
RCrmActions::apiMethod($api, 'storeInventoriesUpload', __METHOD__, $chunk, $shop);
time_nanosleep(0, 250000000);
}
}
}
$arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1;
$arNavStatParams['iNumPage'] = $dbResProductsIds->NavPageNomer + 1;
}
} while($dbResProductsIds->NavPageNomer < $dbResProductsIds->NavPageCount);
}
} else {

View File

@ -68,9 +68,9 @@ class RetailCrmUa
";
}
$ua .= "ga('ecommerce:send');";
$ua .= "</script>";
}
}
$ua .= "</script>";
$APPLICATION->AddHeadString($ua);
}

View File

@ -1,2 +1,3 @@
- Устранено резервирование товара в отмененном заказе
- Исправлен некорректный расчет скидки на товар
- Исправлена некорректная генерация скрипта UA
- Улучшена выгрузка остатков по складам в retailCRM
- Улучшена обработка истории изменений заказов

View File

@ -1,5 +1,5 @@
<?
$arModuleVersion = array(
"VERSION" => "2.3.9",
"VERSION_DATE" => "2018-08-08 11:00:00"
"VERSION" => "2.3.10",
"VERSION_DATE" => "2018-09-26 13:30:00"
);