1
0
mirror of synced 2024-11-21 21:06:09 +03:00

ref #92358 Передача трек номера из системы (#321)

This commit is contained in:
Kocmonavtik 2023-10-26 14:36:22 +03:00 committed by GitHub
parent 693031012d
commit 748ebdf4a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 52 additions and 18 deletions

View File

@ -1,3 +1,6 @@
## 2023-10-25 v.6.4.10
- Добавлена передача трек-номера в заказе из CRM в Bitrix
## 2023-10-24 v.6.4.9
- Исправлена ошибка при деактивации модуля

View File

@ -1722,28 +1722,30 @@ class RetailCrmHistory
$shipmentColl = $bitrixOrder->getShipmentCollection();
if ($delivery) {
$baseFields = [
'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'CURRENCY' => $bitrixOrder->getCurrency(),
'DELIVERY_NAME' => $delivery->getName(),
'CUSTOM_PRICE_DELIVERY' => 'Y',
];
if (RetailcrmConfigProvider::getTrackNumberStatus() === 'Y') {
$baseFields['TRACKING_NUMBER'] = $crmOrder['delivery']['data']['trackNumber'] ?? '';
}
//В коллекции всегда есть одна скрытая системная доставка, к которой относятся нераспределенные товары
//Поэтому, если есть только системная доставка, то нужно создать новую
if (!$update || $shipmentColl->count() === 1) {
$shipment = $shipmentColl->createItem($delivery);
$shipment->setFields([
'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'CURRENCY' => $bitrixOrder->getCurrency(),
'DELIVERY_NAME' => $delivery->getName(),
'CUSTOM_PRICE_DELIVERY' => 'Y'
]);
$shipment->setFields($baseFields);
} else {
$baseFields['DELIVERY_ID'] = $deliveryId;
foreach ($shipmentColl as $shipment) {
if (!$shipment->isSystem()) {
$shipment->setFields([
'BASE_PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'PRICE_DELIVERY' => $crmOrder['delivery']['cost'],
'CURRENCY' => $bitrixOrder->getCurrency(),
'DELIVERY_ID' => $deliveryId,
'DELIVERY_NAME' => $delivery->getName(),
'CUSTOM_PRICE_DELIVERY' => 'Y'
]);
$shipment->setFields($baseFields);
}
}
}

View File

@ -1 +1 @@
- Исправлена ошибка при деактивации модуля
- Добавлена передача трек-номера в заказе из CRM в Bitrix

View File

@ -1,6 +1,6 @@
<?php
$arModuleVersion = [
'VERSION' => '6.4.9',
'VERSION_DATE' => '2023-10-24 13:00:00'
'VERSION' => '6.4.10',
'VERSION_DATE' => '2023-10-25 15:00:00'
];

View File

@ -112,3 +112,5 @@ $MESS ['DEACTIVATE_MODULE'] = 'Deactivate the module';
$MESS ['WRONG_CREDENTIALS'] = 'Enter the address and authorization key of the CRM system';
$MESS ['Wrong "apiKey" value.'] = 'Invalid authorization key';
$MESS ['ORDER_TRACK_NUMBER'] = 'Receive track number';

View File

@ -171,3 +171,5 @@ $MESS ['DEACTIVATE_MODULE'] = 'Деактивировать модуль';
$MESS ['WRONG_CREDENTIALS'] = 'Введите адрес и ключ авторизации CRM системы';
$MESS ['Wrong "apiKey" value.'] = 'Недействительный ключ авторизации';
$MESS ['ORDER_TRACK_NUMBER'] = 'Получать трек-номер';

View File

@ -1159,4 +1159,14 @@ class ConfigProvider
{
return COption::GetOptionString(Constants::MODULE_ID, Constants::SITES_AVAILABLE, null);
}
public static function getTrackNumberStatus()
{
return static::getOption(Constants::RECEIVE_TRACK_NUMBER_DELIVERY);
}
public static function setTrackNumberStatus($trackNumberStatus)
{
static::setOption(Constants::RECEIVE_TRACK_NUMBER_DELIVERY, $trackNumberStatus);
}
}

View File

@ -104,4 +104,6 @@ class Constants
['EVENT_NAME' => 'OnSaleComponentOrderResultPrepared', 'FROM_MODULE' => 'sale'],
];
public const SITES_AVAILABLE = 'sites_available';
public const RECEIVE_TRACK_NUMBER_DELIVERY = 'receive_track_number_delivery';
}

View File

@ -814,6 +814,9 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
$CRM_ORDER_VAT,
htmlspecialchars(trim($_POST['order-vat'])) ?: 'N'
);
ConfigProvider::setTrackNumberStatus(htmlspecialchars(trim($_POST['track-number'])) ?: 'N');
COption::SetOptionString(
$mid,
$CRM_COUPON_FIELD,
@ -1027,6 +1030,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
$optionsCustomFields = unserialize(COption::GetOptionString($mid, $CRM_CUSTOM_FIELDS, 0));
$optionsOrderNumbers = COption::GetOptionString($mid, $CRM_ORDER_NUMBERS, 0);
$optionsOrderVat = COption::GetOptionString($mid, $CRM_ORDER_VAT, 0);
$optionsOrderTrackNumber = ConfigProvider::getTrackNumberStatus();
$canselOrderArr = unserialize(COption::GetOptionString($mid, $CRM_CANSEL_ORDER, 0));
$sendPickupPointAddress = COption::GetOptionString($mid, Constants::CRM_SEND_PICKUP_POINT_ADDRESS, 'N');
@ -2238,6 +2242,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
<tr class="heading">
<td colspan="2" class="option-other-bottom"><b><?php echo GetMessage('ORDERS_OPTIONS'); ?></b></td>
</tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>
<label><input class="addr" type="checkbox" name="track-number" value="Y" <?php if ($optionsOrderTrackNumber === 'Y') {
echo "checked";
} ?>> <?php echo GetMessage('ORDER_TRACK_NUMBER'); ?></label>
</b>
</td>
</tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b>