parent
85749c8602
commit
830fe34e3e
@ -1,3 +1,6 @@
|
|||||||
|
## 2024-03-28 v.6.5.11
|
||||||
|
- Исправлена ошибка дублирования скидок
|
||||||
|
|
||||||
## 2024-03-18 v.6.5.10
|
## 2024-03-18 v.6.5.10
|
||||||
- Добавлена валидация прав API ключа
|
- Добавлена валидация прав API ключа
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
class RestNormalizer
|
class RestNormalizer
|
||||||
{
|
{
|
||||||
public $clear = true;
|
public $clear = true;
|
||||||
private $validation = array();
|
private $validation = [];
|
||||||
private $originalValidation = array();
|
private $originalValidation = [];
|
||||||
private $server;
|
private $server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,8 +55,10 @@ class RestNormalizer
|
|||||||
$file = $server . $file;
|
$file = $server . $file;
|
||||||
if (is_null($file) || is_file($file) === false
|
if (is_null($file) || is_file($file) === false
|
||||||
|| json_decode(file_get_contents($file)) === null
|
|| json_decode(file_get_contents($file)) === null
|
||||||
|| $this->parseConfig($file) === false) {
|
|| $this->parseConfig($file) === false
|
||||||
|
) {
|
||||||
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect file normalize.');
|
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect file normalize.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ class RestNormalizer
|
|||||||
|
|
||||||
if (!is_array($data) || count($data) < 1) {
|
if (!is_array($data) || count($data) < 1) {
|
||||||
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect data array.');
|
RCrmActions::eventLog('RestNormalizer', 'intaro.retailcrm', 'Incorrect data array.');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +91,7 @@ class RestNormalizer
|
|||||||
*/
|
*/
|
||||||
final private function formatting($data, $skip = false)
|
final private function formatting($data, $skip = false)
|
||||||
{
|
{
|
||||||
$formatted = array();
|
$formatted = [];
|
||||||
|
|
||||||
foreach ($data as $code => $value) {
|
foreach ($data as $code => $value) {
|
||||||
if (isset($this->validation[ $code ]) && $this->validation[ $code ]['type'] == 'skip') {
|
if (isset($this->validation[ $code ]) && $this->validation[ $code ]['type'] == 'skip') {
|
||||||
@ -99,13 +102,15 @@ class RestNormalizer
|
|||||||
$formatted[ $code ] = $this->formatting($value, true);
|
$formatted[ $code ] = $this->formatting($value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($formatted[$code] && $formatted[$code] !== 0)) {
|
//Удаление пустых переменных, кроме значений равных 0
|
||||||
|
if (empty($formatted[$code]) && $formatted[$code] !== 0 && $formatted[$code] !== 0.0) {
|
||||||
if ($this->clear === true) {
|
if ($this->clear === true) {
|
||||||
unset($formatted[ $code ]);
|
unset($formatted[ $code ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->validation[ $code ]['required']) && $this->validation[ $code ]['required'] === true) {
|
if (isset($this->validation[ $code ]['required']) && $this->validation[ $code ]['required'] === true) {
|
||||||
$formatted = array();
|
$formatted = [];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +179,8 @@ class RestNormalizer
|
|||||||
$data = trim((string) $data);
|
$data = trim((string) $data);
|
||||||
|
|
||||||
if (isset($validation['default']) && is_string($validation['default']) && trim($validation['default']) != ''
|
if (isset($validation['default']) && is_string($validation['default']) && trim($validation['default']) != ''
|
||||||
&& ($data == '' || is_string($data) === false)) {
|
&& ($data == '' || is_string($data) === false)
|
||||||
|
) {
|
||||||
$data = trim($validation['default']);
|
$data = trim($validation['default']);
|
||||||
} elseif ($data == '' || is_string($data) === false) {
|
} elseif ($data == '' || is_string($data) === false) {
|
||||||
return null;
|
return null;
|
||||||
@ -302,7 +308,8 @@ class RestNormalizer
|
|||||||
} elseif (isset($validation['default']) && in_array($validation['default'], $validation['values']) === false) {
|
} elseif (isset($validation['default']) && in_array($validation['default'], $validation['values']) === false) {
|
||||||
return null;
|
return null;
|
||||||
} elseif (in_array($data, $validation['values']) === false
|
} elseif (in_array($data, $validation['values']) === false
|
||||||
&& isset($validation['default']) && in_array($validation['default'], $validation['values'])) {
|
&& isset($validation['default']) && in_array($validation['default'], $validation['values'])
|
||||||
|
) {
|
||||||
$data = $validation['default'];
|
$data = $validation['default'];
|
||||||
} elseif (in_array($data, $validation['values']) === false) {
|
} elseif (in_array($data, $validation['values']) === false) {
|
||||||
return null;
|
return null;
|
||||||
@ -327,10 +334,13 @@ class RestNormalizer
|
|||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = array_diff($value, array('', NULL));
|
$value = array_diff($value, array('', NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$APPLICATION->ConvertCharset($code, SITE_CHARSET, 'utf-8')] = is_array($value)
|
$data[$APPLICATION->ConvertCharset($code, SITE_CHARSET, 'utf-8')] = is_array($value)
|
||||||
? $this->multiConvert($value)
|
? $this->multiConvert($value)
|
||||||
: $APPLICATION->ConvertCharset($value, SITE_CHARSET, 'utf-8');
|
: $APPLICATION->ConvertCharset($value, SITE_CHARSET, 'utf-8')
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
} else {
|
} else {
|
||||||
return $APPLICATION->ConvertCharset($data, SITE_CHARSET, 'utf-8');
|
return $APPLICATION->ConvertCharset($data, SITE_CHARSET, 'utf-8');
|
||||||
|
@ -328,6 +328,8 @@ class RetailCrmOrder
|
|||||||
} elseif ($product['BASE_PRICE'] >= $product['PRICE']) {
|
} elseif ($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'];
|
||||||
|
$order['discountManualAmount'] = 0;
|
||||||
|
$order['discountManualPercent'] = 0;
|
||||||
} else {
|
} else {
|
||||||
$item['discountManualAmount'] = 0;
|
$item['discountManualAmount'] = 0;
|
||||||
$item['initialPrice'] = $product['PRICE'];
|
$item['initialPrice'] = $product['PRICE'];
|
||||||
|
@ -1 +1 @@
|
|||||||
- Добавлена валидация прав API ключа
|
- Исправлена ошибка дублирования скидок
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$arModuleVersion = [
|
$arModuleVersion = [
|
||||||
'VERSION' => '6.5.10',
|
'VERSION' => '6.5.11',
|
||||||
'VERSION_DATE' => '2024-03-18 14:30:00'
|
'VERSION_DATE' => '2024-03-28 12:00:00'
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user