34e8105583
* Loyalty program * fix dot bug for shops-exoprt option * delete credantials request from services * add CurlException for credentials catch * add catching CurlException * edit error msgs * add supportind double bonuses * add any step for bonus-input field in sale.order.ajax template * recalculate bonuses * fix bonus rounded * strtoupper for params in icml * change delivery service code
58 lines
1.5 KiB
PHP
58 lines
1.5 KiB
PHP
<?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 Intaro\RetailCrm\Component\Json\Deserializer;
|
|
use Intaro\RetailCrm\Model\Bitrix\UserLoyaltyData;
|
|
use Intaro\RetailCrm\Model\Bitrix\ORM\UtsUserTable;
|
|
|
|
/**
|
|
* Class UserLoyaltyDataRepository
|
|
*
|
|
* @package Intaro\RetailCrm\Repository
|
|
*/
|
|
class UserLoyaltyDataRepository extends AbstractRepository
|
|
{
|
|
/**
|
|
* @param int $userId
|
|
* @return \Intaro\RetailCrm\Model\Bitrix\UserLoyaltyData|null
|
|
* @throws \Bitrix\Main\ArgumentException
|
|
* @throws \Bitrix\Main\ObjectPropertyException
|
|
* @throws \Bitrix\Main\SystemException
|
|
*/
|
|
public static function getLoyaltyFields(int $userId): ?UserLoyaltyData
|
|
{
|
|
$loyaltyFields = UtsUserTable::query()
|
|
->setSelect([
|
|
'UF_CARD_NUM_INTARO',
|
|
'UF_LP_ID_INTARO',
|
|
'UF_AGREE_PL_INTARO',
|
|
'UF_PD_PROC_PL_INTARO',
|
|
'UF_EXT_REG_PL_INTARO',
|
|
'UF_REG_IN_PL_INTARO',
|
|
])
|
|
->where([['VALUE_ID', '=', $userId]])
|
|
->fetch();
|
|
|
|
if (!$loyaltyFields) {
|
|
return null;
|
|
}
|
|
|
|
/** @var UserLoyaltyData $loyalty */
|
|
$loyalty = Deserializer::deserializeArray($loyaltyFields, UserLoyaltyData::class);
|
|
|
|
return $loyalty;
|
|
}
|
|
}
|