ref #90085 Проверка на доступность типа оплат и доставок для текущего магазина для настройки модуля (#295)
This commit is contained in:
parent
de7a2bc1de
commit
555d7e2513
@ -1,3 +1,6 @@
|
|||||||
|
## 2023-06-02 v.6.3.10
|
||||||
|
- Добавлено ограничение по магазинам для типов доставок и оплат
|
||||||
|
|
||||||
## 2023-06-01 v.6.3.9
|
## 2023-06-01 v.6.3.9
|
||||||
- Исправление ошибок генерации ICML каталога при установке модуля
|
- Исправление ошибок генерации ICML каталога при установке модуля
|
||||||
|
|
||||||
@ -10,6 +13,8 @@
|
|||||||
## 2023-05-19 v.6.3.6
|
## 2023-05-19 v.6.3.6
|
||||||
- В настройки добавлена опция деактивации модуля
|
- В настройки добавлена опция деактивации модуля
|
||||||
|
|
||||||
|
## 2023-05-18 v.6.3.5
|
||||||
|
- Добавлен функционал обновления номера телефона, адреса и других полей заказа, связанных с курьерской доставкой
|
||||||
|
|
||||||
## 2023-04-26 v.6.3.4
|
## 2023-04-26 v.6.3.4
|
||||||
- Оптимизирован алгоритм получения истории заказов и клиентов
|
- Оптимизирован алгоритм получения истории заказов и клиентов
|
||||||
|
@ -124,4 +124,34 @@ class RetailCrmService
|
|||||||
true
|
true
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array|null $availableSites
|
||||||
|
* @param array|null $types
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getAvailableTypes(?array $availableSites, ?array $types)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
if ($type['active'] !== true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($type['sites'])) {
|
||||||
|
$result[] = $type;
|
||||||
|
} else {
|
||||||
|
foreach ($type['sites'] as $site) {
|
||||||
|
if (!empty($availableSites[$site])) {
|
||||||
|
$result[] = $type;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
- Исправление ошибок генерации ICML каталога при установке модуля
|
- Добавлено ограничение по магазинам для типов доставок и оплат
|
@ -455,14 +455,25 @@ class intaro_retailcrm extends CModule
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$delivTypes = [];
|
$this->loadDeps();
|
||||||
foreach ($arResult['deliveryTypesList'] as $delivType) {
|
|
||||||
if ($delivType['active'] === true) {
|
$availableSites = RetailcrmConfigProvider::getSitesList();
|
||||||
$delivTypes[$delivType['code']] = $delivType;
|
|
||||||
}
|
if (!empty($availableSites)) {
|
||||||
|
$availableSites = array_flip($availableSites);
|
||||||
|
} else {
|
||||||
|
$site = RetailcrmConfigProvider::getSitesAvailable();
|
||||||
|
$availableSites[$site] = $site;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadDeps();
|
$arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$arResult['deliveryTypesList']
|
||||||
|
);
|
||||||
|
$arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$arResult['paymentTypesList']
|
||||||
|
);
|
||||||
|
|
||||||
RetailcrmConfigProvider::setIntegrationDelivery(
|
RetailcrmConfigProvider::setIntegrationDelivery(
|
||||||
RetailCrmService::selectIntegrationDeliveries($arResult['deliveryTypesList'])
|
RetailCrmService::selectIntegrationDeliveries($arResult['deliveryTypesList'])
|
||||||
@ -472,8 +483,6 @@ class intaro_retailcrm extends CModule
|
|||||||
RetailCrmService::selectIntegrationPayments($arResult['paymentTypesList'])
|
RetailCrmService::selectIntegrationPayments($arResult['paymentTypesList'])
|
||||||
);
|
);
|
||||||
|
|
||||||
$arResult['deliveryTypesList'] = $delivTypes;
|
|
||||||
|
|
||||||
//bitrix personTypes
|
//bitrix personTypes
|
||||||
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
||||||
|
|
||||||
|
@ -24,6 +24,15 @@ $RETAIL_CRM_API = new ApiClient($api_host, $api_key);
|
|||||||
COption::SetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, $api_host);
|
COption::SetOptionString($MODULE_ID, $CRM_API_HOST_OPTION, $api_host);
|
||||||
COption::SetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, $api_key);
|
COption::SetOptionString($MODULE_ID, $CRM_API_KEY_OPTION, $api_key);
|
||||||
|
|
||||||
|
$availableSites = RetailcrmConfigProvider::getSitesList();
|
||||||
|
|
||||||
|
if (!empty($availableSites)) {
|
||||||
|
$availableSites = array_flip($availableSites);
|
||||||
|
} else {
|
||||||
|
$site = RetailcrmConfigProvider::getSitesAvailable();
|
||||||
|
$availableSites[$site] = $site;
|
||||||
|
}
|
||||||
|
|
||||||
if (count($arResult['arSites']) === 1) {
|
if (count($arResult['arSites']) === 1) {
|
||||||
COption::SetOptionString($MODULE_ID, $CRM_SITES_LIST, serialize([]));
|
COption::SetOptionString($MODULE_ID, $CRM_SITES_LIST, serialize([]));
|
||||||
}
|
}
|
||||||
@ -38,7 +47,10 @@ if (!isset($arResult['ORDER_TYPES'])) {
|
|||||||
|
|
||||||
if (!isset($arResult['paymentTypesList'])) {
|
if (!isset($arResult['paymentTypesList'])) {
|
||||||
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
|
$arResult['bitrixPaymentTypesList'] = RCrmActions::PaymentList();
|
||||||
$arResult['paymentTypesList'] = $RETAIL_CRM_API->paymentTypesList()->paymentTypes;
|
$arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$RETAIL_CRM_API->paymentTypesList()->paymentTypes
|
||||||
|
);
|
||||||
$arResult['PAYMENT_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_PAYMENT_TYPES, 0));
|
$arResult['PAYMENT_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_PAYMENT_TYPES, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +72,10 @@ if (!isset($arResult['paymentStatusesList'])) {
|
|||||||
|
|
||||||
if (!isset($arResult['bitrixDeliveryTypesList'])) {
|
if (!isset($arResult['bitrixDeliveryTypesList'])) {
|
||||||
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
|
$arResult['bitrixDeliveryTypesList'] = RCrmActions::DeliveryList();
|
||||||
$arResult['deliveryTypesList'] = $RETAIL_CRM_API->deliveryTypesList()->deliveryTypes;
|
$arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$RETAIL_CRM_API->deliveryTypesList()->deliveryTypes
|
||||||
|
);
|
||||||
$arResult['DELIVERY_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_DELIVERY_TYPES_ARR, 0));
|
$arResult['DELIVERY_TYPES'] = unserialize(COption::GetOptionString($MODULE_ID, $CRM_DELIVERY_TYPES_ARR, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,12 +241,10 @@ if (isset($arResult['PAYMENT'])) {
|
|||||||
<select name="delivery-type-<?php echo $bitrixDeliveryType['ID']; ?>" class="typeselect">
|
<select name="delivery-type-<?php echo $bitrixDeliveryType['ID']; ?>" class="typeselect">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<?php foreach($arResult['deliveryTypesList'] as $deliveryType): ?>
|
<?php foreach($arResult['deliveryTypesList'] as $deliveryType): ?>
|
||||||
<?php if ($deliveryType['active'] === true): ?>
|
|
||||||
<option value="<?php echo $deliveryType['code']; ?>"
|
<option value="<?php echo $deliveryType['code']; ?>"
|
||||||
<?php if($defaultDelivTypes[$bitrixDeliveryType['ID']] == $deliveryType['code']) echo 'selected'; ?>>
|
<?php if($defaultDelivTypes[$bitrixDeliveryType['ID']] == $deliveryType['code']) echo 'selected'; ?>>
|
||||||
<?php echo $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET); ?>
|
<?php echo $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@ -250,14 +263,12 @@ if (isset($arResult['PAYMENT'])) {
|
|||||||
<select name="payment-type-<?php echo $bitrixPaymentType['ID']; ?>" class="typeselect">
|
<select name="payment-type-<?php echo $bitrixPaymentType['ID']; ?>" class="typeselect">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<?php foreach($arResult['paymentTypesList'] as $paymentType): ?>
|
<?php foreach($arResult['paymentTypesList'] as $paymentType): ?>
|
||||||
<?php if($paymentType['active'] === true): ?>
|
|
||||||
<option value="<?php echo $paymentType['code']; ?>"
|
<option value="<?php echo $paymentType['code']; ?>"
|
||||||
<?php if($defaultPayTypes[$bitrixPaymentType['ID']] == $paymentType['code']) echo 'selected'; ?>>
|
<?php if($defaultPayTypes[$bitrixPaymentType['ID']] == $paymentType['code']) echo 'selected'; ?>>
|
||||||
<?php
|
<?php
|
||||||
$nameType = isset($paymentType['integrationModule']) ? $APPLICATION->ConvertCharset($paymentType['name'] . GetMessage('INTEGRATIONS'), 'utf-8', SITE_CHARSET) : $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET);
|
$nameType = isset($paymentType['integrationModule']) ? $APPLICATION->ConvertCharset($paymentType['name'] . GetMessage('INTEGRATIONS'), 'utf-8', SITE_CHARSET) : $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET);
|
||||||
echo $nameType;?>
|
echo $nameType;?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$arModuleVersion = [
|
$arModuleVersion = [
|
||||||
'VERSION' => '6.3.9',
|
'VERSION' => '6.3.10',
|
||||||
'VERSION_DATE' => '2023-06-01 14:00:00'
|
'VERSION_DATE' => '2023-06-02 11:00:00'
|
||||||
];
|
];
|
||||||
|
@ -220,6 +220,15 @@ if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && (strtolower($_SERVER['HTTP_X_RE
|
|||||||
die(json_encode($res));
|
die(json_encode($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$availableSites = RetailcrmConfigProvider::getSitesList();
|
||||||
|
|
||||||
|
if (!empty($availableSites)) {
|
||||||
|
$availableSites = array_flip($availableSites);
|
||||||
|
} else {
|
||||||
|
$site = RetailcrmConfigProvider::getSitesAvailable();
|
||||||
|
$availableSites[$site] = $site;
|
||||||
|
}
|
||||||
|
|
||||||
//update connection settings
|
//update connection settings
|
||||||
if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
||||||
$api_host = htmlspecialchars(trim($_POST['api_host']));
|
$api_host = htmlspecialchars(trim($_POST['api_host']));
|
||||||
@ -618,8 +627,14 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$arResult['paymentTypesList'] = $api->paymentTypesList()->paymentTypes;
|
$arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
$arResult['deliveryTypesList'] = $api->deliveryTypesList()->deliveryTypes;
|
$availableSites,
|
||||||
|
$api->paymentTypesList()->paymentTypes
|
||||||
|
);
|
||||||
|
$arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$api->deliveryTypesList()->deliveryTypes
|
||||||
|
);
|
||||||
} catch (\RetailCrm\Exception\CurlException $e) {
|
} catch (\RetailCrm\Exception\CurlException $e) {
|
||||||
RCrmActions::eventLog(
|
RCrmActions::eventLog(
|
||||||
'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException',
|
'intaro.retailcrm/options.php', 'RetailCrm\ApiClient::*List::CurlException',
|
||||||
@ -942,21 +957,20 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
echo CAdminMessage::ShowMessage(GetMessage('ERR_JSON'));
|
echo CAdminMessage::ShowMessage(GetMessage('ERR_JSON'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$deliveryTypes = [];
|
$arResult['paymentTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
$deliveryIntegrationCode = [];
|
$availableSites,
|
||||||
foreach ($arResult['deliveryTypesList'] as $deliveryType) {
|
$api->paymentTypesList()->paymentTypes
|
||||||
if ($deliveryType['active'] === true) {
|
|
||||||
$deliveryTypes[$deliveryType['code']] = $deliveryType;
|
|
||||||
$deliveryIntegrationCode[$deliveryType['code']] = $deliveryType['integrationCode'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$arResult['deliveryTypesList'] = $deliveryTypes;
|
|
||||||
COption::SetOptionString(
|
|
||||||
$mid,
|
|
||||||
RetailcrmConstants::CRM_INTEGRATION_DELIVERY,
|
|
||||||
serialize(RCrmActions::clearArr(is_array($deliveryIntegrationCode) ? $deliveryIntegrationCode : []))
|
|
||||||
);
|
);
|
||||||
|
$arResult['deliveryTypesList'] = RetailCrmService::getAvailableTypes(
|
||||||
|
$availableSites,
|
||||||
|
$api->deliveryTypesList()->deliveryTypes
|
||||||
|
);
|
||||||
|
|
||||||
|
$integrationPayments = RetailCrmService::selectIntegrationPayments($arResult['paymentTypesList']);
|
||||||
|
$integrationDeliveries = RetailCrmService::selectIntegrationDeliveries($arResult['deliveryTypesList']);
|
||||||
|
|
||||||
|
RetailcrmConfigProvider::setIntegrationPaymentTypes($integrationPayments);
|
||||||
|
RetailcrmConfigProvider::setIntegrationDelivery($integrationDeliveries);
|
||||||
|
|
||||||
//bitrix orderTypesList -- personTypes
|
//bitrix orderTypesList -- personTypes
|
||||||
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
$arResult['bitrixOrderTypesList'] = RCrmActions::OrderTypesList($arResult['arSites']);
|
||||||
@ -1470,13 +1484,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
<select name="delivery-type-<?php echo $bitrixDeliveryType['ID']; ?>" class="typeselect">
|
<select name="delivery-type-<?php echo $bitrixDeliveryType['ID']; ?>" class="typeselect">
|
||||||
<option value=""></option>
|
<option value=""></option>
|
||||||
<?php foreach ($arResult['deliveryTypesList'] as $deliveryType): ?>
|
<?php foreach ($arResult['deliveryTypesList'] as $deliveryType): ?>
|
||||||
<?php if ($deliveryType['active'] === true) { ?>
|
|
||||||
<option value="<?php echo $deliveryType['code']; ?>" <?php if ($optionsDelivTypes[$bitrixDeliveryType['ID']] === $deliveryType['code']) {
|
<option value="<?php echo $deliveryType['code']; ?>" <?php if ($optionsDelivTypes[$bitrixDeliveryType['ID']] === $deliveryType['code']) {
|
||||||
echo 'selected';
|
echo 'selected';
|
||||||
} ?>>
|
} ?>>
|
||||||
<?php echo $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET); ?>
|
<?php echo $APPLICATION->ConvertCharset($deliveryType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||||
</option>
|
</option>
|
||||||
<?php } ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
@ -1501,13 +1513,11 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||||||
<select name="payment-type-<?php echo $bitrixPaymentType['ID']; ?>" class="typeselect">
|
<select name="payment-type-<?php echo $bitrixPaymentType['ID']; ?>" class="typeselect">
|
||||||
<option value="" selected=""></option>
|
<option value="" selected=""></option>
|
||||||
<?php foreach ($arResult['paymentTypesList'] as $paymentType): ?>
|
<?php foreach ($arResult['paymentTypesList'] as $paymentType): ?>
|
||||||
<?php if($paymentType['active'] === true): ?>
|
|
||||||
<option value="<?php echo $paymentType['code']; ?>" <?php if ($optionsPayTypes[$bitrixPaymentType['ID']] === $paymentType['code']) {
|
<option value="<?php echo $paymentType['code']; ?>" <?php if ($optionsPayTypes[$bitrixPaymentType['ID']] === $paymentType['code']) {
|
||||||
echo 'selected';
|
echo 'selected';
|
||||||
} ?>>
|
} ?>>
|
||||||
<?php echo $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET); ?>
|
<?php echo $APPLICATION->ConvertCharset($paymentType['name'], 'utf-8', SITE_CHARSET); ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
@ -50,6 +50,20 @@ class RetailCrmServiceTest extends PHPUnit\Framework\TestCase
|
|||||||
$this->assertEquals($expected, RetailCrmService::selectIntegrationPayments($data));
|
$this->assertEquals($expected, RetailCrmService::selectIntegrationPayments($data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetAvailableTypes(): void
|
||||||
|
{
|
||||||
|
$data = DataService::availableSitesAndTypesData();
|
||||||
|
$sites = $data['sites'];
|
||||||
|
$types = $data['types'];
|
||||||
|
|
||||||
|
$result = RetailCrmService::getAvailableTypes($sites, $types);
|
||||||
|
|
||||||
|
$this->assertCount(3, $result);
|
||||||
|
$this->assertEquals('test1', $result[0]['code']);
|
||||||
|
$this->assertEquals('test4', $result[1]['code']);
|
||||||
|
$this->assertEquals('test6', $result[2]['code']);
|
||||||
|
}
|
||||||
|
|
||||||
public function selectIntegrationDeliveriesProvider()
|
public function selectIntegrationDeliveriesProvider()
|
||||||
{
|
{
|
||||||
return [[
|
return [[
|
||||||
|
@ -42,4 +42,46 @@ class DataService
|
|||||||
'shipmentStore' => 'test',
|
'shipmentStore' => 'test',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function availableSitesAndTypesData()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'sites' => [
|
||||||
|
'bitrix' => 's1',
|
||||||
|
'bitrix2' => 's2'
|
||||||
|
],
|
||||||
|
'types' => [
|
||||||
|
'test1' => [
|
||||||
|
'code' => 'test1',
|
||||||
|
'active' => true,
|
||||||
|
'sites' => []
|
||||||
|
],
|
||||||
|
'test2' => [
|
||||||
|
'code' => 'test2',
|
||||||
|
'active' => false,
|
||||||
|
'sites' => []
|
||||||
|
],
|
||||||
|
'test3' => [
|
||||||
|
'code' => 'test3',
|
||||||
|
'active' => true,
|
||||||
|
'sites' => ['crm', 'crm1']
|
||||||
|
],
|
||||||
|
'test4' => [
|
||||||
|
'code' => 'test4',
|
||||||
|
'active' => true,
|
||||||
|
'sites' => ['bitrix', 'crm']
|
||||||
|
],
|
||||||
|
'test5' => [
|
||||||
|
'code' => 'test5',
|
||||||
|
'active' => false,
|
||||||
|
'sites' => ['bitrix', 'bitrix2']
|
||||||
|
],
|
||||||
|
'test6' => [
|
||||||
|
'code' => 'test6',
|
||||||
|
'active' => true,
|
||||||
|
'sites' => ['bitrix', 'bitrix2']
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user