1
0
mirror of synced 2024-11-22 05:16:09 +03:00

ref #90482 Добавлен функционал передачи примененного купона в заказе Битрикс в пользовательское поле заказа CRM (#302)

This commit is contained in:
Uryvskiy Dima 2023-07-05 10:34:37 +03:00 committed by GitHub
parent c7cec20c02
commit 7c667112d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 90 additions and 6 deletions

View File

@ -1,3 +1,6 @@
## 2023-07-04 v.6.3.17
- Добавлен функционал передачи примененного купона в заказе Битрикс в пользовательское поле заказа CRM
## 2023-06-30 v.6.3.16 ## 2023-06-30 v.6.3.16
- Добавлена передача НДС товаров - Добавлена передача НДС товаров

View File

@ -1433,9 +1433,9 @@ class ApiClient
* *
* @return ApiResponse * @return ApiResponse
*/ */
public function customFieldsList(array $filter = array(), $limit = null, $page = null) public function customFieldsList(array $filter = [], $limit = null, $page = null)
{ {
$parameters = array(); $parameters = [];
if (count($filter)) { if (count($filter)) {
$parameters['filter'] = $filter; $parameters['filter'] = $filter;

View File

@ -75,6 +75,25 @@ class RetailCrmOrder
'delivery' => ['cost' => $arOrder['PRICE_DELIVERY']], 'delivery' => ['cost' => $arOrder['PRICE_DELIVERY']],
]; ];
$orderCouponField = ConfigProvider::getOrderCouponField();
if ($orderCouponField !== '__default_empty_value__') {
$couponList = \Bitrix\Sale\Internals\OrderCouponsTable::getList([
'select' => ['COUPON'],
'filter' => ['=ORDER_ID' => $arOrder['ID']],
]);
$appliedCoupons = [];
while ($coupon = $couponList->fetch())
{
$appliedCoupons[] = $coupon['COUPON'];
}
if (!empty($orderCouponField) && $appliedCoupons !== []) {
$order['customFields'][$orderCouponField] = implode('; ', $appliedCoupons);
}
}
if (!empty($arOrder['REASON_CANCELED'])) { if (!empty($arOrder['REASON_CANCELED'])) {
$order['statusComment'] = $arOrder['REASON_CANCELED']; $order['statusComment'] = $arOrder['REASON_CANCELED'];
} }

View File

@ -1 +1 @@
- Добавлена передача НДС товаров - Добавлен функционал передачи примененного купона в заказе Битрикс в пользовательское поле заказа CRM

View File

@ -1,6 +1,6 @@
<?php <?php
$arModuleVersion = [ $arModuleVersion = [
'VERSION' => '6.3.16', 'VERSION' => '6.3.17',
'VERSION_DATE' => '2023-06-30 18:00:00' 'VERSION_DATE' => '2023-07-04 18:00:00'
]; ];

View File

@ -18,6 +18,8 @@ $MESS ['PAYMENT_Y'] = 'Paid';
$MESS ['PAYMENT_N'] = 'Not paid'; $MESS ['PAYMENT_N'] = 'Not paid';
$MESS ['LEGAL_DETAIL'] = 'Legal entity and bank details'; $MESS ['LEGAL_DETAIL'] = 'Legal entity and bank details';
$MESS ['ORDER_CUSTOM'] = 'Custom fields'; $MESS ['ORDER_CUSTOM'] = 'Custom fields';
$MESS ['COUPON_CUSTOM_FIELD'] = 'Select a custom field in the CRM to transfer the applied coupon in the Bitrix order';
$MESS ['SELECT_VALUE'] = '-- Select a value --';
$MESS ['ORDER_UPLOAD'] = 'Re-upload orders'; $MESS ['ORDER_UPLOAD'] = 'Re-upload orders';
$MESS ['ORDER_NUMBER'] = 'Order numbers: '; $MESS ['ORDER_NUMBER'] = 'Order numbers: ';
$MESS ['ORDER_UPLOAD_INFO'] = 'Click "Start uploading" to upload all the orders . Or list the required order IDs separated by commas, intervals or dashes. For example: 1, 3, 5-10, 12, 13... etc.'; $MESS ['ORDER_UPLOAD_INFO'] = 'Click "Start uploading" to upload all the orders . Or list the required order IDs separated by commas, intervals or dashes. For example: 1, 3, 5-10, 12, 13... etc.';

View File

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

View File

@ -69,6 +69,9 @@ class ConfigProvider
/** @var bool|null|string $orderVat */ /** @var bool|null|string $orderVat */
protected static $orderVat; protected static $orderVat;
/** @var null|string $orderVat */
protected static $orderCouponField;
/** @var array $orderTypes */ /** @var array $orderTypes */
protected static $orderTypes; protected static $orderTypes;
@ -501,6 +504,20 @@ class ConfigProvider
return static::$customFields; return static::$customFields;
} }
/**
* get CRM order coupon field
*
* @return string
*/
public static function getOrderCouponField()
{
if (self::isEmptyNotZero(static::$orderCouponField)) {
static::$orderCouponField = static::getOption(Constants::CRM_COUPON_FIELD);
}
return static::$orderCouponField;
}
/** /**
* getCancellableOrderPaymentStatuses * getCancellableOrderPaymentStatuses
* *

View File

@ -44,6 +44,7 @@ class Constants
public const CRM_SITES_LIST_CORPORATE = 'shops-corporate'; public const CRM_SITES_LIST_CORPORATE = 'shops-corporate';
public const CRM_ORDER_NUMBERS = 'order_numbers'; public const CRM_ORDER_NUMBERS = 'order_numbers';
public const CRM_ORDER_VAT = 'order_vat'; public const CRM_ORDER_VAT = 'order_vat';
public const CRM_COUPON_FIELD = 'crm_coupon_field';
public const CRM_CANCEL_ORDER = 'cansel_order'; public const CRM_CANCEL_ORDER = 'cansel_order';
public const CRM_INVENTORIES_UPLOAD = 'inventories_upload'; public const CRM_INVENTORIES_UPLOAD = 'inventories_upload';
public const CRM_STORES = 'stores'; public const CRM_STORES = 'stores';

View File

@ -35,6 +35,7 @@ $CRM_ORDER_DISCHARGE = 'order_discharge';
$CRM_ORDER_PROPS = 'order_props'; $CRM_ORDER_PROPS = 'order_props';
$CRM_LEGAL_DETAILS = 'legal_details'; $CRM_LEGAL_DETAILS = 'legal_details';
$CRM_CUSTOM_FIELDS = 'custom_fields'; $CRM_CUSTOM_FIELDS = 'custom_fields';
$CRM_COUPON_FIELD = 'crm_coupon_field';
$CRM_CONTRAGENT_TYPE = 'contragent_type'; $CRM_CONTRAGENT_TYPE = 'contragent_type';
$CRM_SITES_LIST = 'sites_list'; $CRM_SITES_LIST = 'sites_list';
$CRM_ORDER_NUMBERS = 'order_numbers'; $CRM_ORDER_NUMBERS = 'order_numbers';
@ -405,6 +406,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
$orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N'; $orderNumbers = htmlspecialchars(trim($_POST['order-numbers'])) ?: 'N';
$orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N'; $orderDimensions = htmlspecialchars(trim($_POST[$CRM_DIMENSIONS])) ?: 'N';
$sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N'; $sendPaymentAmount = htmlspecialchars(trim($_POST[RetailcrmConstants::SEND_PAYMENT_AMOUNT])) ?: 'N';
$crmCouponFiled = htmlspecialchars(trim($_POST['crm-coupon-field'])) ?: 'N';
//stores //stores
$bitrixStoresArr = []; $bitrixStoresArr = [];
@ -812,6 +814,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
$CRM_ORDER_VAT, $CRM_ORDER_VAT,
$orderVat $orderVat
); );
COption::SetOptionString(
$mid,
$CRM_COUPON_FIELD,
$crmCouponFiled
);
COption::SetOptionString( COption::SetOptionString(
$mid, $mid,
$CRM_CANSEL_ORDER, $CRM_CANSEL_ORDER,
@ -1051,9 +1058,27 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
//currency //currency
$baseCurrency = \Bitrix\Currency\CurrencyManager::getBaseCurrency(); $baseCurrency = \Bitrix\Currency\CurrencyManager::getBaseCurrency();
$currencyOption = COption::GetOptionString($mid, $CRM_CURRENCY, 0) ? COption::GetOptionString($mid, $CRM_CURRENCY, 0) : $baseCurrency; $currencyOption = COption::GetOptionString($mid, $CRM_CURRENCY, 0) ?: $baseCurrency;
$currencyList = \Bitrix\Currency\CurrencyManager::getCurrencyList(); $currencyList = \Bitrix\Currency\CurrencyManager::getCurrencyList();
$customFields = [['code' => '__default_empty_value__', 'name' => GetMessage('SELECT_VALUE')]];
$crmCouponFieldOption = COption::GetOptionString($mid, $CRM_COUPON_FIELD, 0) ?: null;
$page = 1;
do {
$getCustomFields = $api->customFieldsList(['entity' => 'order', 'type' => ['string', 'text']], 100, $page);
if (!$getCustomFields->isSuccessful() && empty($getCustomFields['customFields'])) {
break;
}
foreach ($getCustomFields['customFields'] as $customField) {
$customFields[] = $customField;
}
$page++;
} while($getCustomFields['pagination']['currentPage'] < $getCustomFields['pagination']['totalPageCount']);
$optionsOrderDimensions = COption::GetOptionString($mid, $CRM_DIMENSIONS, 'N'); $optionsOrderDimensions = COption::GetOptionString($mid, $CRM_DIMENSIONS, 'N');
$addressOptions = unserialize(COption::GetOptionString($mid, $CRM_ADDRESS_OPTIONS, 0)); $addressOptions = unserialize(COption::GetOptionString($mid, $CRM_ADDRESS_OPTIONS, 0));
@ -2193,6 +2218,21 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
</b> </b>
</td> </td>
</tr> </tr>
<tr>
<td colspan="2" class="option-head option-other-top option-other-bottom">
<b><?php echo GetMessage('COUPON_CUSTOM_FIELD'); ?></b>
<br><br>
<select name="crm-coupon-field" class="typeselect">
<?php foreach ($customFields as $customField) : ?>
<option value="<?php echo $customField['code']; ?>" <?php if ($customField['code'] === $crmCouponFieldOption) {
echo 'selected';
} ?>>
<?php echo $customField['name']; ?>
</option>
<?php endforeach; ?>
</select>
</td>
</tr>
<tr class="heading"> <tr class="heading">
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td> <td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td>
</tr> </tr>