1
0
mirror of synced 2025-02-16 15:03:14 +03:00
This commit is contained in:
Евгений Тыщицкий 2016-10-06 17:34:35 +03:00
parent 02828f45e6
commit 3f858702c4
7 changed files with 75 additions and 59 deletions

View File

@ -1,3 +1,7 @@
## 2016-10-06 v.2.0.4
* Оптимизация History
* Исправлена ошибка выгрузки доставок при установке
## 2016-10-04 v.2.0.3
* fix состава отгрузки

View File

@ -443,6 +443,7 @@ class RetailCrmHistory
}
if (isset($order['externalId']) && $order['externalId']) {
$itemUpdate = false;
$newOrder = Bitrix\Sale\Order::load($order['externalId']);
if (!$newOrder instanceof \Bitrix\Sale\Order) {
@ -597,62 +598,67 @@ class RetailCrmHistory
//items
$basket = $newOrder->getBasket();
foreach ($order['items'] as $product) {
$item = self::getExistsItem($basket, 'catalog', $product['offer']['externalId']);
if (!$item) {
$item = $basket->createItem('catalog', $product['offer']['externalId']);
if ($item instanceof \Bitrix\Sale\Basket) {
$elem = self::getInfoElement();
$item->setFields(array(
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'LID' => \Bitrix\Main\Context::getCurrent()->getSite(),
'BASE_PRICE' => $product['initialPrice'],
'NAME' => $elem['NAME'],
'DETAIL_PAGE_URL' => $elem['URL']
));
} else {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'createItem', 'Error item add');
if (isset($order['items'])) {
$itemUpdate = true;
foreach ($order['items'] as $product) {
$item = self::getExistsItem($basket, 'catalog', $product['offer']['externalId']);
if (!$item) {
if($product['delete']){
continue;
}
$item = $basket->createItem('catalog', $product['offer']['externalId']);
if ($item instanceof \Bitrix\Sale\Basket) {
$elem = self::getInfoElement();
$item->setFields(array(
'CURRENCY' => \Bitrix\Currency\CurrencyManager::getBaseCurrency(),
'LID' => \Bitrix\Main\Context::getCurrent()->getSite(),
'BASE_PRICE' => $product['initialPrice'],
'NAME' => $elem['NAME'],
'DETAIL_PAGE_URL' => $elem['URL']
));
} else {
RCrmActions::eventLog('RetailCrmHistory::orderHistory', 'createItem', 'Error item add');
continue;
}
}
if ($product['delete']) {
$item->delete();
continue;
}
}
if ($product['quantity']) {
$item->setFieldNoDemand('QUANTITY', $product['quantity']);
}
if (array_key_exists('discount', $product) || array_key_exists('discountPercent', $product)) {
if (!isset($orderCrm)) {
try {
$orderCrm = $api->ordersGet($order['id'], 'id');
} catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog(
'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet::CurlException',
$e->getCode() . ': ' . $e->getMessage()
);
if ($product['quantity']) {
$item->setFieldNoDemand('QUANTITY', $product['quantity']);
}
if (array_key_exists('discount', $product) || array_key_exists('discountPercent', $product)) {
if (!isset($orderCrm)) {
try {
$orderCrm = $api->ordersGet($order['id'], 'id');
} catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog(
'RetailCrmHistory::orderHistory', 'RetailCrm\RestApi::ordersGet::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($itemCost) && $itemCost > 0) {
$item->setField('CUSTOM_PRICE', 'Y');
$item->setField('PRICE', $itemCost);
$item->setField('DISCOUNT_NAME', '');
$item->setField('DISCOUNT_VALUE', '');
}
}
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);
$item->setField('DISCOUNT_NAME', '');
$item->setField('DISCOUNT_VALUE', '');
}
$basket->save();
}
if ($product['delete']) {
$item->delete();
}
$basket->save();
}
$orderSumm = 0;
@ -678,7 +684,8 @@ class RetailCrmHistory
}
//delivery
if (array_key_exists('code', $order['delivery'])/* || array_key_exists('service', $order['delivery'])*/) {
if (array_key_exists('code', $order['delivery'])) {
$itemUpdate = true;
//если пусто, удаляем, если нет, update или add
if (!isset($orderCrm)) {
try {
@ -711,7 +718,9 @@ class RetailCrmHistory
Bitrix\Sale\OrderTable::update($order['externalId'], array('MARKED' => 'N', 'EMP_MARKED_ID' => '', 'REASON_MARKED' => ''));
self::updateShipmentItem($order['externalId']);
if ($itemUpdate) {
self::updateShipmentItem($order['externalId']);
}
if (function_exists('retailCrmAfterOrderSave')) {
retailCrmAfterOrderSave($order);

View File

@ -1 +1,2 @@
- fix состава отгрузки
- Оптимизация History
- Исправлена ошибка выгрузки доставок при установке

View File

@ -680,7 +680,8 @@ class intaro_retailcrm extends CModule
}
} elseif (htmlspecialchars(trim($_POST['delivery-types-export'])) == 'true') {//отправка доставок в црм
// send to intaro crm and save delivery types!
foreach ($optionsDelivTypes as $deliveryType) {
$arDeliveryServiceAll = \Bitrix\Sale\Delivery\Services\Manager::getActiveList();
foreach ($arResult['bitrixDeliveryTypesList'] as $deliveryType) {
$load = true;
try {
$this->RETAIL_CRM_API->deliveryTypesEdit(RCrmActions::clearArr(array(
@ -698,7 +699,8 @@ class intaro_retailcrm extends CModule
);
}
if ($load) {
foreach ($optionsDelivTypes as $deliveryService) {
$deliveryTypesArr[$deliveryType['ID']] = $deliveryType['ID'];
foreach ($arDeliveryServiceAll as $deliveryService) {
if ($deliveryService['PARENT_ID'] != 0 && $deliveryService['PARENT_ID'] == $deliveryType['ID']) {
$srv = explode(':', $deliveryService['CODE']);
if (count($srv) == 2) {
@ -710,7 +712,7 @@ class intaro_retailcrm extends CModule
)));
} catch (\RetailCrm\Exception\CurlException $e) {
RCrmActions::eventLog(
'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::deliveryServiceEdit::CurlException',
'intaro.crm/install/index.php', 'RetailCrm\ApiClient::deliveryServiceEdit::CurlException',
$e->getCode() . ': ' . $e->getMessage()
);
}

View File

@ -1,6 +1,6 @@
<?
$arModuleVersion = array(
"VERSION" => "2.0.3",
"VERSION_DATE" => "2016-10-04 18:00:00"
"VERSION" => "2.0.4",
"VERSION_DATE" => "2016-10-06 18:00:00"
);

View File

@ -19,7 +19,7 @@ $MESS ['PAYMENT_N'] = 'Не оплачен';
$MESS ['LEGAL_DETAIL'] = 'Юридические и банковские реквизиты';
$MESS ['ORDER_CUSTOM'] = 'Кастомные поля';
$MESS ['ORDER_UPLOAD'] = 'Повторная выгрузка заказов';
$MESS ['ORDER_NUMBERS'] = 'Номера заказов: ';
$MESS ['ORDER_NUMBER'] = 'Номера заказов: ';
$MESS ['ORDER_UPLOAD_INFO'] = 'Для загрузки всех заказов нажмите кнопку «Начать выгрузку». Или перечислите необходимые ID заказов через запятую, интервалы через тире. Например: 1, 3, 5-10, 12, 13... и т.д.';
$MESS ['ICRM_OPTIONS_SUBMIT_TITLE'] = 'Сохранить настройки';

View File

@ -930,7 +930,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<td colspan="2"><b><?php echo GetMessage('ORDER_UPLOAD'); ?></b></td>
</tr>
<tr>
<td class="adm-detail-content-cell-r"><?php echo GetMessage('ORDER_NUMBERS'); ?> <input id="order-nombers" style="width:86%" type="text" value="" name="orders"></td>
<td class="adm-detail-content-cell-r"><?php echo GetMessage('ORDER_NUMBER'); ?> <input id="order-nombers" style="width:86%" type="text" value="" name="orders"></td>
</tr>
</tbody>
</table>