parent
0a6c409e11
commit
b9030b94ac
@ -1,4 +1,7 @@
|
||||
## 2023-08-31 v.6.4.4
|
||||
## 2023-09-01 v.6.4.5
|
||||
- Удалена поддержка API V4
|
||||
|
||||
## 2023-09-01 v.6.4.4
|
||||
- Исправлены ошибки при работе с программой лояльности
|
||||
|
||||
## 2023-08-29 v.6.4.3
|
||||
|
@ -17,11 +17,8 @@
|
||||
* RetailCrmCollector.php
|
||||
* RetailCrmUa.php
|
||||
* RetailCrmEvent.php
|
||||
* RetailCrmHistory_v4.php
|
||||
* RetailCrmHistory_v5.php
|
||||
* RetailCrmOrder_v4.php
|
||||
* RetailCrmOrder_v5.php
|
||||
* ApiClient_v4.php
|
||||
* ApiClient_v5.php
|
||||
|
||||
С версии 6.3.19 доступна кастомизация ICML, файлы которого расположены в модуле по пути `lib/icml`:
|
||||
|
@ -129,11 +129,8 @@ class RetailcrmClasspathBuilder
|
||||
*/
|
||||
protected static $ignoredClasses = [
|
||||
'classes' => [
|
||||
'ApiClient_v4.php',
|
||||
'ApiClient_v5.php',
|
||||
'RetailCrmOrder_v4.php',
|
||||
'RetailCrmOrder_v5.php',
|
||||
'RetailCrmHistory_v4.php',
|
||||
'RetailCrmHistory_v5.php',
|
||||
'RetailCrmCart_v5.php',
|
||||
],
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -468,30 +468,18 @@ class RCrmActions
|
||||
|
||||
$code = $integrationCode . '-' . $clientId;
|
||||
|
||||
if ($api_version == 'v4') {
|
||||
$configuration = array(
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'code' => $code,
|
||||
'logo' => $logo,
|
||||
'configurationUrl' => $accountUrl,
|
||||
'active' => $active
|
||||
);
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => $code,
|
||||
'integrationCode' => $integrationCode,
|
||||
'active' => $active,
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'logo' => $logo,
|
||||
'baseUrl' => $baseUrl,
|
||||
'accountUrl' => $accountUrl
|
||||
);
|
||||
|
||||
self::apiMethod($api, 'marketplaceSettingsEdit', __METHOD__, $configuration);
|
||||
} else {
|
||||
$configuration = array(
|
||||
'clientId' => $clientId,
|
||||
'code' => $code,
|
||||
'integrationCode' => $integrationCode,
|
||||
'active' => $active,
|
||||
'name' => GetMessage('API_MODULE_NAME'),
|
||||
'logo' => $logo,
|
||||
'baseUrl' => $baseUrl,
|
||||
'accountUrl' => $accountUrl
|
||||
);
|
||||
|
||||
self::apiMethod($api, 'integrationModulesEdit', __METHOD__, $configuration);
|
||||
}
|
||||
self::apiMethod($api, 'integrationModulesEdit', __METHOD__, $configuration);
|
||||
}
|
||||
|
||||
public static function apiMethod($api, $methodApi, $method, $params, $site = null)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1042,7 +1042,7 @@ class RetailCrmHistory
|
||||
$vatRate = null;
|
||||
|
||||
if (RetailcrmConfigProvider::getOrderVat() === 'Y') {
|
||||
if ($product['vatRate'] === 0) {
|
||||
if ($product['vatRate'] === 0 || $product['vatRate'] === 'none') {
|
||||
$vatRate = 0;
|
||||
} elseif($product['vatRate'] !== null) {
|
||||
$vatRate = $product['vatRate'] / 100;
|
||||
|
@ -1,403 +0,0 @@
|
||||
<?php
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
class RetailCrmOrder
|
||||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
public static $CRM_API_HOST_OPTION = 'api_host';
|
||||
public static $CRM_API_KEY_OPTION = 'api_key';
|
||||
public static $CRM_ORDER_TYPES_ARR = 'order_types_arr';
|
||||
public static $CRM_DELIVERY_TYPES_ARR = 'deliv_types_arr';
|
||||
public static $CRM_PAYMENT_TYPES = 'pay_types_arr';
|
||||
public static $CRM_PAYMENT_STATUSES = 'pay_statuses_arr';
|
||||
public static $CRM_PAYMENT = 'payment_arr';
|
||||
public static $CRM_ORDER_LAST_ID = 'order_last_id';
|
||||
public static $CRM_SITES_LIST = 'sites_list';
|
||||
public static $CRM_ORDER_PROPS = 'order_props';
|
||||
public static $CRM_LEGAL_DETAILS = 'legal_details';
|
||||
public static $CRM_CUSTOM_FIELDS = 'custom_fields';
|
||||
public static $CRM_CONTRAGENT_TYPE = 'contragent_type';
|
||||
public static $CRM_ORDER_FAILED_IDS = 'order_failed_ids';
|
||||
public static $CRM_ORDER_HISTORY_DATE = 'order_history_date';
|
||||
public static $CRM_CATALOG_BASE_PRICE = 'catalog_base_price';
|
||||
public static $CRM_ORDER_NUMBERS = 'order_numbers';
|
||||
public static $CRM_CURRENCY = 'currency';
|
||||
|
||||
const CANCEL_PROPERTY_CODE = 'INTAROCRM_IS_CANCELED';
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates order or returns order for mass upload
|
||||
*
|
||||
* @param array $arFields
|
||||
* @param $api
|
||||
* @param $arParams
|
||||
* @param $send
|
||||
* @return boolean
|
||||
* @return array - array('order' = $order, 'customer' => $customer)
|
||||
*/
|
||||
public static function orderSend($arFields, $api, $arParams, $send = false, $site = null, $methodApi = 'ordersEdit')
|
||||
{
|
||||
if (!$api || empty($arParams)) { // add cond to check $arParams
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($arFields)) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'empty($arFields)', 'incorrect order');
|
||||
return false;
|
||||
}
|
||||
|
||||
$currency = RetailcrmConfigProvider::getCurrencyOrDefault();
|
||||
$order = array(
|
||||
'number' => $arFields['NUMBER'],
|
||||
'externalId' => $arFields['ID'],
|
||||
'createdAt' => $arFields['DATE_INSERT'],
|
||||
'customer' => array('externalId' => $arFields['USER_ID']),
|
||||
'paymentType' => isset($arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]]) ?
|
||||
$arParams['optionsPayTypes'][$arFields['PAYMENTS'][0]] : '',
|
||||
'paymentStatus' => isset($arParams['optionsPayment'][$arFields['PAYED']]) ?
|
||||
$arParams['optionsPayment'][$arFields['PAYED']] : '',
|
||||
'orderType' => isset($arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']]) ?
|
||||
$arParams['optionsOrderTypes'][$arFields['PERSON_TYPE_ID']] : '',
|
||||
'status' => isset($arParams['optionsPayStatuses'][$arFields['STATUS_ID']]) ?
|
||||
$arParams['optionsPayStatuses'][$arFields['STATUS_ID']] : '',
|
||||
'customerComment' => $arFields['USER_DESCRIPTION'],
|
||||
'managerComment' => $arFields['COMMENTS'],
|
||||
'delivery' => array(
|
||||
'cost' => $arFields['PRICE_DELIVERY']
|
||||
),
|
||||
);
|
||||
|
||||
if ($send && isset($_COOKIE['_rc']) && $_COOKIE['_rc'] != '') {
|
||||
$order['customer']['browserId'] = $_COOKIE['_rc'];
|
||||
}
|
||||
|
||||
$order['contragent']['contragentType'] = $arParams['optionsContragentType'][$arFields['PERSON_TYPE_ID']];
|
||||
|
||||
//fields
|
||||
foreach ($arFields['PROPS']['properties'] as $prop) {
|
||||
if (!empty($arParams['optionsLegalDetails'])
|
||||
&& $search = array_search($prop['CODE'], $arParams['optionsLegalDetails'][$arFields['PERSON_TYPE_ID']])
|
||||
) {
|
||||
$order['contragent'][$search] = $prop['VALUE'][0];//legal order data
|
||||
} elseif (!empty($arParams['optionsCustomFields'])
|
||||
&& $search = array_search($prop['CODE'], $arParams['optionsCustomFields'][$arFields['PERSON_TYPE_ID']])
|
||||
) {
|
||||
$order['customFields'][$search] = $prop['VALUE'][0];//custom properties
|
||||
} elseif ($search = array_search($prop['CODE'], $arParams['optionsOrderProps'][$arFields['PERSON_TYPE_ID']])) {//other
|
||||
if (in_array($search, array('fio', 'phone', 'email'))) {//fio, phone, email
|
||||
if ($search == 'fio') {
|
||||
$order = array_merge($order, RCrmActions::explodeFio($prop['VALUE'][0]));//add fio fields
|
||||
} elseif ($search == 'email' && mb_strlen($prop['VALUE'][0]) > 100) {
|
||||
continue;
|
||||
} else {
|
||||
$order[$search] = $prop['VALUE'][0];//phone, email
|
||||
}
|
||||
} else {//address
|
||||
if ($prop['TYPE'] == 'LOCATION' && isset($prop['VALUE'][0]) && $prop['VALUE'][0] != '') {
|
||||
$arLoc = \Bitrix\Sale\Location\LocationTable::getByCode($prop['VALUE'][0])->fetch();
|
||||
if ($arLoc) {
|
||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||
$countrys = array();
|
||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml')) {
|
||||
$countrysFile = simplexml_load_file($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/country.xml');
|
||||
foreach ($countrysFile->country as $country) {
|
||||
$countrys[RCrmActions::fromJSON((string) $country->name)] = (string) $country->alpha;
|
||||
}
|
||||
}
|
||||
$location = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
|
||||
'filter' => array('=LOCATION_ID' => $arLoc['CITY_ID'], 'LANGUAGE_ID' => 'ru')
|
||||
))->fetch();
|
||||
if (count($countrys) > 0) {
|
||||
$countryOrder = \Bitrix\Sale\Location\Name\LocationTable::getList(array(
|
||||
'filter' => array('=LOCATION_ID' => $arLoc['COUNTRY_ID'], 'LANGUAGE_ID' => 'ru')
|
||||
))->fetch();
|
||||
if(isset($countrys[$countryOrder['NAME']])){
|
||||
$order['countryIso'] = $countrys[$countryOrder['NAME']];
|
||||
}
|
||||
}
|
||||
}
|
||||
$prop['VALUE'][0] = $location['NAME'];
|
||||
}
|
||||
|
||||
$order['delivery']['address'][$search] = $prop['VALUE'][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//deliverys
|
||||
if (array_key_exists($arFields['DELIVERYS'][0]['id'], $arParams['optionsDelivTypes'])) {
|
||||
$order['delivery']['code'] = $arParams['optionsDelivTypes'][$arFields['DELIVERYS'][0]['id']];
|
||||
if (isset($arFields['DELIVERYS'][0]['service']) && $arFields['DELIVERYS'][0]['service'] != '') {
|
||||
$order['delivery']['service']['code'] = $arFields['DELIVERYS'][0]['service'];
|
||||
}
|
||||
}
|
||||
|
||||
//basket
|
||||
foreach ($arFields['BASKET'] as $product) {
|
||||
$item = array(
|
||||
'quantity' => $product['QUANTITY'],
|
||||
'offer' => array('externalId' => $product['PRODUCT_ID'],
|
||||
'xmlId' => $product['PRODUCT_XML_ID']
|
||||
),
|
||||
'productName' => $product['NAME']
|
||||
);
|
||||
|
||||
$pp = CCatalogProduct::GetByID($product['PRODUCT_ID']);
|
||||
if (is_null($pp['PURCHASING_PRICE']) == false) {
|
||||
if ($pp['PURCHASING_CURRENCY'] && $currency != $pp['PURCHASING_CURRENCY']) {
|
||||
$purchasePrice = CCurrencyRates::ConvertCurrency(
|
||||
(double) $pp['PURCHASING_PRICE'],
|
||||
$pp['PURCHASING_CURRENCY'],
|
||||
$currency
|
||||
);
|
||||
} else {
|
||||
$purchasePrice = $pp['PURCHASING_PRICE'];
|
||||
}
|
||||
|
||||
$item['purchasePrice'] = $purchasePrice;
|
||||
}
|
||||
$item['discount'] = (double) $product['DISCOUNT_PRICE'];
|
||||
$item['discountPercent'] = 0;
|
||||
$item['initialPrice'] = (double) $product['PRICE'] + (double) $product['DISCOUNT_PRICE'];
|
||||
|
||||
$order['items'][] = $item;
|
||||
}
|
||||
|
||||
//send
|
||||
if (function_exists('retailCrmBeforeOrderSend')) {
|
||||
$newResOrder = retailCrmBeforeOrderSend($order, $arFields);
|
||||
if (is_array($newResOrder) && !empty($newResOrder)) {
|
||||
$order = $newResOrder;
|
||||
} elseif ($newResOrder === false) {
|
||||
RCrmActions::eventLog('RetailCrmOrder::orderSend', 'retailCrmBeforeOrderSend()', 'OrderID = ' . $arFields['ID'] . '. Sending canceled after retailCrmBeforeOrderSend');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$normalizer = new RestNormalizer();
|
||||
$order = $normalizer->normalize($order, 'orders');
|
||||
|
||||
Logger::getInstance()->write($order, 'orderSend');
|
||||
|
||||
if($send) {
|
||||
if (!RCrmActions::apiMethod($api, $methodApi, __METHOD__, $order, $site)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass order uploading, without repeating; always returns true, but writes error log
|
||||
*
|
||||
* @param int $pSize
|
||||
* @param bool $failed -- flag to export failed orders
|
||||
* @param bool $orderList
|
||||
*
|
||||
* @return boolean
|
||||
* @throws \Bitrix\Main\ArgumentNullException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
*/
|
||||
public static function uploadOrders($pSize = 50, $failed = false, $orderList = false)
|
||||
{
|
||||
if (!RetailcrmDependencyLoader::loadDependencies()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$resOrders = array();
|
||||
$resCustomers = array();
|
||||
$orderIds = array();
|
||||
|
||||
$lastUpOrderId = RetailcrmConfigProvider::getLastOrderId();
|
||||
$failedIds = RetailcrmConfigProvider::getFailedOrdersIds();
|
||||
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
$orderIds = $failedIds;
|
||||
} elseif ($orderList !== false && count($orderList) > 0) {
|
||||
$orderIds = $orderList;
|
||||
} else {
|
||||
$dbOrder = \Bitrix\Sale\Internals\OrderTable::GetList(array(
|
||||
'order' => array("ID" => "ASC"),
|
||||
'filter' => array('>ID' => $lastUpOrderId),
|
||||
'limit' => $pSize,
|
||||
'select' => array('ID')
|
||||
));
|
||||
while ($arOrder = $dbOrder->fetch()) {
|
||||
$orderIds[] = $arOrder['ID'];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($orderIds)<=0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$api_host = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_HOST_OPTION, 0);
|
||||
$api_key = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_KEY_OPTION, 0);
|
||||
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
$optionsOrderTypes = RetailcrmConfigProvider::getOrderTypes();
|
||||
$optionsDelivTypes = RetailcrmConfigProvider::getDeliveryTypes();
|
||||
$optionsPayTypes = RetailcrmConfigProvider::getPaymentTypes();
|
||||
$optionsPayStatuses = RetailcrmConfigProvider::getPaymentStatuses(); // --statuses
|
||||
$optionsPayment = RetailcrmConfigProvider::getPayment();
|
||||
$optionsOrderProps = RetailcrmConfigProvider::getOrderProps();
|
||||
$optionsLegalDetails = RetailcrmConfigProvider::getLegalDetails();
|
||||
$optionsContragentType = RetailcrmConfigProvider::getContragentTypes();
|
||||
$optionsCustomFields = RetailcrmConfigProvider::getCustomFields();
|
||||
|
||||
$api = new RetailCrm\ApiClient(RetailcrmConfigProvider::getApiUrl(), RetailcrmConfigProvider::getApiKey());
|
||||
|
||||
$arParams = array(
|
||||
'optionsOrderTypes' => $optionsOrderTypes,
|
||||
'optionsDelivTypes' => $optionsDelivTypes,
|
||||
'optionsPayTypes' => $optionsPayTypes,
|
||||
'optionsPayStatuses' => $optionsPayStatuses,
|
||||
'optionsPayment' => $optionsPayment,
|
||||
'optionsOrderProps' => $optionsOrderProps,
|
||||
'optionsLegalDetails' => $optionsLegalDetails,
|
||||
'optionsContragentType' => $optionsContragentType,
|
||||
'optionsSitesList' => $optionsSitesList,
|
||||
'optionsCustomFields' => $optionsCustomFields,
|
||||
);
|
||||
|
||||
$recOrders = array();
|
||||
foreach ($orderIds as $orderId) {
|
||||
$id = \Bitrix\Sale\Order::load($orderId);
|
||||
if (!$id) {
|
||||
continue;
|
||||
}
|
||||
$order = self::orderObjToArr($id);
|
||||
$user = Bitrix\Main\UserTable::getById($order['USER_ID'])->fetch();
|
||||
|
||||
$site = count($optionsSitesList) > 1 ? $optionsSitesList[$order['LID']] : null;
|
||||
|
||||
$arCustomers = RetailCrmUser::customerSend($user, $api, $optionsContragentType[$order['PERSON_TYPE_ID']], false, $site);
|
||||
$arOrders = self::orderSend($order, $api, $arParams, false, $site);
|
||||
|
||||
if (!$arCustomers || !$arOrders) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$resCustomers[$order['LID']][] = $arCustomers;
|
||||
$resOrders[$order['LID']][] = $arOrders;
|
||||
|
||||
$recOrders[] = $orderId;
|
||||
}
|
||||
|
||||
if (count($resOrders) > 0) {
|
||||
foreach ($resCustomers as $key => $customerLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site == null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'customersUpload', __METHOD__, $customerLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
}
|
||||
foreach ($resOrders as $key => $orderLoad) {
|
||||
if ($optionsSitesList) {
|
||||
if (array_key_exists($key, $optionsSitesList) && $optionsSitesList[$key] != null) {
|
||||
$site = $optionsSitesList[$key];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} elseif (!$optionsSitesList) {
|
||||
$site == null;
|
||||
}
|
||||
if (RCrmActions::apiMethod($api, 'ordersUpload', __METHOD__, $orderLoad, $site) === false) {
|
||||
return false;
|
||||
}
|
||||
if (count($optionsSitesList) > 1) {
|
||||
time_nanosleep(0, 250000000);
|
||||
}
|
||||
}
|
||||
if ($failed == true && $failedIds !== false && count($failedIds) > 0) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_FAILED_IDS, serialize(array_diff($failedIds, $recOrders)));
|
||||
} elseif ($lastUpOrderId < max($recOrders) && $orderList === false) {
|
||||
COption::SetOptionString(self::$MODULE_ID, self::$CRM_ORDER_LAST_ID, max($recOrders));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if provided order array is corporate order data. v4 doesn't have corporate orders.
|
||||
*
|
||||
* @param array|\ArrayAccess $order
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOrderCorporate($order)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function orderObjToArr($obOrder)
|
||||
{
|
||||
$culture = new \Bitrix\Main\Context\Culture(array("FORMAT_DATETIME" => "Y-m-d HH:i:s"));
|
||||
$arOrder = array(
|
||||
'ID' => $obOrder->getId(),
|
||||
'NUMBER' => $obOrder->getField('ACCOUNT_NUMBER'),
|
||||
'LID' => $obOrder->getSiteId(),
|
||||
'DATE_INSERT' => $obOrder->getDateInsert()->toString($culture),
|
||||
'STATUS_ID' => $obOrder->getField('STATUS_ID'),
|
||||
'USER_ID' => $obOrder->getUserId(),
|
||||
'PERSON_TYPE_ID' => $obOrder->getPersonTypeId(),
|
||||
'CURRENCY' => $obOrder->getCurrency(),
|
||||
'PAYMENTS' => $obOrder->getPaymentSystemId(),
|
||||
'PAYED' => $obOrder->isPaid() ? 'Y' : 'N',
|
||||
'DELIVERYS' => array(),
|
||||
'PRICE_DELIVERY' => $obOrder->getDeliveryPrice(),
|
||||
'PROPS' => $obOrder->getPropertyCollection()->getArray(),
|
||||
'DISCOUNTS' => $obOrder->getDiscount()->getApplyResult(),
|
||||
'BASKET' => array(),
|
||||
'USER_DESCRIPTION' => $obOrder->getField('USER_DESCRIPTION'),
|
||||
'COMMENTS' => $obOrder->getField('COMMENTS'),
|
||||
'REASON_CANCELED' => $obOrder->getField('REASON_CANCELED'),
|
||||
);
|
||||
|
||||
$shipmentList = $obOrder->getShipmentCollection();
|
||||
foreach ($shipmentList as $shipmentData) {
|
||||
if ($shipmentData->isSystem()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($shipmentData->getDeliveryId()) {
|
||||
$delivery = \Bitrix\Sale\Delivery\Services\Manager::getById($shipmentData->getDeliveryId());
|
||||
$siteDeliverys = RCrmActions::DeliveryList();
|
||||
foreach ($siteDeliverys as $siteDelivery) {
|
||||
if ($siteDelivery['ID'] == $delivery['ID'] && $siteDelivery['PARENT_ID'] == 0) {
|
||||
unset($delivery['PARENT_ID']);
|
||||
}
|
||||
}
|
||||
if ($delivery['PARENT_ID']) {
|
||||
$servise = explode(':', $delivery['CODE']);
|
||||
$shipment = array('id' => $delivery['PARENT_ID'], 'service' => $servise[1]);
|
||||
} else {
|
||||
$shipment = array('id' => $delivery['ID']);
|
||||
}
|
||||
$arOrder['DELIVERYS'][] = $shipment;
|
||||
}
|
||||
}
|
||||
|
||||
$basketItems = $obOrder->getBasket();
|
||||
foreach ($basketItems as $item) {
|
||||
$arOrder['BASKET'][] = $item->getFields();
|
||||
}
|
||||
|
||||
return $arOrder;
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
- Исправлены ошибки при работе с программой лояльности
|
||||
- Удалена поддержка API V4
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$arModuleVersion = [
|
||||
'VERSION' => '6.4.4',
|
||||
'VERSION_DATE' => '2023-09-01 10:00:00'
|
||||
'VERSION' => '6.4.5',
|
||||
'VERSION_DATE' => '2023-09-01 10:30:00'
|
||||
];
|
||||
|
@ -576,9 +576,7 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
||||
$version = COption::GetOptionString($mid, $CRM_API_VERSION);
|
||||
|
||||
if (htmlspecialchars(trim($_POST['api_version'])) != $version) {
|
||||
if (htmlspecialchars(trim($_POST['api_version'])) === 'v4') {
|
||||
$version = 'v4';
|
||||
} elseif (htmlspecialchars(trim($_POST['api_version'])) === 'v5') {
|
||||
if (htmlspecialchars(trim($_POST['api_version'])) === 'v5') {
|
||||
$version = 'v5';
|
||||
} else {
|
||||
LocalRedirect($uri);
|
||||
@ -2295,13 +2293,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="heading">
|
||||
|
||||
<?php //По умолчанию используем апи V5. При добавлении в будущем V6 выводить пользователю данный блок ?>
|
||||
<tr class="heading" hidden="hidden">
|
||||
<td colspan="2" class="option-other-heading"><b><?php echo GetMessage('CRM_API_VERSION'); ?></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr hidden="hidden">
|
||||
<td colspan="2" class="option-head option-other-top option-other-bottom">
|
||||
<select name="api_version" class="typeselect">
|
||||
<?php for ($v = 4; $v <= 5; $v++) {
|
||||
<?php for ($v = 5; $v <= 5; $v++) {
|
||||
$ver = 'v' . $v; ?>
|
||||
<option value="<?php echo $ver; ?>" <?php if ($ver === $version) {
|
||||
echo 'selected';
|
||||
|
@ -1181,6 +1181,8 @@ function update()
|
||||
Loader::includeModule('sale');
|
||||
Loader::includeModule('highloadblock');
|
||||
|
||||
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v5');
|
||||
|
||||
(new LoyaltyProgramUpdater())
|
||||
->updateBonusInfoFieldForLp()
|
||||
->updateBonusFieldsTypeInHl()
|
||||
|
@ -46,7 +46,6 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
/**
|
||||
* @param $history
|
||||
* @param $v5
|
||||
* @param $new
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@ -57,7 +56,7 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @dataProvider paymentSaveDataProvider
|
||||
*/
|
||||
public function testPaymentSave($history, $v5, $new)
|
||||
public function testPaymentSave($history, $new)
|
||||
{
|
||||
$event = $this->createMock(\Bitrix\Sale\Payment::class);
|
||||
|
||||
@ -77,10 +76,6 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
$GLOBALS['RETAIL_CRM_HISTORY'] = true;
|
||||
}
|
||||
|
||||
if ($v5 === false) {
|
||||
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v4');
|
||||
}
|
||||
|
||||
$result = RetailCrmEvent::paymentSave($event);
|
||||
|
||||
$this->assertEquals(false, $result);
|
||||
@ -88,7 +83,6 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
/**
|
||||
* @param $history
|
||||
* @param $v5
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws \PHPUnit\Framework\Exception
|
||||
@ -97,7 +91,7 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
*
|
||||
* @dataProvider paymentDeleteDataProvider
|
||||
*/
|
||||
public function testPaymentDelete($history, $v5)
|
||||
public function testPaymentDelete($history)
|
||||
{
|
||||
$event = $this->createMock(\Bitrix\Sale\Payment::class);
|
||||
|
||||
@ -105,10 +99,6 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
$GLOBALS['RETAIL_CRM_HISTORY'] = true;
|
||||
}
|
||||
|
||||
if ($v5 === false) {
|
||||
COption::SetOptionString('intaro.retailcrm', 'api_version', 'v4');
|
||||
}
|
||||
|
||||
$result = RetailCrmEvent::paymentDelete($event);
|
||||
|
||||
$this->assertEquals(false, $result);
|
||||
@ -247,17 +237,14 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
return [
|
||||
[
|
||||
'history' => true,
|
||||
'v5' => true,
|
||||
'new' => false
|
||||
],
|
||||
[
|
||||
'history' => false,
|
||||
'v5' => false,
|
||||
'new' => false
|
||||
],
|
||||
[
|
||||
'history' => false,
|
||||
'v5' => true,
|
||||
'new' => true
|
||||
]
|
||||
];
|
||||
@ -271,15 +258,12 @@ class RetailCrmEventTest extends PHPUnit\Framework\TestCase
|
||||
return [
|
||||
[
|
||||
'history' => true,
|
||||
'v5' => true
|
||||
],
|
||||
[
|
||||
'history' => false,
|
||||
'v5' => false
|
||||
],
|
||||
[
|
||||
'history' => false,
|
||||
'v5' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user