1
0
mirror of synced 2024-11-29 08:46:09 +03:00

Merge pull request #240 from Chazovs/5.8.5

5.8.5
This commit is contained in:
Alex Lushpai 2022-02-03 16:50:23 +03:00 committed by GitHub
commit a2804d82c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 82 additions and 60 deletions

View File

@ -1,3 +1,12 @@
## 2022-02-03 v.5.8.5
* Исправление ошибка восстановления отсутствующей отгрузки во время выгрузки истории из системы
* Исправлена ошибка обработки магазинов с кодами, содержащими ".", в настройках модуля
* Исправлен баг выгрузки заказов, связанный с неверным указанием namespace для LocationTable
* При обмене данными итоговая стоимость доставки теперь указывается принудительно
* Исправлена ошибка генерации icml для проиндексированных каталогов с простыми товарами
* Исправлена ошибка выгрузки клиентов, при которой одни и те же клиенты могли попасть в лист выгрузки повторно
* Исправления в документации
## 2021-10-15 v.5.8.4 ## 2021-10-15 v.5.8.4
* Исправление некорректной генерации каталога при повторных запусках генерации * Исправление некорректной генерации каталога при повторных запусках генерации

View File

@ -6,7 +6,7 @@
Bitrix module Bitrix module
============= =============
Bitrix module for interaction with [RetailCRM](http://www.retailcrm.ru) Bitrix module for interaction with [RetailCRM](https://www.retailcrm.ru)
Module allows: Module allows:
@ -19,4 +19,4 @@ Installation
You should install module through [Bitrix.Marketplace](http://marketplace.1c-bitrix.ru/solutions/intaro.retailcrm/). You should install module through [Bitrix.Marketplace](http://marketplace.1c-bitrix.ru/solutions/intaro.retailcrm/).
[Setup guide](https://docs.retailcrm.ru/ru/Users/Integration/SiteModules/1CBitrix) [Setup guide](https://docs.retailcrm.ru/Users/Integration/SiteModules/1CBitrix)

View File

@ -532,7 +532,7 @@ class RetailCrmHistory
continue; continue;
} }
$site = self::getSite($order['site']); $site = self::getSite($order['site']);
if (null === $site) { if (null === $site) {
@ -1229,7 +1229,7 @@ class RetailCrmHistory
return false; return false;
} }
/** /**
* @param string $shopCode * @param string $shopCode
* *
@ -1238,18 +1238,18 @@ class RetailCrmHistory
public static function getSite(string $shopCode): ?string public static function getSite(string $shopCode): ?string
{ {
$optionsSitesList = RetailcrmConfigProvider::getSitesList(); $optionsSitesList = RetailcrmConfigProvider::getSitesList();
if ($optionsSitesList) { if ($optionsSitesList) {
$searchResult = array_search($shopCode, $optionsSitesList, true); $searchResult = array_search($shopCode, $optionsSitesList, true);
return is_string($searchResult) ? $searchResult : null; return is_string($searchResult) ? $searchResult : null;
} }
$defaultSite = CSite::GetDefSite(); $defaultSite = CSite::GetDefSite();
return is_string($defaultSite) ? $defaultSite : null; return is_string($defaultSite) ? $defaultSite : null;
} }
/** /**
* @param $array * @param $array
* @param $value * @param $value
@ -1493,7 +1493,7 @@ class RetailCrmHistory
return $orders; return $orders;
} }
/** /**
* Filters out history by these terms: * Filters out history by these terms:
* - Changes from current API key will be added only if CMS changes are more actual than history. * - Changes from current API key will be added only if CMS changes are more actual than history.
@ -1512,7 +1512,7 @@ class RetailCrmHistory
$history = []; $history = [];
$organizedHistory = []; $organizedHistory = [];
$notOurChanges = []; $notOurChanges = [];
foreach ($historyEntries as $entry) { foreach ($historyEntries as $entry) {
if (!isset($entry[$recordType]['externalId'])) { if (!isset($entry[$recordType]['externalId'])) {
if ($entry['source'] == 'api' if ($entry['source'] == 'api'
@ -1522,23 +1522,23 @@ class RetailCrmHistory
) { ) {
continue; continue;
} }
$history[] = $entry; $history[] = $entry;
continue; continue;
} }
$externalId = $entry[$recordType]['externalId']; $externalId = $entry[$recordType]['externalId'];
$field = $entry['field']; $field = $entry['field'];
if (!isset($organizedHistory[$externalId])) { if (!isset($organizedHistory[$externalId])) {
$organizedHistory[$externalId] = []; $organizedHistory[$externalId] = [];
} }
if (!isset($notOurChanges[$externalId])) { if (!isset($notOurChanges[$externalId])) {
$notOurChanges[$externalId] = []; $notOurChanges[$externalId] = [];
} }
if ($entry['source'] == 'api' if ($entry['source'] == 'api'
&& isset($entry['apiKey']['current']) && isset($entry['apiKey']['current'])
&& $entry['apiKey']['current'] == true && $entry['apiKey']['current'] == true
@ -1553,16 +1553,16 @@ class RetailCrmHistory
$notOurChanges[$externalId][$field] = true; $notOurChanges[$externalId][$field] = true;
} }
} }
unset($notOurChanges); unset($notOurChanges);
foreach ($organizedHistory as $historyChunk) { foreach ($organizedHistory as $historyChunk) {
$history = array_merge($history, $historyChunk); $history = array_merge($history, $historyChunk);
} }
return $history; return $history;
} }
/** /**
* Update shipment in order * Update shipment in order
* *
@ -1623,24 +1623,28 @@ class RetailCrmHistory
$shipmentColl = $order->getShipmentCollection(); $shipmentColl = $order->getShipmentCollection();
if ($delivery) { if ($delivery) {
if (!$update) { //В коллекции всегда есть одна скрытая системная доставка, к которой относятся нераспределенные товары
//Поэтому, если есть только системная доставка, то нужно создать новую
if (!$update || $shipmentColl->count() === 1) {
$shipment = $shipmentColl->createItem($delivery); $shipment = $shipmentColl->createItem($delivery);
$shipment->setFields(array( $shipment->setFields([
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'], 'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'CURRENCY' => $order->getCurrency(), 'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'DELIVERY_NAME' => $delivery->getName(), 'CURRENCY' => $order->getCurrency(),
'DELIVERY_NAME' => $delivery->getName(),
'CUSTOM_PRICE_DELIVERY' => 'Y' 'CUSTOM_PRICE_DELIVERY' => 'Y'
)); ]);
} else { } else {
foreach ($shipmentColl as $shipment) { foreach ($shipmentColl as $shipment) {
if (!$shipment->isSystem()) { if (!$shipment->isSystem()) {
$shipment->setFields(array( $shipment->setFields([
'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'], 'BASE_PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'CURRENCY' => $order->getCurrency(), 'PRICE_DELIVERY' => $orderCrm['delivery']['cost'],
'DELIVERY_ID' => $deliveryId, 'CURRENCY' => $order->getCurrency(),
'DELIVERY_NAME' => $delivery->getName(), 'DELIVERY_ID' => $deliveryId,
'DELIVERY_NAME' => $delivery->getName(),
'CUSTOM_PRICE_DELIVERY' => 'Y' 'CUSTOM_PRICE_DELIVERY' => 'Y'
)); ]);
} }
} }
} }

View File

@ -11,6 +11,7 @@ use Bitrix\Sale\Order;
use RetailCrm\ApiClient; use RetailCrm\ApiClient;
use Intaro\RetailCrm\Service\ManagerService; use Intaro\RetailCrm\Service\ManagerService;
use RetailCrm\Response\ApiResponse; use RetailCrm\Response\ApiResponse;
use \Bitrix\Sale\Location\Name\LocationTable as LocationTableName;
IncludeModuleLangFile(__FILE__); IncludeModuleLangFile(__FILE__);
@ -135,12 +136,12 @@ class RetailCrmOrder
} }
} }
$location = LocationTable::getList([ $location = LocationTableName::getList([
'filter' => ['=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru'] 'filter' => ['=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru']
])->fetch(); ])->fetch();
if (count($countrys) > 0) { if (count($countrys) > 0) {
$countryOrder = LocationTable::getList([ $countryOrder = LocationTableName::getList([
'filter' => ['=LOCATION_ID' => $arLoc['COUNTRY_ID'], 'LANGUAGE_ID' => 'ru'] 'filter' => ['=LOCATION_ID' => $arLoc['COUNTRY_ID'], 'LANGUAGE_ID' => 'ru']
])->fetch(); ])->fetch();
if(isset($countrys[$countryOrder['NAME']])){ if(isset($countrys[$countryOrder['NAME']])){
@ -161,7 +162,7 @@ class RetailCrmOrder
//deliverys //deliverys
if (array_key_exists($arOrder['DELIVERYS'][0]['id'], $arParams['optionsDelivTypes'])) { if (array_key_exists($arOrder['DELIVERYS'][0]['id'], $arParams['optionsDelivTypes'])) {
$order['delivery']['code'] = $arParams['optionsDelivTypes'][$arOrder['DELIVERYS'][0]['id']]; $order['delivery']['code'] = $arParams['optionsDelivTypes'][$arOrder['DELIVERYS'][0]['id']];
if (isset($arOrder['DELIVERYS'][0]['service']) && $arOrder['DELIVERYS'][0]['service'] != '') { if (isset($arOrder['DELIVERYS'][0]['service']) && $arOrder['DELIVERYS'][0]['service'] != '') {
$order['delivery']['service']['code'] = $arOrder['DELIVERYS'][0]['service']; $order['delivery']['service']['code'] = $arOrder['DELIVERYS'][0]['service'];
} }
@ -192,7 +193,7 @@ class RetailCrmOrder
$itemId = $orderItems[$externalId]['id']; $itemId = $orderItems[$externalId]['id'];
$key = array_search('bitrix', array_column($externalIds, 'code')); $key = array_search('bitrix', array_column($externalIds, 'code'));
if ($externalIds[$key]['code'] === 'bitrix') { if ($externalIds[$key]['code'] === 'bitrix') {
$externalIds[$key] = [ $externalIds[$key] = [
'code' => 'bitrix', 'code' => 'bitrix',
@ -228,7 +229,7 @@ class RetailCrmOrder
} }
$catalogProduct = CCatalogProduct::GetByID($product['PRODUCT_ID']); $catalogProduct = CCatalogProduct::GetByID($product['PRODUCT_ID']);
if (is_null($catalogProduct['PURCHASING_PRICE']) === false) { if (is_null($catalogProduct['PURCHASING_PRICE']) === false) {
if ($catalogProduct['PURCHASING_CURRENCY'] && $currency != $catalogProduct['PURCHASING_CURRENCY']) { if ($catalogProduct['PURCHASING_CURRENCY'] && $currency != $catalogProduct['PURCHASING_CURRENCY']) {
$purchasePrice = CCurrencyRates::ConvertCurrency( $purchasePrice = CCurrencyRates::ConvertCurrency(
@ -244,7 +245,7 @@ class RetailCrmOrder
} }
$item['discountManualPercent'] = 0; $item['discountManualPercent'] = 0;
if ($product['BASE_PRICE'] >= $product['PRICE']) { if ($product['BASE_PRICE'] >= $product['PRICE']) {
$item['discountManualAmount'] = self::getDiscountManualAmount($product); $item['discountManualAmount'] = self::getDiscountManualAmount($product);
$item['initialPrice'] = (double) $product['BASE_PRICE']; $item['initialPrice'] = (double) $product['BASE_PRICE'];
@ -276,7 +277,7 @@ class RetailCrmOrder
//payments //payments
$payments = []; $payments = [];
foreach ($arOrder['PAYMENTS'] as $payment) { foreach ($arOrder['PAYMENTS'] as $payment) {
$isIntegrationPayment = RetailCrmService::isIntegrationPayment($payment['PAY_SYSTEM_ID'] ?? null); $isIntegrationPayment = RetailCrmService::isIntegrationPayment($payment['PAY_SYSTEM_ID'] ?? null);
@ -457,14 +458,14 @@ class RetailCrmOrder
$resCustomersCorporate[$arCustomerCorporate['nickName']] = $arCustomerCorporate; $resCustomersCorporate[$arCustomerCorporate['nickName']] = $arCustomerCorporate;
} }
$email = $arCustomer['email'] ?? ''; if (
array_key_exists('externalId', $arCustomer)
if (!in_array($email, $resCustomersAdded)) { && !in_array($arCustomer['externalId'], $resCustomersAdded, true)
$resCustomersAdded[] = $email; ) {
$resCustomersAdded[] = $arCustomer['externalId'];
$resCustomers[$order['LID']][] = $arCustomer; $resCustomers[$order['LID']][] = $arCustomer;
} }
$resCustomers[$order['LID']][] = $arCustomer;
$ordersPack[$order['LID']][] = $arOrders; $ordersPack[$order['LID']][] = $arOrders;
$recOrders[] = $orderId; $recOrders[] = $orderId;
} }
@ -709,7 +710,7 @@ class RetailCrmOrder
foreach ($pack as $key => $itemLoad) { foreach ($pack as $key => $itemLoad) {
$site = self::getCrmShopCodeByLid($key, $optionsSitesList); $site = self::getCrmShopCodeByLid($key, $optionsSitesList);
if (null === $site && count($optionsSitesList) > 0) { if (null === $site && count($optionsSitesList) > 0) {
continue; continue;
} }
@ -839,14 +840,14 @@ class RetailCrmOrder
$sumDifference = $product->get('BASE_PRICE') - $product->get('PRICE'); $sumDifference = $product->get('BASE_PRICE') - $product->get('PRICE');
return $sumDifference > 0 ? $sumDifference : 0.0; return $sumDifference > 0 ? $sumDifference : 0.0;
} }
$discount = (double) $product->get('DISCOUNT_PRICE'); $discount = (double) $product->get('DISCOUNT_PRICE');
$dpItem = $product->get('BASE_PRICE') - $product->get('PRICE'); $dpItem = $product->get('BASE_PRICE') - $product->get('PRICE');
if ($dpItem > 0 && $discount <= 0) { if ($dpItem > 0 && $discount <= 0) {
return $dpItem; return $dpItem;
} }
return $discount; return $discount;
} }
} }

View File

@ -1 +1 @@
- Исправление некорректной генерации каталога при повторных запусках генерации - Исправления ошибок в выгрузке заказов и генерации каталога

View File

@ -1,6 +1,6 @@
<?php <?php
$arModuleVersion = [ $arModuleVersion = [
'VERSION' => '5.8.4', 'VERSION' => '5.8.5',
'VERSION_DATE' => '2021-10-15 12:00:00', 'VERSION_DATE' => '2022-02-03 12:00:00',
]; ];

View File

@ -251,7 +251,7 @@ class IcmlDirector
do { do {
//Если каталог проиндексирован, у товара есть Тип и это простой товар, то просто записываем его //Если каталог проиндексирован, у товара есть Тип и это простой товар, то просто записываем его
if ($product->productType = ProductTable::TYPE_PRODUCT) { if ($product->productType === ProductTable::TYPE_PRODUCT) {
$this->icmlWriter->writeOffers([$product]); $this->icmlWriter->writeOffers([$product]);
break; break;
} }

View File

@ -225,7 +225,7 @@ class XmlOfferBuilder
{ {
$this->xmlOffer->id = $item['ID']; $this->xmlOffer->id = $item['ID'];
$this->xmlOffer->productId = $item['ID']; $this->xmlOffer->productId = $item['ID'];
$this->xmlOffer->productType = $item['CATALOG_TYPE']; $this->xmlOffer->productType = (int) $item['CATALOG_TYPE'];
$this->xmlOffer->quantity = $item['CATALOG_QUANTITY'] ?? ''; $this->xmlOffer->quantity = $item['CATALOG_QUANTITY'] ?? '';
$this->xmlOffer->url = $item['DETAIL_PAGE_URL'] $this->xmlOffer->url = $item['DETAIL_PAGE_URL']
? $this->defaultServerName . $item['DETAIL_PAGE_URL'] ? $this->defaultServerName . $item['DETAIL_PAGE_URL']

View File

@ -125,7 +125,7 @@ class XmlOffer
* \Bitrix\Catalog\ProductTable::TYPE_SKU товар с торговыми предложениями * \Bitrix\Catalog\ProductTable::TYPE_SKU товар с торговыми предложениями
* \Bitrix\Catalog\ProductTable::TYPE_OFFER торговое предложение * \Bitrix\Catalog\ProductTable::TYPE_OFFER торговое предложение
* *
* @var mixed * @var int
*/ */
public $productType; public $productType;

View File

@ -212,7 +212,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
//bitrix site list //bitrix site list
$siteListArr = []; $siteListArr = [];
foreach ($arResult['arSites'] as $arSites) { foreach ($arResult['arSites'] as $arSites) {
if (count($arResult['arSites']) > 1) { if (count($arResult['arSites']) > 1) {
if ($_POST['sites-id-' . $arSites['LID']]) { if ($_POST['sites-id-' . $arSites['LID']]) {
@ -414,8 +414,8 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
function maskPrice($var){ function maskPrice($var){
return preg_match("/^shops-price/", $var); return preg_match("/^shops-price/", $var);
} }
$bitrixPriceShopsArr = str_replace('shops-price-', '', array_filter(array_keys($_POST), 'maskPrice'));
$bitrixPriceShopsArr = array_values(array_filter($_POST, 'maskPrice', ARRAY_FILTER_USE_KEY));
$arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList(); $arResult['bitrixIblocksExportList'] = RCrmActions::IblocksExportList();
foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){ foreach($arResult['bitrixIblocksExportList'] as $bitrixIblocks){
if(htmlspecialchars(trim($_POST['iblocks-prices-' . $bitrixIblocks['ID']])) === 'Y'){ if(htmlspecialchars(trim($_POST['iblocks-prices-' . $bitrixIblocks['ID']])) === 'Y'){
@ -486,10 +486,12 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
$cc = 'Y'; $cc = 'Y';
$bitrixCorpName = htmlspecialchars(trim($_POST['nickName-corporate'])); $bitrixCorpName = htmlspecialchars(trim($_POST['nickName-corporate']));
$bitrixCorpAdres = htmlspecialchars(trim($_POST['adres-corporate'])); $bitrixCorpAdres = htmlspecialchars(trim($_POST['adres-corporate']));
function maskCorp($var) { function maskCorp($var) {
return preg_match("/^shops-corporate/", $var); return preg_match("/^shops-corporate/", $var);
} }
$bitrixCorpShopsArr = str_replace('shops-corporate-', '', array_filter(array_keys($_POST), 'maskCorp'));
$bitrixCorpShopsArr = array_values(array_filter($_POST, 'maskCorp', ARRAY_FILTER_USE_KEY));
RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCc", "add"); RegisterModuleDependences("main", "OnBeforeProlog", $mid, "RetailCrmCc", "add");
} else { } else {
@ -1394,7 +1396,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<?php foreach ($arResult['sitesList'] as $sitesList): ?> <?php foreach ($arResult['sitesList'] as $sitesList): ?>
<tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>> <tr class="prices" align="center" <?php if($optionPricesUpload !== 'Y') echo 'style="display: none;"'; ?>>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="shops-price-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionPriceShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label> <label><input class="addr" type="checkbox" name="shops-price-<? echo $sitesList['code']; ?>" value="<? echo $sitesList['code']; ?>" <?php if (in_array($sitesList['code'], $optionPriceShops)) {
echo "checked";
} ?>> <?php echo $sitesList['name'] . ' (' . $sitesList['code'] . ')'; ?>
</label>
</td> </td>
</tr> </tr>
<?php endforeach;?> <?php endforeach;?>
@ -1541,7 +1546,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] == 'Y')) {
<td width="50%" class="" name="<?php ?>" align="center"> <td width="50%" class="" name="<?php ?>" align="center">
<?php foreach ($arResult['sitesList'] as $sitesList): ?> <?php foreach ($arResult['sitesList'] as $sitesList): ?>
<td colspan="2" class="option-other-center"> <td colspan="2" class="option-other-center">
<label><input class="addr" type="checkbox" name="shops-corporate-<?echo $sitesList['code'];?>" value="Y" <?php if(in_array($sitesList['code'], $optionCorpShops)) echo "checked"; ?>> <?php echo $sitesList['name'].' ('.$sitesList['code'].')'; ?></label> <label><input class="addr" type="checkbox" name="shops-corporate-<? echo $sitesList['code']; ?>" value="<? echo $sitesList['code']; ?>" <?php if (in_array($sitesList['code'], $optionCorpShops)) {
echo "checked";
} ?>> <?php echo $sitesList['name'] . ' (' . $sitesList['code'] . ')'; ?>
</label>
</td> </td>
<?php endforeach;?> <?php endforeach;?>
</td> </td>