1
0
mirror of synced 2024-11-26 07:16:08 +03:00
This commit is contained in:
Akolzin Dmitry 2018-07-16 16:01:19 +03:00
parent 6412e6bf7f
commit 7e3ea3fa87
8 changed files with 86 additions and 189 deletions

View File

@ -1,4 +1,9 @@
## 2018-06-33 v.2.3.7 ## 2018-07-16 v.2.3.8
* Добавлен рассчет стоимости товара с учетом наценки
* Добавлена выгрузка картинок товара, если отсутствует картинка торгового предложения
* Заменены устаревшие методы в API клиенте
## 2018-06-13 v.2.3.7
* Добавлена выгрузка штрихкодов в ICML * Добавлена выгрузка штрихкодов в ICML
* Добавлена выгрузка картинок торговых предложений в ICML * Добавлена выгрузка картинок торговых предложений в ICML
* Улучшена передача типа доставки в заказе * Улучшена передача типа доставки в заказе

View File

@ -48,8 +48,6 @@ class ApiClient
* @param string $site site code * @param string $site site code
* *
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*
* @return mixed
*/ */
public function __construct($url, $apiKey, $site = null) public function __construct($url, $apiKey, $site = null)
{ {
@ -1373,30 +1371,6 @@ class ApiClient
); );
} }
/**
* Get store settings
*
* @param string $code get settings code
*
* @return ApiResponse
* @throws \RetailCrm\Exception\InvalidJsonException
* @throws \RetailCrm\Exception\CurlException
* @throws \InvalidArgumentException
*
* @return ApiResponse
*/
public function storeSettingsGet($code)
{
if (empty($code)) {
throw new \InvalidArgumentException('Parameter `code` must be set');
}
return $this->client->makeRequest(
"/store/setting/$code",
Client::METHOD_GET
);
}
/** /**
* Upload store inventories * Upload store inventories
* *
@ -1486,30 +1460,31 @@ class ApiClient
} }
/** /**
* Get delivery settings * Get module configuration
* *
* @param string $code * @param string $code
* *
* @throws \InvalidArgumentException
* @throws \RetailCrm\Exception\CurlException
* @throws \RetailCrm\Exception\InvalidJsonException * @throws \RetailCrm\Exception\InvalidJsonException
* @throws \RetailCrm\Exception\CurlException
* @throws \InvalidArgumentException
* *
* @return ApiResponse * @return ApiResponse
*/ */
public function deliverySettingsGet($code) public function integrationModulesGet($code)
{ {
if (empty($code)) { if (empty($code)) {
throw new \InvalidArgumentException('Parameter `code` must be set'); throw new \InvalidArgumentException(
'Parameter `code` must be set'
);
} }
return $this->client->makeRequest( return $this->client->makeRequest(
"/delivery/generic/setting/$code", sprintf('/integration-modules/%s', $code),
Client::METHOD_GET Client::METHOD_GET
); );
} }
/** /**
* Edit delivery configuration * Edit module configuration
* *
* @param array $configuration * @param array $configuration
* *
@ -1519,7 +1494,7 @@ class ApiClient
* *
* @return ApiResponse * @return ApiResponse
*/ */
public function deliverySettingsEdit(array $configuration) public function integrationModulesEdit(array $configuration)
{ {
if (!count($configuration) || empty($configuration['code'])) { if (!count($configuration) || empty($configuration['code'])) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
@ -1528,9 +1503,9 @@ class ApiClient
} }
return $this->client->makeRequest( return $this->client->makeRequest(
sprintf('/delivery/generic/setting/%s/edit', $configuration['code']), sprintf('/integration-modules/%s/edit', $configuration['code']),
Client::METHOD_POST, Client::METHOD_POST,
array('configuration' => json_encode($configuration)) array('integrationModule' => json_encode($configuration))
); );
} }
@ -2117,134 +2092,6 @@ class ApiClient
); );
} }
/**
* Get telephony settings
*
* @param string $code
*
* @throws \RetailCrm\Exception\InvalidJsonException
* @throws \RetailCrm\Exception\CurlException
* @throws \InvalidArgumentException
*
* @return ApiResponse
*/
public function telephonySettingsGet($code)
{
if (empty($code)) {
throw new \InvalidArgumentException('Parameter `code` must be set');
}
return $this->client->makeRequest(
"/telephony/setting/$code",
Client::METHOD_GET
);
}
/**
* Edit telephony settings
*
* @param string $code symbolic code
* @param string $clientId client id
* @param boolean $active telephony activity
* @param mixed $name service name
* @param mixed $makeCallUrl service init url
* @param mixed $image service logo url(svg file)
*
* @param array $additionalCodes
* @param array $externalPhones
* @param bool $allowEdit
* @param bool $inputEventSupported
* @param bool $outputEventSupported
* @param bool $hangupEventSupported
* @param bool $changeUserStatusUrl
*
* @return ApiResponse
*/
public function telephonySettingsEdit(
$code,
$clientId,
$active = false,
$name = false,
$makeCallUrl = false,
$image = false,
$additionalCodes = array(),
$externalPhones = array(),
$allowEdit = false,
$inputEventSupported = false,
$outputEventSupported = false,
$hangupEventSupported = false,
$changeUserStatusUrl = false
)
{
if (!isset($code)) {
throw new \InvalidArgumentException('Code must be set');
}
$parameters['code'] = $code;
if (!isset($clientId)) {
throw new \InvalidArgumentException('client id must be set');
}
$parameters['clientId'] = $clientId;
if (!isset($active)) {
$parameters['active'] = false;
} else {
$parameters['active'] = $active;
}
if (!isset($name)) {
throw new \InvalidArgumentException('name must be set');
}
if (isset($name)) {
$parameters['name'] = $name;
}
if (isset($makeCallUrl)) {
$parameters['makeCallUrl'] = $makeCallUrl;
}
if (isset($image)) {
$parameters['image'] = $image;
}
if (isset($additionalCodes)) {
$parameters['additionalCodes'] = $additionalCodes;
}
if (isset($externalPhones)) {
$parameters['externalPhones'] = $externalPhones;
}
if (isset($allowEdit)) {
$parameters['allowEdit'] = $allowEdit;
}
if (isset($inputEventSupported)) {
$parameters['inputEventSupported'] = $inputEventSupported;
}
if (isset($outputEventSupported)) {
$parameters['outputEventSupported'] = $outputEventSupported;
}
if (isset($hangupEventSupported)) {
$parameters['hangupEventSupported'] = $hangupEventSupported;
}
if (isset($changeUserStatusUrl)) {
$parameters['changeUserStatusUrl'] = $changeUserStatusUrl;
}
return $this->client->makeRequest(
"/telephony/setting/$code/edit",
Client::METHOD_POST,
array('configuration' => json_encode($parameters))
);
}
/** /**
* Call event * Call event
* *

View File

@ -267,10 +267,14 @@ class RCrmActions
* *
* @param string $string * @param string $string
* *
* @return array * @return mixed
*/ */
public static function unserializeArrayRecursive($string) public static function unserializeArrayRecursive($string)
{ {
if ($string === false || empty($string)) {
return false;
}
if (is_string($string)) { if (is_string($string)) {
$string = unserialize($string); $string = unserialize($string);
} }
@ -348,7 +352,7 @@ class RCrmActions
} }
} }
private function proxy($api, $methodApi, $method, $params) { private static function proxy($api, $methodApi, $method, $params) {
$log = new Logger(); $log = new Logger();
$version = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_VERSION, 0); $version = COption::GetOptionString(self::$MODULE_ID, self::$CRM_API_VERSION, 0);
try { try {
@ -428,12 +432,28 @@ class RCrmActions
} }
return false; return false;
} catch (\RetailCrm\Exception\InvalidJsonException $e) {
self::eventLog(
__CLASS__ . '::' . $method, 'RetailCrm\ApiClient::' . $methodApi . '::InvalidJsonException',
$e->getCode() . ': ' . $e->getMessage()
);
$log->write(array(
'api' => $version,
'methodApi' => $methodApi,
'errorMsg' => $e->getMessage(),
'errors' => $e->getCode(),
'params' => $params
), 'apiErrors');
if (function_exists('retailCrmApiResult')) {
retailCrmApiResult($methodApi, false, 'ArgumentException');
}
} }
if (function_exists('retailCrmApiResult')) { if (function_exists('retailCrmApiResult')) {
retailCrmApiResult($methodApi, true, $result->getStatusCode()); retailCrmApiResult($methodApi, true, $result->getStatusCode());
} }
return $result; return isset($result) ? $result : false;
} }
} }

View File

@ -619,7 +619,7 @@ class RetailCrmHistory
$fUserId = $basket->getFUserId(true); $fUserId = $basket->getFUserId(true);
if ($fUserId === null) { if (!$fUserId) {
$fUserId = Bitrix\Sale\Fuser::getIdByUserId($order['customer']['externalId']); $fUserId = Bitrix\Sale\Fuser::getIdByUserId($order['customer']['externalId']);
$basket->setFUserId($fUserId); $basket->setFUserId($fUserId);
} }
@ -671,12 +671,20 @@ class RetailCrmHistory
if (array_key_exists('discountTotal', $product)) { if (array_key_exists('discountTotal', $product)) {
$itemCost = $item->getField('BASE_PRICE'); $itemCost = $item->getField('BASE_PRICE');
$discount = (double) $item->getField('DISCOUNT_PRICE');
if (isset($itemCost) && $itemCost >= 0) { if (isset($itemCost) && $itemCost >= 0) {
if ($discount < 0) {
$resultDiscount = $product['discountTotal'] + $discount;
} else {
$resultDiscount = $product['discountTotal'];
}
$item->setField('CUSTOM_PRICE', 'Y'); $item->setField('CUSTOM_PRICE', 'Y');
$item->setField('PRICE', $itemCost - $product['discountTotal']);
$item->setField('DISCOUNT_PRICE', $product['discountTotal']);
$item->setField('DISCOUNT_NAME', ''); $item->setField('DISCOUNT_NAME', '');
$item->setField('DISCOUNT_VALUE', ''); $item->setField('DISCOUNT_VALUE', '');
$item->setField('DISCOUNT_PRICE', $product['discountTotal'] + $resultDiscount);
$item->setField('PRICE', $itemCost - $resultDiscount);
} }
} }
} }

View File

@ -404,7 +404,6 @@ class RetailCrmICML
while ($offer = $dbResOffers->GetNext()) { while ($offer = $dbResOffers->GetNext()) {
// Link offers to products // Link offers to products
$offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
$products[$offer['PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'] . '_VALUE']]['offers'][$offer['ID']] = $offer; $products[$offer['PROPERTY_' . $iblockOffer['SKU_PROPERTY_ID'] . '_VALUE']]['offers'][$offer['ID']] = $offer;
} }
unset($offer, $dbResOffers); unset($offer, $dbResOffers);
@ -459,7 +458,13 @@ class RetailCrmICML
$offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : ''; $offer['BARCODE'] = isset($barcodes[$offer['ID']]) ? $barcodes[$offer['ID']] : '';
$offer['PRODUCT_ID'] = $product["ID"]; $offer['PRODUCT_ID'] = $product["ID"];
$offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"]; $offer['DETAIL_PAGE_URL'] = $product["DETAIL_PAGE_URL"];
$offer['PICTURE'] = $offer["PICTURE"] ? $offer["PICTURE"] : $product["PICTURE"];
if (CFile::GetPath($offer["DETAIL_PICTURE"])) {
$offer['PICTURE'] = $this->protocol . $this->serverName . CFile::GetPath($offer["DETAIL_PICTURE"]);
} else {
$offer['PICTURE'] = $product["PICTURE"];
}
$offer['PRODUCT_NAME'] = $product["NAME"]; $offer['PRODUCT_NAME'] = $product["NAME"];
$offer['PRODUCT_ACTIVE'] = $product["ACTIVE"]; $offer['PRODUCT_ACTIVE'] = $product["ACTIVE"];
$offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId]; $offer['PRICE'] = $offer['CATALOG_PRICE_' . $basePriceId];

View File

@ -148,18 +148,31 @@ class RetailCrmOrder
if (is_null($pp['PURCHASING_PRICE']) == false) { if (is_null($pp['PURCHASING_PRICE']) == false) {
$item['purchasePrice'] = $pp['PURCHASING_PRICE']; $item['purchasePrice'] = $pp['PURCHASING_PRICE'];
} }
$item['discountManualAmount'] = (double) $product['DISCOUNT_PRICE'];
$discount = (double) $product['DISCOUNT_PRICE'];
if ($discount < 0) {
$item['discountManualAmount'] = 0;
$initialPrice = (double) $product['PRICE'];
} else {
$item['discountManualAmount'] = (double) $product['DISCOUNT_PRICE'];
$initialPrice = (double) $product['PRICE'] + (double) $product['DISCOUNT_PRICE'];
}
$item['discountManualPercent'] = 0; $item['discountManualPercent'] = 0;
$item['initialPrice'] = (double) $product['PRICE'] + (double) $product['DISCOUNT_PRICE']; $item['initialPrice'] = $initialPrice;
$order['items'][] = $item; $order['items'][] = $item;
if ($send && $dimensions == 'Y') { if ($send && $dimensions == 'Y') {
$dimensions = RCrmActions::unserializeArrayRecursive($product['DIMENSIONS']); $dimensions = RCrmActions::unserializeArrayRecursive($product['DIMENSIONS']);
$width += $dimensions['WIDTH'];
$height += $dimensions['HEIGHT']; if ($dimensions !== false) {
$length += $dimensions['LENGTH']; $width += $dimensions['WIDTH'];
$weight += $product['WEIGHT']; $height += $dimensions['HEIGHT'];
$length += $dimensions['LENGTH'];
$weight += $product['WEIGHT'];
}
} }
} }

View File

@ -1,4 +1,3 @@
- Добавлена выгрузка штрихкодов в ICML - Добавлен рассчет стоимости товара с учетом наценки
- Добавлена выгрузка картинок торговых предложений в ICML - Добавлена выгрузка картинок товара, если отсутствует картинка торгового предложения
- Улучшена передача типа доставки в заказе - Заменены устаревшие методы в API клиенте
- Добавлена проверка некоторых настроек при передаче заказа

View File

@ -1,5 +1,5 @@
<? <?
$arModuleVersion = array( $arModuleVersion = array(
"VERSION" => "2.3.7", "VERSION" => "2.3.8",
"VERSION_DATE" => "2018-06-13 13:15:00" "VERSION_DATE" => "2018-07-16 16:00:00"
); );