Loyalty feature installer (#118)
* fixes for crash during the installation * add LP activate option
This commit is contained in:
parent
3f6f1bfe3f
commit
f528a0a90e
14 changed files with 1426 additions and 1097 deletions
11
intaro.retailcrm/.settings.php
Normal file
11
intaro.retailcrm/.settings.php
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
return [
|
||||
'controllers' => [
|
||||
'value' => [
|
||||
'namespaces' => [
|
||||
'\\Intaro\\RetailCrm\\Controller' => 'api'
|
||||
],
|
||||
],
|
||||
'readonly' => true,
|
||||
]
|
||||
];
|
|
@ -1,5 +1,12 @@
|
|||
<?php
|
||||
|
||||
use Intaro\RetailCrm\Component\ServiceLocator;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/servicelocator.php';
|
||||
require_once __DIR__ . '/../../lib/service/utils.php';
|
||||
|
||||
class RCrmActions
|
||||
{
|
||||
public static $MODULE_ID = 'intaro.retailcrm';
|
||||
|
@ -227,7 +234,7 @@ class RCrmActions
|
|||
public static function clearArr($arr)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->clearArray($arr);
|
||||
}
|
||||
|
||||
|
@ -240,7 +247,7 @@ class RCrmActions
|
|||
public static function toJSON($str)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::getOrCreate(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->toUTF8($str);
|
||||
}
|
||||
|
||||
|
@ -253,7 +260,7 @@ class RCrmActions
|
|||
public static function fromJSON($str)
|
||||
{
|
||||
/** @var \Intaro\RetailCrm\Service\Utils $utils */
|
||||
$utils = \Intaro\RetailCrm\Component\ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
$utils = ServiceLocator::get(\Intaro\RetailCrm\Service\Utils::class);
|
||||
return $utils->fromUTF8($str);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/configprovider.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
@ -25,6 +29,6 @@ IncludeModuleLangFile(__FILE__);
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
class RetailcrmConfigProvider extends \Intaro\RetailCrm\Component\ConfigProvider
|
||||
class RetailcrmConfigProvider extends ConfigProvider
|
||||
{
|
||||
}
|
||||
|
|
|
@ -12,8 +12,12 @@
|
|||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/constants.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
@ -25,6 +29,6 @@ IncludeModuleLangFile(__FILE__);
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion4
|
||||
*/
|
||||
class RetailcrmConstants extends \Intaro\RetailCrm\Component\Constants
|
||||
class RetailcrmConstants extends Constants
|
||||
{
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
|
||||
require_once __DIR__ . '/../../lib/component/dependencyloader.php';
|
||||
|
||||
/**
|
||||
* PHP version 5.3
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -68,6 +68,8 @@ $MESS ['MESS_2'] = 'Произошла ошибка сервера, обрати
|
|||
$MESS ['ORDER_TYPES_LIST_CUSTOM'] = 'Внимание! Используется не стандартное соответвие типов заказов.';
|
||||
$MESS ['ORDER_UPL_START'] = 'Начать выгрузку';
|
||||
|
||||
$MESS ['LOYALTY_PROGRAM_TITLE'] = 'Программа лояльности';
|
||||
$MESS ['LOYALTY_PROGRAM_TOGGLE_MSG'] = 'Включить программу лояльности';
|
||||
$MESS ['OTHER_OPTIONS'] = 'Прочие настройки';
|
||||
$MESS ['ORDERS_OPTIONS'] = 'Настройки заказов';
|
||||
$MESS ['ORDER_NUMBERS'] = 'Транслировать номера заказов созданных в црм в магазин';
|
||||
|
|
|
@ -156,7 +156,8 @@ trait CustomersTrait
|
|||
*
|
||||
* @return CustomerChangeResponse|null
|
||||
*/
|
||||
public function customersEdit(CustomersEditRequest $request): ?CustomerChangeResponse {
|
||||
public function customersEdit(CustomersEditRequest $request): ?CustomerChangeResponse
|
||||
{
|
||||
$serialized = Serializer::serializeArray($request);
|
||||
$response = $this->client->customersEdit($serialized['customer'], $request->by, $request->site);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*/
|
||||
namespace Intaro\RetailCrm\Component;
|
||||
|
||||
use Bitrix\Currency\CurrencyManager;
|
||||
use Bitrix\Main\ArgumentNullException;
|
||||
use Bitrix\Main\ArgumentOutOfRangeException;
|
||||
use Bitrix\Main\Config\Option;
|
||||
|
@ -99,7 +100,10 @@ class ConfigProvider
|
|||
|
||||
/** @var array $integrationDeliveriesMapping */
|
||||
protected static $integrationDeliveriesMapping;
|
||||
|
||||
|
||||
/** @var bool|null|string $loyaltyProgramStatus */
|
||||
protected static $loyaltyProgramStatus;
|
||||
|
||||
/**
|
||||
* @return bool|string|null
|
||||
*/
|
||||
|
@ -500,7 +504,7 @@ class ConfigProvider
|
|||
*/
|
||||
public static function getCurrencyOrDefault()
|
||||
{
|
||||
return self::getCurrency() ? self::getCurrency() : \Bitrix\Currency\CurrencyManager::getBaseCurrency();
|
||||
return self::getCurrency() ?: CurrencyManager::getBaseCurrency();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -660,4 +664,21 @@ class ConfigProvider
|
|||
{
|
||||
return empty($value) && $value !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool|string|null
|
||||
*/
|
||||
public static function getLoyaltyProgramStatus()
|
||||
{
|
||||
return static::getOption(Constants::LOYALTY_PROGRAM_TOGGLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool|string|null $loyaltyProgramStatus
|
||||
* @throws \Bitrix\Main\ArgumentOutOfRangeException
|
||||
*/
|
||||
public static function setLoyaltyProgramStatus($loyaltyProgramStatus): void
|
||||
{
|
||||
static::setOption(Constants::LOYALTY_PROGRAM_TOGGLE, $loyaltyProgramStatus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,5 @@ class Constants
|
|||
public const CRM_INTEGRATION_DELIVERY = 'integration_delivery';
|
||||
public const CRM_SHIPMENT_DEDUCTED = 'shipment_deducted';
|
||||
public const CORPORATE_CONTRAGENT_TYPE = 'legal-entity';
|
||||
public const LOYALTY_PROGRAM_TOGGLE = 'loyalty_program_toggle';
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
*/
|
||||
namespace Intaro\RetailCrm\Component;
|
||||
|
||||
use CModule;
|
||||
use RCrmActions;
|
||||
|
||||
/**
|
||||
* Class DependencyLoader
|
||||
*
|
||||
|
|
|
@ -85,7 +85,27 @@ class ServiceLocator
|
|||
{
|
||||
return static::$services[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create service (instantiates service if it wasn't created earlier; $name must be FQN).
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getOrCreate(string $name)
|
||||
{
|
||||
$service = static::$services[$name];
|
||||
|
||||
if (null === $service) {
|
||||
static::$services[$name] = new $name();
|
||||
return static::$services[$name];
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets service into ServiceContainer.
|
||||
*
|
||||
|
|
34
intaro.retailcrm/lib/controller/adminpanel.php
Normal file
34
intaro.retailcrm/lib/controller/adminpanel.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Intaro\RetailCrm\Controller;
|
||||
|
||||
use Bitrix\Main\Engine\ActionFilter\Authentication;
|
||||
use Bitrix\Main\Engine\Controller;
|
||||
use Intaro\RetailCrm\Component\ConfigProvider;
|
||||
|
||||
class AdminPanel extends Controller
|
||||
{
|
||||
public function configureActions(): array
|
||||
{
|
||||
return [
|
||||
'loyaltyProgramToggle' => [
|
||||
'-prefilters' => [
|
||||
Authentication::class,
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* @throws \Bitrix\Main\ArgumentOutOfRangeException
|
||||
*/
|
||||
public function LoyaltyProgramToggleAction(): array
|
||||
{
|
||||
$status = ConfigProvider::getLoyaltyProgramStatus();
|
||||
$newStatus = $status === 'N' || $status === null ? 'Y' : 'N';
|
||||
ConfigProvider::setLoyaltyProgramStatus($newStatus);
|
||||
|
||||
return ['newStatus' => $newStatus];
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue