changed logger to new one
This commit is contained in:
parent
a0f224f882
commit
2a56e087af
12 changed files with 91 additions and 67 deletions
|
@ -188,13 +188,13 @@ class RCrmActions
|
|||
|
||||
public static function eventLog($auditType, $itemId, $description)
|
||||
{
|
||||
CEventLog::Add(array(
|
||||
CEventLog::Add([
|
||||
'SEVERITY' => 'SECURITY',
|
||||
'AUDIT_TYPE_ID' => $auditType,
|
||||
'MODULE_ID' => self::$MODULE_ID,
|
||||
'ITEM_ID' => $itemId,
|
||||
'DESCRIPTION' => $description,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,11 @@ use Bitrix\Sale\Location\Search\Finder;
|
|||
use Bitrix\Sale\Order;
|
||||
use Bitrix\Sale\OrderUserProperties;
|
||||
use Intaro\RetailCrm\Service\ManagerService;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Intaro\RetailCrm\Component\Handlers\EventsHandlers;
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
use Intaro\RetailCrm\Service\LoyaltyService;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
class RetailCrmHistory
|
||||
|
@ -532,7 +537,7 @@ class RetailCrmHistory
|
|||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$site = self::getSite($order['site']);
|
||||
|
||||
if (null === $site) {
|
||||
|
@ -1229,7 +1234,7 @@ class RetailCrmHistory
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $shopCode
|
||||
*
|
||||
|
@ -1238,18 +1243,18 @@ class RetailCrmHistory
|
|||
public static function getSite(string $shopCode): ?string
|
||||
{
|
||||
$optionsSitesList = RetailcrmConfigProvider::getSitesList();
|
||||
|
||||
|
||||
if ($optionsSitesList) {
|
||||
$searchResult = array_search($shopCode, $optionsSitesList, true);
|
||||
|
||||
|
||||
return is_string($searchResult) ? $searchResult : null;
|
||||
}
|
||||
|
||||
|
||||
$defaultSite = CSite::GetDefSite();
|
||||
|
||||
|
||||
return is_string($defaultSite) ? $defaultSite : null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $array
|
||||
* @param $value
|
||||
|
@ -1493,7 +1498,7 @@ class RetailCrmHistory
|
|||
|
||||
return $orders;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Filters out history by these terms:
|
||||
* - Changes from current API key will be added only if CMS changes are more actual than history.
|
||||
|
@ -1512,7 +1517,7 @@ class RetailCrmHistory
|
|||
$history = [];
|
||||
$organizedHistory = [];
|
||||
$notOurChanges = [];
|
||||
|
||||
|
||||
foreach ($historyEntries as $entry) {
|
||||
if (!isset($entry[$recordType]['externalId'])) {
|
||||
if ($entry['source'] == 'api'
|
||||
|
@ -1522,23 +1527,23 @@ class RetailCrmHistory
|
|||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$history[] = $entry;
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$externalId = $entry[$recordType]['externalId'];
|
||||
$field = $entry['field'];
|
||||
|
||||
|
||||
if (!isset($organizedHistory[$externalId])) {
|
||||
$organizedHistory[$externalId] = [];
|
||||
}
|
||||
|
||||
|
||||
if (!isset($notOurChanges[$externalId])) {
|
||||
$notOurChanges[$externalId] = [];
|
||||
}
|
||||
|
||||
|
||||
if ($entry['source'] == 'api'
|
||||
&& isset($entry['apiKey']['current'])
|
||||
&& $entry['apiKey']['current'] == true
|
||||
|
@ -1553,16 +1558,16 @@ class RetailCrmHistory
|
|||
$notOurChanges[$externalId][$field] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unset($notOurChanges);
|
||||
|
||||
|
||||
foreach ($organizedHistory as $historyChunk) {
|
||||
$history = array_merge($history, $historyChunk);
|
||||
}
|
||||
|
||||
|
||||
return $history;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update shipment in order
|
||||
*
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
<?php
|
||||
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\LoaderException;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
use Intaro\RetailCrm\Service\CustomerService;
|
||||
use Intaro\RetailCrm\Service\LoyaltyService;
|
||||
use Intaro\RetailCrm\Service\LoyaltyAccountService;
|
||||
|
||||
/** RetailCRM loyalty program start */
|
||||
|
@ -50,3 +45,4 @@ try {
|
|||
AddMessage2Log($exception->getMessage());
|
||||
}
|
||||
/** RetailCRM loyalty program end */
|
||||
|
||||
|
|
|
@ -1,40 +1,32 @@
|
|||
<?php
|
||||
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\LoaderException;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
use Intaro\RetailCrm\Service\CustomerService;
|
||||
use Intaro\RetailCrm\Service\LoyaltyService;
|
||||
use Intaro\RetailCrm\Service\LoyaltyAccountService;
|
||||
|
||||
/** RetailCRM loyalty program start */
|
||||
try {
|
||||
Loader::includeModule('intaro.retailcrm');
|
||||
} catch (LoaderException $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
}
|
||||
|
||||
$arResult['LOYALTY_STATUS'] = ConfigProvider::getLoyaltyProgramStatus();
|
||||
|
||||
global $USER;
|
||||
|
||||
if ('Y' === $arResult['LOYALTY_STATUS'] && $USER->IsAuthorized()) {
|
||||
/** @var CustomerService $customerService */
|
||||
$customerService = ServiceLocator::get(CustomerService::class);
|
||||
$customer = $customerService->createModel($USER->GetID());
|
||||
|
||||
$customerService->createCustomer($customer);
|
||||
|
||||
/* @var LoyaltyAccountService $service*/
|
||||
$service = ServiceLocator::get(LoyaltyAccountService::class);
|
||||
$arResult['LP_REGISTER'] = $service->checkRegInLp();
|
||||
}
|
||||
|
||||
try {
|
||||
$arResult['LOYALTY_STATUS'] = ConfigProvider::getLoyaltyProgramStatus();
|
||||
|
||||
global $USER;
|
||||
|
||||
if ('Y' === $arResult['LOYALTY_STATUS'] && $USER->IsAuthorized()) {
|
||||
/** @var CustomerService $customerService */
|
||||
$customerService = ServiceLocator::get(CustomerService::class);
|
||||
$customer = $customerService->createModel($USER->GetID());
|
||||
|
||||
$customerService->createCustomer($customer);
|
||||
|
||||
/* @var LoyaltyAccountService $service */
|
||||
$service = ServiceLocator::get(LoyaltyAccountService::class);
|
||||
$arResult['LP_REGISTER'] = $service->checkRegInLp();
|
||||
}
|
||||
|
||||
$agreementPersonalData = AgreementRepository::getFirstByWhere(
|
||||
['AGREEMENT_TEXT'],
|
||||
[
|
||||
|
@ -49,6 +41,7 @@ try {
|
|||
);
|
||||
$arResult['AGREEMENT_PERSONAL_DATA'] = $agreementPersonalData['AGREEMENT_TEXT'];
|
||||
$arResult['AGREEMENT_LOYALTY_PROGRAM'] = $agreementLoyaltyProgram['AGREEMENT_TEXT'];
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $e) {
|
||||
AddMessage2Log($e->getMessage());
|
||||
} catch (Throwable $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
}
|
||||
/** RetailCRM loyalty program end */
|
||||
|
|
|
@ -32,6 +32,8 @@ use Bitrix\Sale\Internals\OrderTable;
|
|||
use Intaro\RetailCrm\Component\Handlers\EventsHandlers;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Agreement;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Intaro\RetailCrm\Component\Handlers\EventsHandlers;
|
||||
use Intaro\RetailCrm\Model\Bitrix\Agreement;
|
||||
use Intaro\RetailCrm\Repository\AgreementRepository;
|
||||
|
@ -1766,7 +1768,11 @@ class intaro_retailcrm extends CModule
|
|||
);
|
||||
}
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage(), $this->MODULE_ID);
|
||||
RCrmActions::eventLog(
|
||||
'intaro.retailcrm/install/index.php',
|
||||
'RetailCrm\ApiClient::addLPEvents',
|
||||
$exception->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,4 +83,6 @@ class Constants
|
|||
public const LP_BONUS_INFO = 'LP_BONUS_INFO';
|
||||
public const API_ERRORS_LOG = 'apiErrors';
|
||||
public const LOYALTY_ERROR = 'loyaltyErrors';
|
||||
public const HISTORY_ERRORS = 'historyErrors';
|
||||
public const REPOSITORY_ERRORS = 'repositoryErrors';
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ use Bitrix\Main\ArgumentException;
|
|||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Logger;
|
||||
|
||||
/**
|
||||
* Class CurrencyRepository
|
||||
|
@ -44,7 +46,7 @@ class CurrencyRepository extends AbstractRepository
|
|||
|
||||
return $currency['FORMAT_STRING'];
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
Logger::getInstance()->write($exception->getMessage(), Constants::REPOSITORY_ERRORS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ use Intaro\RetailCrm\Component\Json\Deserializer;
|
|||
use Intaro\RetailCrm\Component\Json\Serializer;
|
||||
use Intaro\RetailCrm\Model\Bitrix\OrderLoyaltyData;
|
||||
use Intaro\RetailCrm\Service\Utils;
|
||||
use Logger;
|
||||
|
||||
/**
|
||||
* Class OrderLoyaltyDataRepository
|
||||
|
@ -35,6 +36,11 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
*/
|
||||
private $dataManager;
|
||||
|
||||
/**
|
||||
* @var \Logger
|
||||
*/
|
||||
private $logger;
|
||||
|
||||
/**
|
||||
* OrderLoyaltyDataRepository constructor.
|
||||
* @throws \Bitrix\Main\LoaderException
|
||||
|
@ -42,6 +48,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->logger = Logger::getInstance();
|
||||
$this->dataManager = Utils::getHlClassByName(Constants::HL_LOYALTY_CODE);
|
||||
}
|
||||
|
||||
|
@ -68,7 +75,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
|
||||
return null;
|
||||
} catch (Exception $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
$this->logger->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -93,7 +100,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
/** @var OrderLoyaltyData $result */
|
||||
return Deserializer::deserializeArray($product, OrderLoyaltyData::class);
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
$this->logger->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +129,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
|
||||
return $result;
|
||||
} catch (SystemException | Exception $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
$this->logger->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +155,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
}
|
||||
|
||||
} catch (Exception $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
$this->logger->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -177,7 +184,7 @@ class OrderLoyaltyDataRepository extends AbstractRepository
|
|||
}
|
||||
|
||||
} catch (SystemException | Exception $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
$this->logger->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -22,6 +22,7 @@ use Intaro\RetailCrm\Component\Json\Deserializer;
|
|||
use Intaro\RetailCrm\Component\Json\Serializer;
|
||||
use Intaro\RetailCrm\Model\Bitrix\User;
|
||||
use Intaro\RetailCrm\Model\Bitrix\UserLoyaltyData;
|
||||
use Logger;
|
||||
|
||||
/**
|
||||
* Class UserRepository
|
||||
|
@ -55,7 +56,7 @@ class UserRepository extends AbstractRepository
|
|||
try {
|
||||
$loyaltyFields = UserLoyaltyDataRepository::getLoyaltyFields($fields['ID']);
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage());
|
||||
Logger::getInstance()->write($exception->getMessage());
|
||||
}
|
||||
|
||||
if (isset($loyaltyFields)) {
|
||||
|
|
|
@ -17,12 +17,14 @@ use Exception;
|
|||
use Intaro\RetailCrm\Component\Builder\Api\CustomerBuilder;
|
||||
use Intaro\RetailCrm\Component\Builder\Exception\BuilderException;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Intaro\RetailCrm\Component\Factory\ClientFactory;
|
||||
use Intaro\RetailCrm\Model\Api\Customer;
|
||||
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersCreateRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersEditRequest;
|
||||
use Intaro\RetailCrm\Model\Api\Request\Customers\CustomersGetRequest;
|
||||
use Intaro\RetailCrm\Repository\UserRepository;
|
||||
use Logger;
|
||||
|
||||
/**
|
||||
* Class CustomerService
|
||||
|
@ -145,9 +147,7 @@ class CustomerService
|
|||
*/
|
||||
public function createModel(int $userId)
|
||||
{
|
||||
$contragentsTypes = ConfigProvider::getContragentTypes();
|
||||
$key = array_search('individual', $contragentsTypes, true);
|
||||
|
||||
$key = array_search('individual', ConfigProvider::getContragentTypes(), true);
|
||||
$builder = new CustomerBuilder();
|
||||
|
||||
try {
|
||||
|
@ -159,7 +159,7 @@ class CustomerService
|
|||
->build()
|
||||
->getResult();
|
||||
}catch (BuilderException $exception){
|
||||
AddMessage2Log($exception->getMessage());
|
||||
Logger::getInstance()->write($exception->getMessage(), Constants::LOYALTY_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ class Utils
|
|||
|
||||
$msg = sprintf('%s (%s %s)', GetMessage('REGISTER_ERROR'), $response->errorMsg, $errorDetails);
|
||||
|
||||
AddMessage2Log($msg);
|
||||
Logger::getInstance()->write($msg);
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
|
|
@ -576,7 +576,10 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
OrderLoyaltyDataService::createLoyaltyHlBlock();
|
||||
}
|
||||
} catch (LoaderException | SystemException $e) {
|
||||
AddMessage2Log($e->getMessage());
|
||||
RCrmActions::eventLog(
|
||||
'intaro.retailcrm/options.php', 'OrderLoyaltyDataService::createLoyaltyHlBlock',
|
||||
$e->getCode() . ': ' . $e->getMessage()
|
||||
);
|
||||
}
|
||||
|
||||
ConfigProvider::setLoyaltyProgramStatus('Y');
|
||||
|
@ -844,6 +847,15 @@ if (isset($_POST['Update']) && ($_POST['Update'] === 'Y')) {
|
|||
?>
|
||||
<?php
|
||||
CJSCore::Init(array("jquery"));
|
||||
|
||||
try {
|
||||
Extension::load("ui.notification");
|
||||
} catch (LoaderException $exception) {
|
||||
RCrmActions::eventLog(
|
||||
'intaro.retailcrm/options.php', 'Extension::load',
|
||||
$e->getCode() . ': ' . $exception->getMessage()
|
||||
);
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue