• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/rest/synchronization/synchronizer.php
  • Класс: BitrixSaleRestSynchronizationSynchronizer
  • Вызов: Synchronizer::addMarkedTimelineExternalSystem
static function addMarkedTimelineExternalSystem($externalOrderId, array $params)
{
	$typeId = 0;
	$message = '';
	$siteName = '';

	$sites = self::getSites();
	$instance = Manager::getInstance();

	if($params['type'] == 'success')
		$typeId = 2;
	elseif ($params['type']== 'failed')
		$typeId = 5;

	if(isset($params['siteId']) && $params['siteId']<>'')
		$siteName = isset($sites[$params['siteId']])?$sites[$params['siteId']]['NAME']:'';
	if($siteName == '')
		$siteName =  $sites[SITE_ID]['NAME'];

	if($params['direction'] == 'incoming')
	{
		if($params['type'] == 'success')
		{
			$message = Loc::getMessage('SYNCH_OUTCOMING_REPLICATION_EXTERNAL_SYSTEM_MESS_EXPORT_ORDER_SUCCESS', [
				'#EXTERNAL_SYSTEM#'=>($siteName<>''?' ('.$siteName.')':''),
				'#ORDER_ID#'=>($params['orderId']>0?$params['orderId']:'')
			]);
		}
		else
		{
			$message = Loc::getMessage('SYNCH_OUTCOMING_REPLICATION_EXTERNAL_SYSTEM_MESS_EXPORT_ORDER_ERROR', [
				'#EXTERNAL_SYSTEM#'=>($siteName<>''?' ('.$siteName.')':''),
				'#ERROR_MESSAGE#'=>($params['errorMessage']<>''?$params['errorMessage']:'')
			]);
		}
	}
	if($params['direction'] == 'outcoming')
	{
		$message = Loc::getMessage('SYNCH_OUTCOMING_REPLICATION_EXTERNAL_SYSTEM_MESS_IMPORT_EXTERNAL_ORDER', [
			'#EXTERNAL_SYSTEM#'=>($siteName<>''?' ('.$siteName.')':''),
			'#ORDER_ID#'=>($params['orderId']>0?$params['orderId']:'')
		]);
	}

	$instance->getClient()->call(
		'sale.synchronizer.addTimelineAfterOrderModify',
		[
			'auth'=>$instance->getAccessToken(),
			'orderId'=>$externalOrderId,
			'params'=>[
				'type'=>$typeId,
				'message'=>$message
			]
		]
	);
}