Loyalty feature entities
This commit is contained in:
commit
b4841a871d
43 changed files with 1116 additions and 62 deletions
|
@ -4,7 +4,7 @@ RUN a2enmod rewrite
|
|||
|
||||
RUN set -xe \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends wget unzip imagemagick libpng-dev libjpeg-dev \
|
||||
&& apt-get install -y --no-install-recommends git wget unzip imagemagick libpng-dev libjpeg-dev \
|
||||
libfreetype6-dev default-mysql-client libmcrypt-dev libicu-dev libxml2 libxml2-dev libmagickwand-dev \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr --with-freetype-dir=/usr \
|
||||
|
|
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -1,3 +1,14 @@
|
|||
## 2020-08-26 v.5.4.4
|
||||
* Исправлена ошибка при установке модуля
|
||||
|
||||
## 2020-08-25 v.5.4.3
|
||||
* Исправлена ошибка с некорректным ID товара при редактировании заказа
|
||||
* Исправлены опечатки в API-клиенте retailCRM
|
||||
* Добавлена фильтрация изменений истории по текущему API-ключу
|
||||
|
||||
## 2020-07-24 v.5.4.2
|
||||
* Исправлена кодировка
|
||||
|
||||
## 2020-07-24 v.5.4.1
|
||||
* Оптимизирован генератор каталога
|
||||
* Передача статуса оплаты и статуса отгрузки заказа в Битрикс
|
||||
|
|
|
@ -36,6 +36,7 @@ for i in `find ./"$version" -type f -name '*.*'`; do
|
|||
echo $result
|
||||
exit 255
|
||||
fi
|
||||
mv $i.cp1251 $i
|
||||
fi
|
||||
done
|
||||
echo "Encoding the file has changed"
|
||||
|
|
|
@ -349,45 +349,6 @@ class ApiClient
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a customer corporate
|
||||
*
|
||||
* @param array $customer customer data
|
||||
* @param string $by (default: 'externalId')
|
||||
* @param string $site (default: null)
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \RetailCrm\Exception\CurlException
|
||||
* @throws \RetailCrm\Exception\InvalidJsonException
|
||||
*
|
||||
* @return ApiResponse
|
||||
*/
|
||||
public function customersСorporateEdit(array $customer, $by = 'externalId', $site = null)
|
||||
{
|
||||
if (!count($customer)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Parameter `customer` must contains a data'
|
||||
);
|
||||
}
|
||||
|
||||
$this->checkIdParameter($by);
|
||||
|
||||
if (!array_key_exists($by, $customer)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Customer array must contain the "%s" parameter.', $by)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->client->makeRequest(
|
||||
sprintf('/customers-corporate/%s/edit', $customer[$by]),
|
||||
Client::METHOD_POST,
|
||||
$this->fillSite(
|
||||
$site,
|
||||
array('customerCorporate' => json_encode($customer), 'by' => $by)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get customers corporate history
|
||||
*
|
||||
|
|
|
@ -447,10 +447,10 @@ class RCrmActions
|
|||
case 'ordersEdit':
|
||||
case 'customersGet':
|
||||
case 'customersEdit':
|
||||
case 'customersСorporateGet':
|
||||
case 'customersCorporateGet':
|
||||
return self::proxy($api, $methodApi, $method, array($params, 'externalId', $site));
|
||||
case 'customersСorporateGetById':
|
||||
return self::proxy($api, 'customersСorporateGet', $method, array($params, 'id', $site));
|
||||
case 'customersCorporateGetById':
|
||||
return self::proxy($api, 'customersCorporateGet', $method, array($params, 'id', $site));
|
||||
case 'customersGetById':
|
||||
return self::proxy($api, 'customersGet', $method, array($params, 'id', $site));
|
||||
|
||||
|
@ -487,7 +487,7 @@ class RCrmActions
|
|||
if ($result->getStatusCode() !== 200 && $result->getStatusCode() !== 201) {
|
||||
if ($methodApi == 'ordersGet'
|
||||
|| $methodApi == 'customersGet'
|
||||
|| $methodApi == 'customersСorporateGet'
|
||||
|| $methodApi == 'customersCorporateGet'
|
||||
) {
|
||||
Logger::getInstance()->write(array(
|
||||
'api' => $version,
|
||||
|
|
|
@ -1129,7 +1129,7 @@ class RetailCrmHistory
|
|||
}
|
||||
|
||||
if (isset($order['fullPaidAt']) && is_string($order['fullPaidAt'])) {
|
||||
$newOrder->setField('PAID', 'Y');
|
||||
$newOrder->setFieldNoDemand('PAYED', 'Y');
|
||||
}
|
||||
|
||||
if ($shipmentDeducted === 'Y') {
|
||||
|
@ -1256,6 +1256,7 @@ class RetailCrmHistory
|
|||
|
||||
public static function assemblyCustomer($customerHistory)
|
||||
{
|
||||
$customerHistory = self::filterHistory($customerHistory, 'customer');
|
||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||
$fields = array();
|
||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
||||
|
@ -1324,6 +1325,7 @@ class RetailCrmHistory
|
|||
|
||||
public static function assemblyOrder($orderHistory)
|
||||
{
|
||||
$orderHistory = self::filterHistory($orderHistory, 'order');
|
||||
$server = \Bitrix\Main\Context::getCurrent()->getServer()->getDocumentRoot();
|
||||
|
||||
if (file_exists($server . '/bitrix/modules/intaro.retailcrm/classes/general/config/objects.xml')) {
|
||||
|
@ -1469,7 +1471,76 @@ 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.
|
||||
* - All other changes will be merged as usual.
|
||||
* It fixes these problems:
|
||||
* - Changes from current API key are merged when it's not needed.
|
||||
* - Changes from CRM can overwrite more actual changes from CMS due to ignoring current API key changes.
|
||||
*
|
||||
* @param array $historyEntries Raw history from CRM
|
||||
* @param string $recordType Entity field name, e.g. `customer` or `order`.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function filterHistory($historyEntries, $recordType)
|
||||
{
|
||||
$history = [];
|
||||
$organizedHistory = [];
|
||||
$notOurChanges = [];
|
||||
|
||||
foreach ($historyEntries as $entry) {
|
||||
if (!isset($entry[$recordType]['externalId'])) {
|
||||
if ($entry['source'] == 'api'
|
||||
&& isset($change['apiKey']['current'])
|
||||
&& $entry['apiKey']['current'] == true
|
||||
&& $entry['field'] != 'externalId'
|
||||
) {
|
||||
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
|
||||
) {
|
||||
if (isset($notOurChanges[$externalId][$field]) || $entry['field'] == 'externalId') {
|
||||
$organizedHistory[$externalId][] = $entry;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$organizedHistory[$externalId][] = $entry;
|
||||
$notOurChanges[$externalId][$field] = true;
|
||||
}
|
||||
}
|
||||
|
||||
unset($notOurChanges);
|
||||
|
||||
foreach ($organizedHistory as $historyChunk) {
|
||||
$history = array_merge($history, $historyChunk);
|
||||
}
|
||||
|
||||
return $history;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update shipment in order
|
||||
*
|
||||
|
|
|
@ -161,6 +161,7 @@ class RetailCrmOrder
|
|||
|
||||
//basket
|
||||
foreach ($arFields['BASKET'] as $position => $product) {
|
||||
$itemId = null;
|
||||
$externalId = $position . "_" . $product['PRODUCT_ID'];
|
||||
|
||||
if (isset($orderItems[$externalId])) { //update
|
||||
|
|
|
@ -1,4 +1 @@
|
|||
- Оптимизирован генератор каталога
|
||||
- Передача статуса оплаты и статуса отгрузки заказа в Битрикс
|
||||
- Предупреждение в случае обнаружения несовместимых настроек
|
||||
- Запрещенные для редактирования поля в заказах с интеграционной доставкой более не передаются при редактировании заказа из Битрикс
|
||||
- Исправлена ошибка при установке модуля
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/intaro.retailcrm/lib/component/payment/retailcrmbonus/.description.php';
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
require_once($filePath);
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
$filePath = $_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/intaro.retailcrm/lib/component/payment/retailcrmbonus/handler.php';
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
require_once($filePath);
|
||||
}
|
|
@ -7,6 +7,17 @@
|
|||
*/
|
||||
global $MESS;
|
||||
|
||||
|
||||
use Bitrix\Main\ArgumentException;
|
||||
use Bitrix\Main\EventManager;
|
||||
use Bitrix\Main\Loader;
|
||||
use Bitrix\Main\ObjectPropertyException;
|
||||
use Bitrix\Main\SystemException;
|
||||
use Bitrix\Sale\Internals\OrderPropsGroupTable;
|
||||
use Bitrix\Sale\Internals\OrderPropsTable;
|
||||
use Bitrix\Sale\Internals\PaySystemActionTable;
|
||||
use Bitrix\Sale\Internals\PersonTypeTable;
|
||||
use Intaro\RetailCrm\Component\Constants;
|
||||
use Bitrix\Highloadblock\HighloadBlockTable;
|
||||
use Bitrix\Main\Application;
|
||||
use Bitrix\Main\Context;
|
||||
|
@ -15,6 +26,11 @@ use Bitrix\sale\EventActions;
|
|||
use Bitrix\Sale\Internals\OrderTable;
|
||||
use \RetailCrm\ApiClient;
|
||||
use RetailCrm\Exception\CurlException;
|
||||
use Intaro\RetailCrm\Component\Loyalty\EventsHandlers;
|
||||
use Intaro\RetailCrm\Repository\OrderPropsRepository;
|
||||
use Intaro\RetailCrm\Repository\PersonTypeRepository;
|
||||
use Intaro\RetailCrm\Repository\ToModuleRepository;
|
||||
|
||||
|
||||
IncludeModuleLangFile(__FILE__);
|
||||
if (class_exists('intaro_retailcrm')) {
|
||||
|
@ -23,6 +39,27 @@ if (class_exists('intaro_retailcrm')) {
|
|||
|
||||
class intaro_retailcrm extends CModule
|
||||
{
|
||||
|
||||
public const LP_ORDER_GROUP_NAME = 'Программа лояльности';
|
||||
public const BONUS_COUNT = 'Количество бонусов';
|
||||
public const BONUS_PAY_SYSTEM_NAME = 'Оплата бонусами';
|
||||
public const BONUS_PAY_SYSTEM_CODE = 'retailcrmbonus';
|
||||
public const BONUS_PAY_SYSTEM_DESCRIPTION = 'Оплата бонусами программы лояльности retailCRM';
|
||||
|
||||
/**
|
||||
* @var string[][]
|
||||
*/
|
||||
private const SUBSCRIBE_LP_EVENTS = [
|
||||
['EVENT_NAME' => 'OnBeforeSalePaymentSetField', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnBeforeEndBufferContent', 'FROM_MODULE' => 'main'],
|
||||
['EVENT_NAME' => 'OnSaleOrderBeforeSaved', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleOrderPaid', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleStatusOrderChange', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleOrderSaved', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleOrderCanceled', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleOrderDeleted', 'FROM_MODULE' => 'sale'],
|
||||
['EVENT_NAME' => 'OnSaleComponentOrderOneStepProcess', 'FROM_MODULE' => 'sale'],
|
||||
];
|
||||
public const V5 = 'v5';
|
||||
public $MODULE_ID = 'intaro.retailcrm';
|
||||
public $OLD_MODULE_ID = 'intaro.intarocrm';
|
||||
|
@ -135,6 +172,11 @@ class intaro_retailcrm extends CModule
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!Loader::includeModule('sale')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!date_default_timezone_get() && !ini_get('date.timezone')) {
|
||||
$APPLICATION->ThrowException(GetMessage("DATE_TIMEZONE_ERR"));
|
||||
|
||||
|
@ -151,6 +193,7 @@ class intaro_retailcrm extends CModule
|
|||
include($this->INSTALL_PATH . '/../classes/general/Exception/CurlException.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/RestNormalizer.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/Logger.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/services/RetailCrmService.php');
|
||||
$version = COption::GetOptionString($this->MODULE_ID, $this->CRM_API_VERSION, 0);
|
||||
include($this->INSTALL_PATH . '/../classes/general/ApiClient_v5.php');
|
||||
include($this->INSTALL_PATH . '/../classes/general/order/RetailCrmOrder_v5.php');
|
||||
|
@ -186,6 +229,27 @@ class intaro_retailcrm extends CModule
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/abstractmodelproxy.php');
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/orderprops.php');
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/tomodule.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/abstractrepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/orderpropsrepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/persontyperepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/repository/tomodulerepository.php');
|
||||
include($this->INSTALL_PATH . '/../lib/model/bitrix/orm/tomodule.php');
|
||||
|
||||
$this->CopyFiles();
|
||||
$this->addBonusPaySystem();
|
||||
$this->addLPUserFields();
|
||||
$this->addLPEvents();
|
||||
|
||||
try {
|
||||
$this->addLPOrderProps();
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($step == 11) {
|
||||
$arResult['arSites'] = RCrmActions::SitesList();
|
||||
if (count($arResult['arSites']) < 2) {
|
||||
|
@ -1218,6 +1282,7 @@ class intaro_retailcrm extends CModule
|
|||
RCrmActions::sendConfiguration($retail_crm_api, $api_version, false);
|
||||
|
||||
$this->DeleteFiles();
|
||||
$this->deleteLPEvents();
|
||||
|
||||
UnRegisterModule($this->MODULE_ID);
|
||||
|
||||
|
@ -1228,8 +1293,23 @@ class intaro_retailcrm extends CModule
|
|||
|
||||
public function CopyFiles(): void
|
||||
{
|
||||
$pathFrom = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install';
|
||||
|
||||
CopyDirFiles(
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/export/', $_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/', true, true
|
||||
$pathFrom . '/export',
|
||||
$_SERVER['DOCUMENT_ROOT'],
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
CopyDirFiles(
|
||||
$pathFrom
|
||||
. '/export_sale_payment',
|
||||
$_SERVER['DOCUMENT_ROOT']
|
||||
. COption::GetOptionString('sale', 'path2user_ps_files'),
|
||||
true,
|
||||
true,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1246,6 +1326,11 @@ class intaro_retailcrm extends CModule
|
|||
unlink($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/include/catalog_export/retailcrm_setup.php');
|
||||
unlink($defaultSite['ABS_DOC_ROOT'] . '/retailcrm/agent.php');
|
||||
rmdir($defaultSite['ABS_DOC_ROOT'] . '/retailcrm/');
|
||||
DeleteDirFilesEx(
|
||||
$_SERVER['DOCUMENT_ROOT']
|
||||
. COption::GetOptionString('sale', 'path2user_ps_files')
|
||||
. 'retailcrmbonus'
|
||||
);
|
||||
}
|
||||
|
||||
public function GetProfileSetupVars(
|
||||
|
@ -1397,4 +1482,235 @@ class intaro_retailcrm extends CModule
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add USER fields for LP
|
||||
*/
|
||||
public function addLPUserFields(): void
|
||||
{
|
||||
$this->addCustomUserFields(
|
||||
[
|
||||
"UF_REG_IN_PL_INTARO",
|
||||
"UF_AGREE_PL_INTARO",
|
||||
"UF_PD_PROC_PL_INTARO",
|
||||
"UF_EXT_REG_PL_INTARO",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* add LP Order Props
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public function addLPOrderProps(): void
|
||||
{
|
||||
$persons = PersonTypeRepository::getCollectionByWhere(['ID']);
|
||||
|
||||
foreach ($persons as $person) {
|
||||
$personId = $person->getID();
|
||||
$groupID = $this->getGroupID($personId);
|
||||
|
||||
if (isset($groupID)) {
|
||||
$this->addBonusField($personId, $groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fieldNames
|
||||
* @param string $filedType
|
||||
*/
|
||||
public function addCustomUserFields($fieldNames, $filedType = 'boolean'): void
|
||||
{
|
||||
foreach ($fieldNames as $filedName) {
|
||||
$arProps = [
|
||||
"ENTITY_ID" => 'USER',
|
||||
"FIELD_NAME" => $filedName,
|
||||
"USER_TYPE_ID" => $filedType,
|
||||
"MULTIPLE" => "N",
|
||||
"MANDATORY" => "N"
|
||||
];
|
||||
$obUserField = new CUserTypeEntity;
|
||||
$dbRes = CUserTypeEntity::GetList([], ["FIELD_NAME" => $filedName])->fetch();
|
||||
|
||||
if (!$dbRes['ID']) {
|
||||
$obUserField->Add($arProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $personId
|
||||
* @return \Bitrix\Main\ORM\Data\AddResult|mixed
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
private function getGroupID($personId)
|
||||
{
|
||||
$LPGroup = OrderPropsGroupTable::query()
|
||||
->setSelect(['ID'])
|
||||
->where(
|
||||
[
|
||||
['PERSON_TYPE_ID', '=', $personId],
|
||||
['NAME', '=', self::LP_ORDER_GROUP_NAME],
|
||||
]
|
||||
)
|
||||
->fetch();
|
||||
|
||||
if (is_array($LPGroup)) {
|
||||
return $LPGroup['ID'];
|
||||
}
|
||||
|
||||
if ($LPGroup === false) {
|
||||
$groupFields = [
|
||||
'PERSON_TYPE_ID' => $personId,
|
||||
'NAME' => self::LP_ORDER_GROUP_NAME,
|
||||
];
|
||||
$result = OrderPropsGroupTable::add($groupFields);
|
||||
|
||||
return $result->getId();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $personID
|
||||
* @param $groupID
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
private function addBonusField($personID, $groupID): void
|
||||
{
|
||||
$bonusProp = OrderPropsRepository::getFirstByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['PERSON_TYPE_ID', '=', $personID],
|
||||
['PROPS_GROUP_ID', '=', $groupID],
|
||||
]
|
||||
);
|
||||
|
||||
if ($bonusProp === null) {
|
||||
CSaleOrderProps::Add(
|
||||
[
|
||||
"REQUIRED" => "N",
|
||||
"NAME" => self::BONUS_COUNT,
|
||||
"TYPE" => "TEXT",
|
||||
"CODE" => "BONUS_RETAILCRM",
|
||||
"USER_PROPS" => "Y",
|
||||
"IS_LOCATION" => "N",
|
||||
"IS_LOCATION4TAX" => "N",
|
||||
"IS_EMAIL" => "N",
|
||||
"IS_PROFILE_NAME" => "N",
|
||||
"IS_PAYER" => "N",
|
||||
'IS_FILTERED' => 'Y',
|
||||
'PERSON_TYPE_ID' => $personID,
|
||||
'PROPS_GROUP_ID' => $groupID,
|
||||
"DEFAULT_VALUE" => 0,
|
||||
"DESCRIPTION" => self::BONUS_COUNT,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add bonus pay system
|
||||
*/
|
||||
private function addBonusPaySystem(): void
|
||||
{
|
||||
$arrPaySystemAction = PaySystemActionTable::query()
|
||||
->setSelect(['ID'])
|
||||
->where([
|
||||
['ACTION_FILE', '=', self::BONUS_PAY_SYSTEM_CODE],
|
||||
])
|
||||
->fetchCollection();
|
||||
|
||||
if (count($arrPaySystemAction) === 0) {
|
||||
$result = PaySystemActionTable::add(
|
||||
[
|
||||
'NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'PSA_NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'ACTION_FILE' => self::BONUS_PAY_SYSTEM_CODE,
|
||||
'DESCRIPTION' => self::BONUS_PAY_SYSTEM_DESCRIPTION,
|
||||
'RESULT_FILE' => '',
|
||||
'NEW_WINDOW' => 'N',
|
||||
'ENCODING' => 'utf-8',
|
||||
'ACTIVE' => 'Y',
|
||||
'HAVE_PAYMENT' => 'Y',
|
||||
'HAVE_ACTION' => 'N',
|
||||
'AUTO_CHANGE_1C' => 'N',
|
||||
'HAVE_RESULT' => 'N',
|
||||
'HAVE_PRICE' => 'N',
|
||||
'HAVE_PREPAY' => 'N',
|
||||
'HAVE_RESULT_RECEIVE' => 'N',
|
||||
'ALLOW_EDIT_PAYMENT' => 'Y',
|
||||
'IS_CASH' => 'N',
|
||||
'CAN_PRINT_CHECK' => 'N',
|
||||
'ENTITY_REGISTRY_TYPE' => 'ORDER',
|
||||
'XML_ID' => 'intaro_' . randString(15),
|
||||
]
|
||||
);
|
||||
$updateData = [
|
||||
'PAY_SYSTEM_ID' => $result->getId(),
|
||||
'PARAMS' => serialize(['BX_PAY_SYSTEM_ID' => $result->getId()]),
|
||||
];
|
||||
|
||||
PaySystemActionTable::update($result->getId(), $updateData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* create loyalty program events handlers
|
||||
*/
|
||||
private function addLPEvents(): void
|
||||
{
|
||||
$eventManager = EventManager::getInstance();
|
||||
|
||||
foreach (self::SUBSCRIBE_LP_EVENTS as $event){
|
||||
|
||||
try {
|
||||
$events = ToModuleRepository::getCollectionByWhere(
|
||||
['ID'],
|
||||
[
|
||||
['from_module_id', '=', $event['FROM_MODULE']],
|
||||
['to_module_id', '=', $this->MODULE_ID],
|
||||
['to_method', '=', $event['EVENT_NAME'] . 'Handler'],
|
||||
['to_class', '=', EventsHandlers::class],
|
||||
]
|
||||
);
|
||||
|
||||
if ($events !== null && count($events) === 0) {
|
||||
$eventManager->registerEventHandler(
|
||||
$event['FROM_MODULE'],
|
||||
$event['EVENT_NAME'],
|
||||
$this->MODULE_ID,
|
||||
EventsHandlers::class,
|
||||
$event['EVENT_NAME'] . 'Handler'
|
||||
);
|
||||
}
|
||||
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
|
||||
AddMessage2Log($exception->getMessage(), $this->MODULE_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete loyalty program events handlers
|
||||
*/
|
||||
private function deleteLPEvents(): void
|
||||
{
|
||||
$eventManager = EventManager::getInstance();
|
||||
|
||||
foreach (self::SUBSCRIBE_LP_EVENTS as $event){
|
||||
$eventManager->unRegisterEventHandler(
|
||||
$event['FROM_MODULE'],
|
||||
$event['EVENT_NAME'],
|
||||
$this->MODULE_ID,
|
||||
EventsHandlers::class,
|
||||
$event['EVENT_NAME'].'Handler'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?
|
||||
$arModuleVersion = array(
|
||||
"VERSION" => "5.4.1",
|
||||
"VERSION_DATE" => "2020-07-24 11:00:00"
|
||||
"VERSION" => "5.4.4",
|
||||
"VERSION_DATE" => "2020-08-26 10:50:00"
|
||||
);
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
<?php
|
||||
|
||||
$MESS ['API_MODULE_NAME'] = '1С-Битрикс';
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php
|
||||
|
||||
$MESS["NO_DELIVERY"] = "Без доставки";
|
||||
$MESS["PRICE_TYPE"] = "Цена retailCRM";
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php
|
||||
|
||||
$MESS["NO_DELIVERY"] = "Без доставки";
|
||||
$MESS["PRICE_TYPE"] = "Цена retailCRM";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS["ROOT_CATEGORY_FOR_CATALOG"] = "Корневой раздел для каталога \"%s\"";
|
||||
$MESS["PROPERTY_ARTICLE_HEADER_NAME"] = "Артикул";
|
||||
$MESS["PROPERTY_MANUFACTURER_HEADER_NAME"] = "Производитель";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS["YANDEX_DETAIL_TITLE"] = "Настройка дополнительных параметров";
|
||||
$MESS["YANDEX_ERR_NO_ACCESS_EXPORT"] = "Нет доступа к управлению экспортом";
|
||||
$MESS["YANDEX_ERR_NO_IBLOCK_CHOSEN"] = "Не выбран инфоблок";
|
||||
|
@ -106,4 +107,4 @@ $MESS["YANDEX_ERR_BAD_OFFERS_IBLOCK_ID"] = "Неверный ID инфоблок
|
|||
$MESS["YANDEX_ERR_SKU_SETTINGS_ABSENT"] = "Отсутствуют настройки экспорта торговых предложений";
|
||||
$MESS["YANDEX_ROOT_DIRECTORY"] = "Основной раздел каталога";
|
||||
$MESS["CET_ERROR_IBLOCK_PERM"] = "Недостаточно прав для работы с инфоблоком ##IBLOCK_ID#";
|
||||
$MESS["CES_ERROR_BAD_EXPORT_FILENAME"] = "Имя файла экспорта содержит запрещенные символы";
|
||||
$MESS["CES_ERROR_BAD_EXPORT_FILENAME"] = "Имя файла экспорта содержит запрещенные символы";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS["CET_ERROR_NO_NAME"] = "Введите название профиля выгрузки.";
|
||||
$MESS["CET_STEP1"] = "Шаг";
|
||||
$MESS["CET_STEP2"] = "из";
|
||||
|
@ -121,4 +122,4 @@ $MESS["CAT_ADM_CSV_EXP_DESCR_SECT_PROP"] = "Пользовательское с
|
|||
$MESS["CAT_ADM_CSV_EXP_SECTION_LEVEL"] = "Раздел уровня #LEVEL#";
|
||||
$MESS["CATI_FI_PRICE_TYPE2"] = "Цена типа \"#TYPE#\"";
|
||||
$MESS["CATI_FI_PRICE_TYPE3"] = "Цена типа \"#NAME#\" (#TYPE#)";
|
||||
$MESS["CATI_FI_PRICE_CURRENCY"] = "в валюте #CURRENCY#";
|
||||
$MESS["CATI_FI_PRICE_CURRENCY"] = "в валюте #CURRENCY#";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?
|
||||
|
||||
$MESS["ERROR_FILENAME_NOT_SET"] = "Не указан файл данных.";
|
||||
$MESS["ERROR_PROFIE_NOT_SET"] = "Не указано имя профиля";
|
||||
$MESS["EXPORT_CATALOGS"] = "Выберите каталоги для выгрузки в ICML:";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['RETAIL_MODULE_NAME'] = 'retailCRM';
|
||||
$MESS ['MODULE_DESCRIPTION'] = 'Модуль интеграции с retailCRM - специализированной CRM для e-commerce';
|
||||
$MESS ['MODULE_PARTNER_NAME'] = 'Интаро Софт';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 1';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['ICRM_API_HOST'] = 'Адрес retailCRM:';
|
||||
|
@ -13,4 +14,4 @@ $MESS ['ERR_METHOD_NOT_FOUND'] = 'Проверьте доступность ме
|
|||
//$MESS ['URL_NOT_FOUND'] = 'В настройках одного или нескольких сайтов не заполнено поле "URL сервера".';
|
||||
$MESS ['INFO_1'] = 'Введите адрес экземпляра retailCRM (например, https://demo.retailcrm.ru) и API-ключ.';
|
||||
$MESS ['INFO_2'] = 'API-ключ можно сгенерировать при регистрации магазина в retailCRM (Администрирование > Интеграция).';
|
||||
$MESS ['INFO_3'] = 'Код сайта в 1С-Битрикс должен совпадать с кодом сайта в retailCRM (Администрирование > Магазины).';
|
||||
$MESS ['INFO_3'] = 'Код сайта в 1С-Битрикс должен совпадать с кодом сайта в retailCRM (Администрирование > Магазины).';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 1. Сайты';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['ICRM_SITES'] = 'Активные сайты:';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 2';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
||||
|
@ -17,4 +18,4 @@ $MESS ['INFO_3'] = 'После этого подгрузите новые зна
|
|||
$MESS ['UPDATE_CATS'] = 'Обновить справочники';
|
||||
$MESS ['MESS_5'] = 'Произошла ошибка сервера, обратитесь в Интаро Софт.';
|
||||
$MESS ['DELIV_TYPES_EXPORT'] = 'Выгрузить список доставок из 1С-Битрикс';
|
||||
$MESS ['DELIV_TYPES_EXPORT_F'] = 'Настроить соответствие доставок 1С-Битрикс и retailCRM';
|
||||
$MESS ['DELIV_TYPES_EXPORT_F'] = 'Настроить соответствие доставок 1С-Битрикс и retailCRM';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 3';
|
||||
$MESS ['STOP'] = 'Приостановить выгрузку';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
|
@ -26,4 +27,4 @@ $MESS ['FLOOR'] = 'Этаж';
|
|||
$MESS ['BLOCK'] = 'Подъезд';
|
||||
$MESS ['HOUSE'] = 'Строение / корпус';
|
||||
$MESS ['ADDRESS_SHORT'] = 'Краткий адрес';
|
||||
$MESS ['ADDRESS_FULL'] = 'Детальный адрес';
|
||||
$MESS ['ADDRESS_FULL'] = 'Детальный адрес';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 4';
|
||||
$MESS ['MESS_1'] = 'На данном шаге вы можете выгрузить ранее оформленные заказы в retailCRM. Для запуска выгрузки нажмите кнопку «Начать выгрузку».';
|
||||
$MESS ['MESS_2'] = 'Экспорт...';
|
||||
|
@ -10,4 +11,4 @@ $MESS ['START_1'] = 'Начать выгрузку';
|
|||
$MESS ['START_2'] = 'Приостановить выгрузку';
|
||||
$MESS ['START_3'] = 'Возобновить выгрузку';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Следующий шаг';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['STEP_NAME'] = 'Шаг 5';
|
||||
$MESS ['MOD_NEXT_STEP'] = 'Завершить установку';
|
||||
$MESS ['MOD_PREV_STEP'] = 'Предыдущий шаг';
|
||||
|
@ -23,4 +24,4 @@ $MESS ['ERR_FIELDS_IBLOCK'] = 'Не выбрано ни одного инфор
|
|||
$MESS ['ERR_FIELDS_ARTICLE'] = 'Не выбраны артикулы';
|
||||
$MESS ['ERR_FIELDS_FILE'] = 'Не указано имя файла';
|
||||
$MESS ['BASE_PRICE'] = 'Базовая цена';
|
||||
$MESS ['WAIT'] = 'Загрузка...';
|
||||
$MESS ['WAIT'] = 'Загрузка...';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['INTAROCRM_INFO'] = '
|
||||
<h2>Дальнейшие действия</h2>
|
||||
<p>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?php
|
||||
|
||||
$MESS['MOD_UNINST_OK'] = 'Удаление модуля успешно завершено';
|
||||
$MESS['MOD_BACK'] = 'Вернуться в список';
|
||||
$MESS['MOD_BACK'] = 'Вернуться в список';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
$MESS ['ICRM_OPTIONS_GENERAL_TAB'] = 'Общие настройки';
|
||||
$MESS ['ICRM_OPTIONS_IMPORT_TAB'] = 'Настройки импорта';
|
||||
$MESS ['ICRM_OPTIONS_ORDER_PROPS_TAB'] = 'Cоответствия полей свойств заказа';
|
||||
|
|
|
@ -650,7 +650,7 @@ class ConfigProvider
|
|||
*/
|
||||
protected static function getUnserializedOption($option, $def = 0)
|
||||
{
|
||||
return unserialize(static::getOption($option, $def), null);
|
||||
return unserialize(static::getOption($option, $def));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
98
intaro.retailcrm/lib/component/loyalty/eventshandlers.php
Normal file
98
intaro.retailcrm/lib/component/loyalty/eventshandlers.php
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Component\Loyalty
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
|
||||
namespace Intaro\RetailCrm\Component\Loyalty;
|
||||
|
||||
use Bitrix\Main\Event;
|
||||
|
||||
/**
|
||||
* Class EventsHandlers
|
||||
* @package Intaro\RetailCrm\Component\Loyalty
|
||||
*/
|
||||
class EventsHandlers
|
||||
{
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnBeforeSalePaymentSetFieldHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnBeforeSalePaymentSetFieldHandler work! ' . $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function OnBeforeEndBufferContentHandler()
|
||||
{
|
||||
AddMessage2Log('OnBeforeEndBufferContentHandler work! ');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleOrderBeforeSavedHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleOrderBeforeSavedHandler work! ' . $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleOrderPaidHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleOrderPaidHandler work! '. $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleStatusOrderChangeHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleStatusOrderChangeHandler work! '. $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleOrderSavedHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleOrderSavedHandler work! '. $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleOrderCanceledHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleOrderCanceledHandler work! '. $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\Event $event
|
||||
*/
|
||||
public function OnSaleOrderDeletedHandler(Event $event): void
|
||||
{
|
||||
AddMessage2Log('OnSaleOrderDeletedHandler work! '. $event->getDebugInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $arResult
|
||||
* @param $arUserResult
|
||||
* @param $arParams
|
||||
* @return mixed
|
||||
*/
|
||||
public function OnSaleComponentOrderOneStepProcessHandler($arResult, $arUserResult, $arParams)
|
||||
{
|
||||
AddMessage2Log('OnSaleComponentOrderOneStepProcessHandler work! '. $arUserResult. $arParams);
|
||||
return $arResult;
|
||||
}
|
||||
}
|
14
intaro.retailcrm/lib/component/payment/retailcrmbonus/.description.php
Executable file
14
intaro.retailcrm/lib/component/payment/retailcrmbonus/.description.php
Executable file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
|
||||
die();
|
||||
}
|
||||
|
||||
use \Bitrix\Main\Localization\Loc;
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
|
||||
$data = [
|
||||
'NAME' => Loc::getMessage("SALE_HPS_BONUS"),
|
||||
'SORT' => 100,
|
||||
'CODES' => [],
|
||||
];
|
35
intaro.retailcrm/lib/component/payment/retailcrmbonus/handler.php
Executable file
35
intaro.retailcrm/lib/component/payment/retailcrmbonus/handler.php
Executable file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Intaro\RetailCrm\Component\Payment\RetailCrmBonus;
|
||||
|
||||
use Bitrix\Main\Localization\Loc;
|
||||
use Bitrix\Main\Request;
|
||||
use Bitrix\Sale\PaySystem;
|
||||
use Bitrix\Sale\Payment;
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
|
||||
/**
|
||||
* Class RetailCrmBonusHandler
|
||||
* @package Sale\Handlers\PaySystem
|
||||
*/
|
||||
class RetailCrmBonusHandler extends PaySystem\BaseServiceHandler
|
||||
{
|
||||
/**
|
||||
* @param Payment $payment
|
||||
* @param Request|null $request
|
||||
* @return PaySystem\ServiceResult
|
||||
*/
|
||||
public function initiatePay(Payment $payment, Request $request = null)
|
||||
{
|
||||
return new PaySystem\ServiceResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCurrencyList()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
$MESS["SALE_HPS_BONUS"] = "retailCRM bonus account";
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
$MESS["SALE_HPS_BONUS"] = "бонусный счет retailCRM";
|
95
intaro.retailcrm/lib/model/bitrix/orderprops.php
Normal file
95
intaro.retailcrm/lib/model/bitrix/orderprops.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Bitrix;
|
||||
|
||||
use Bitrix\Main\ORM\Objectify\EntityObject;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
use Bitrix\Sale\FuserTable;
|
||||
use Bitrix\Sale\Internals\OrderPropsTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ORM\ToModuleTable;
|
||||
|
||||
/**
|
||||
* Class OrderProps
|
||||
*
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
*
|
||||
* @method int getId()
|
||||
* @method void setId(int $id)
|
||||
* @method int getPersonTypeId()
|
||||
* @method void setPersonTypeId(int $personTypeId)
|
||||
* @method string getName()
|
||||
* @method void setName(string $name)
|
||||
* @method string getType()
|
||||
* @method void setType(string $type)
|
||||
* @method bool getRequired()
|
||||
* @method void setRequired(bool $required)
|
||||
* @method string getDefaultValue()
|
||||
* @method void setDefaultValue(string $defaultValue)
|
||||
* @method int getSort()
|
||||
* @method void setSort(int $sort)
|
||||
* @method bool getUserProps()
|
||||
* @method void setUserProps(bool $userProps)
|
||||
* @method bool getIsLocation()
|
||||
* @method void setIsLocation(bool $isLocation)
|
||||
* @method int getPropsGroupId()
|
||||
* @method void setPropsGroupId(int $propsGroupId)
|
||||
* @method string getDescription()
|
||||
* @method void setDescription(string $description)
|
||||
* @method bool getIsEmail()
|
||||
* @method void setIsEmail(bool $isEmail)
|
||||
* @method bool getIsProfileName()
|
||||
* @method void setIsProfileName(bool $isProfileName)
|
||||
* @method bool getIsPayer()
|
||||
* @method void setIsPayer(bool $isPayer)
|
||||
* @method bool getIsLocation4tax()
|
||||
* @method void setIsLocation4tax(bool $isLocation4tax)
|
||||
* @method bool getIsFiltered()
|
||||
* @method void setIsFiltered(bool $isFiltered)
|
||||
* @method string getCode()
|
||||
* @method void setCode(string $code)
|
||||
* @method bool getIsZip()
|
||||
* @method void setIsZip(bool $isZip)
|
||||
* @method bool getIsPhone()
|
||||
* @method void setIsPhone(bool $isPhone)
|
||||
* @method bool getIsAddress()
|
||||
* @method void setIsAddress(bool $isAddress)
|
||||
* @method bool getActive()
|
||||
* @method void setActive(bool $active)
|
||||
* @method bool getUtil()
|
||||
* @method void setUtil(bool $util)
|
||||
* @method int getInputFieldLocation()
|
||||
* @method void setInputFieldLocation(int $inputFieldLocation)
|
||||
* @method bool getMultiple()
|
||||
* @method void setMultiple(bool $multiple)
|
||||
* @method string getSettings()
|
||||
* @method void setSettings(string $settings)
|
||||
* @method mixed getGroup()
|
||||
* @method void setGroup($group)
|
||||
* @method mixed getPersonType()
|
||||
* @method void setPersonType($personType)
|
||||
* @method string getEntityRegistryType()
|
||||
* @method void setEntityRegistryType(string $entityRegistryType)
|
||||
* @method string getXmlId()
|
||||
* @method void setXmlId(string $xmlId)
|
||||
*/
|
||||
class OrderProps extends AbstractModelProxy
|
||||
{
|
||||
/**
|
||||
* @return \Bitrix\Main\ORM\Objectify\EntityObject|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
protected static function newObject(): ?EntityObject
|
||||
{
|
||||
return OrderPropsTable::createObject();
|
||||
}
|
||||
}
|
199
intaro.retailcrm/lib/model/bitrix/orm/tomodule.php
Normal file
199
intaro.retailcrm/lib/model/bitrix/orm/tomodule.php
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
namespace Intaro\RetailCrm\Model\Bitrix\ORM;
|
||||
|
||||
use Bitrix\Main,
|
||||
Bitrix\Main\Localization\Loc;
|
||||
use Bitrix\Main\ORM\Fields\IntegerField;
|
||||
use Bitrix\Main\ORM\Fields\DatetimeField;
|
||||
use Bitrix\Main\ORM\Fields\StringField;
|
||||
|
||||
Loc::loadMessages(__FILE__);
|
||||
|
||||
/**
|
||||
* Class ToModuleTable
|
||||
*
|
||||
* Fields:
|
||||
* <ul>
|
||||
* <li> ID int mandatory
|
||||
* <li> TIMESTAMP_X datetime mandatory default 'CURRENT_TIMESTAMP'
|
||||
* <li> SORT int optional default 100
|
||||
* <li> FROM_MODULE_ID string(50) mandatory
|
||||
* <li> MESSAGE_ID string(255) mandatory
|
||||
* <li> TO_MODULE_ID string(50) mandatory
|
||||
* <li> TO_PATH string(255) optional
|
||||
* <li> TO_CLASS string(255) optional
|
||||
* <li> TO_METHOD string(255) optional
|
||||
* <li> TO_METHOD_ARG string(255) optional
|
||||
* <li> VERSION int optional
|
||||
* <li> UNIQUE_ID string(32) mandatory
|
||||
* </ul>
|
||||
*
|
||||
* @package Bitrix\Module
|
||||
**/
|
||||
class ToModuleTable extends Main\Entity\DataManager
|
||||
{
|
||||
/**
|
||||
* Returns DB table name for entity.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getTableName()
|
||||
{
|
||||
return 'b_module_to_module';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity map definition.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getMap()
|
||||
{
|
||||
return [
|
||||
new IntegerField(
|
||||
'id',
|
||||
['primary' => true, 'autocomplete' => true]),
|
||||
new DatetimeField('TIMESTAMP_X', ['required' => true]),
|
||||
new IntegerField('sort'),
|
||||
new StringField(
|
||||
'from_module_id',
|
||||
['required' => true, 'validation' => [__CLASS__, 'validateFromModuleId']]
|
||||
),
|
||||
new StringField(
|
||||
'message_id',
|
||||
['required' => true, 'validation' => [__CLASS__, 'validateMessageId']]
|
||||
),
|
||||
new StringField(
|
||||
'to_module_id',
|
||||
['required' => true, 'validation' => [__CLASS__, 'validateToModuleId']]
|
||||
),
|
||||
new StringField(
|
||||
'to_path',
|
||||
['validation' => [__CLASS__, 'validateToPath']]
|
||||
),
|
||||
new StringField(
|
||||
'to_class',
|
||||
['validation' => [__CLASS__, 'validateToClass']]
|
||||
),
|
||||
new StringField(
|
||||
'to_method',
|
||||
['validation' => [__CLASS__, 'validateToMethod']]
|
||||
),
|
||||
new StringField(
|
||||
'to_method_arg',
|
||||
['validation' => [__CLASS__, 'validateToMethodArg']]
|
||||
),
|
||||
new IntegerField('version'),
|
||||
new StringField(
|
||||
'unique_id',
|
||||
['required' => true, 'validation' => [__CLASS__, 'validateUniqueId']]
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for FROM_MODULE_ID field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateFromModuleId()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 50),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for MESSAGE_ID field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateMessageId()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 255),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for TO_MODULE_ID field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateToModuleId()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 50),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for TO_PATH field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateToPath()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 255),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for TO_CLASS field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateToClass()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 255),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for TO_METHOD field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateToMethod()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 255),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for TO_METHOD_ARG field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateToMethodArg()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 255),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns validators for UNIQUE_ID field.
|
||||
*
|
||||
* @return array
|
||||
* @throws \Bitrix\Main\ArgumentTypeException
|
||||
*/
|
||||
public static function validateUniqueId()
|
||||
{
|
||||
return [
|
||||
new Main\Entity\Validator\Length(null, 32),
|
||||
];
|
||||
}
|
||||
}
|
60
intaro.retailcrm/lib/model/bitrix/tomodule.php
Normal file
60
intaro.retailcrm/lib/model/bitrix/tomodule.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Model\Bitrix;
|
||||
|
||||
use Bitrix\Main\ORM\Objectify\EntityObject;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
use Bitrix\Sale\FuserTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ORM\ToModuleTable;
|
||||
|
||||
/**
|
||||
* Class ToModule
|
||||
*
|
||||
* @package Intaro\RetailCrm\Model\Bitrix
|
||||
*
|
||||
* @method int getId()
|
||||
* @method void setId(int $id)
|
||||
* @method DateTime getTimestampX()
|
||||
* @method void setTimestampX(DateTime $timestampX)
|
||||
* @method int getSort()
|
||||
* @method void setSort(int $sort)
|
||||
* @method string getFromModuleId()
|
||||
* @method void setFromModuleId(string $fromModuleId)
|
||||
* @method string getMessageId()
|
||||
* @method void setMessageId(string $messageId)
|
||||
* @method string getToModuleId()
|
||||
* @method void setToModuleId(string $toModuleId)
|
||||
* @method string getToPath()
|
||||
* @method void setToPath(string $toPath)
|
||||
* @method string getToClass()
|
||||
* @method void setToClass(string $toClass)
|
||||
* @method string getToMethod()
|
||||
* @method void setToMethod(string $toMethod)
|
||||
* @method string getToMethodArg()
|
||||
* @method void setToMethodArg(string $toMethodArg)
|
||||
* @method int getVersion()
|
||||
* @method void setVersion(int $version)
|
||||
* @method string getUniqueId()
|
||||
* @method void setUniqueId(string $uniqueId)
|
||||
*/
|
||||
class ToModule extends AbstractModelProxy
|
||||
{
|
||||
/**
|
||||
* @return \Bitrix\Main\ORM\Objectify\EntityObject|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
protected static function newObject(): ?EntityObject
|
||||
{
|
||||
return ToModuleTable::createObject();
|
||||
}
|
||||
}
|
67
intaro.retailcrm/lib/repository/orderpropsrepository.php
Normal file
67
intaro.retailcrm/lib/repository/orderpropsrepository.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Repository;
|
||||
|
||||
use Bitrix\Sale\Internals\OrderPropsTable;
|
||||
use Bitrix\Main\ORM\Objectify\EntityObject;
|
||||
use Intaro\RetailCrm\Model\Bitrix\OrderProps;
|
||||
|
||||
|
||||
/**
|
||||
* Class OrderPropsRepository
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
*/
|
||||
class OrderPropsRepository extends AbstractRepository
|
||||
{
|
||||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\OrderProps|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getFirstByWhere(array $select, array $where): ?OrderProps
|
||||
{
|
||||
return static::getWrapped(OrderPropsTable::query()
|
||||
->setSelect($select)
|
||||
->where($where)
|
||||
->fetchObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return OrderProps|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getById(int $id): ?OrderProps
|
||||
{
|
||||
return static::getWrapped(OrderPropsTable::getByPrimary($id)->fetchObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Bitrix\Main\ORM\Objectify\EntityObject|null $entityObject
|
||||
*
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\Fuser|null
|
||||
*/
|
||||
private static function getWrapped(?EntityObject $entityObject): ?OrderProps
|
||||
{
|
||||
if (null === $entityObject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new OrderProps($entityObject);
|
||||
}
|
||||
}
|
39
intaro.retailcrm/lib/repository/persontyperepository.php
Normal file
39
intaro.retailcrm/lib/repository/persontyperepository.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Repository;
|
||||
|
||||
use Bitrix\Main\Type\Collection;
|
||||
use Bitrix\Sale\Internals\PersonTypeTable;
|
||||
|
||||
/**
|
||||
* Class PersonTypeRepository
|
||||
*
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
*/
|
||||
class PersonTypeRepository extends AbstractRepository
|
||||
{
|
||||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Bitrix\Main\Type\Collection|null|Bitrix\Sale\Internals\EO_PersonType_Collection
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getCollectionByWhere(array $select = ['*'], array $where = [])
|
||||
{
|
||||
return PersonTypeTable::query()
|
||||
->setSelect($select)
|
||||
->where($where)
|
||||
->fetchCollection();
|
||||
}
|
||||
}
|
56
intaro.retailcrm/lib/repository/tomodulerepository.php
Normal file
56
intaro.retailcrm/lib/repository/tomodulerepository.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* PHP version 7.1
|
||||
*
|
||||
* @category Integration
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license MIT
|
||||
* @link http://retailcrm.ru
|
||||
* @see http://retailcrm.ru/docs
|
||||
*/
|
||||
namespace Intaro\RetailCrm\Repository;
|
||||
|
||||
use Bitrix\Main\Type\Collection;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ORM\ToModuleTable;
|
||||
use Intaro\RetailCrm\Model\Bitrix\ToModule;
|
||||
|
||||
/**
|
||||
* Class ToModuleRepository
|
||||
*
|
||||
* @package Intaro\RetailCrm\Repository
|
||||
*/
|
||||
class ToModuleRepository extends AbstractRepository
|
||||
{
|
||||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\ToModule|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getFirstByWhere(array $select, array $where): ?ToModule
|
||||
{
|
||||
return ToModuleTable::query()
|
||||
->setSelect($select)
|
||||
->where($where)
|
||||
->fetchObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Bitrix\Main\Type\Collection|Intaro\RetailCrm\Model\Bitrix\ORM\EO_ToModule_Collection|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
* @throws \Bitrix\Main\SystemException
|
||||
*/
|
||||
public static function getCollectionByWhere(array $select, array $where)
|
||||
{
|
||||
return ToModuleTable::query()
|
||||
->setSelect($select)
|
||||
->where($where)
|
||||
->fetchCollection();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue