Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
price.php
1
<?php
2
3
namespace
Bitrix\Sale\Services\PaySystem\Restrictions
;
4
5
use
Bitrix\Main\ArgumentTypeException
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Sale\Internals\Entity
;
8
use
Bitrix\Sale\Order
;
9
use
Bitrix\Sale\PaymentCollection
;
10
use
Bitrix\Sale\Services\Base
;
11
use
Bitrix\Sale\Payment
;
12
13
Loc::loadMessages
(__FILE__);
14
15
class
Price
extends
Base\Restriction
16
{
23
public
static
function
check
($params, array $restrictionParams, $serviceId = 0)
24
{
25
$maxValue = static::getPrice($params, $restrictionParams[
'MAX_VALUE'
]);
26
$minValue = static::getPrice($params, $restrictionParams[
'MIN_VALUE'
]);
27
$price = (float)$params[
'PRICE_PAYMENT'
];
28
29
if
($maxValue > 0 && $minValue > 0)
30
{
31
return
($maxValue >= $price) && ($minValue <= $price);
32
}
33
34
if
($maxValue > 0)
35
{
36
return
$maxValue >= $price;
37
}
38
39
if
($minValue >= 0)
40
{
41
return
$minValue <= $price;
42
}
43
44
return
false
;
45
}
46
51
protected
static
function
extractParams(
Entity
$entity)
52
{
53
$orderPrice =
null
;
54
$paymentPrice =
null
;
55
56
if
($entity instanceof
Payment
)
57
{
59
$collection = $entity->getCollection();
61
$order = $collection->getOrder();
62
63
$orderPrice = $order->getPrice();
64
$paymentPrice = $entity->
getField
(
'SUM'
);
65
}
66
67
return
array(
68
'PRICE_PAYMENT'
=> $paymentPrice,
69
'PRICE_ORDER'
=> $orderPrice,
70
);
71
}
72
78
protected
static
function
getPrice
($entityParams, $paramValue)
79
{
80
return
(
float
)$paramValue;
81
}
82
86
public
static
function
getClassTitle
()
87
{
88
return
Loc::getMessage
(
'SALE_PS_RESTRICTIONS_BY_PRICE'
);
89
}
90
94
public
static
function
getClassDescription
()
95
{
96
return
Loc::getMessage
(
'SALE_PS_RESTRICTIONS_BY_PRICE_DESC'
);
97
}
98
99
public
static
function
getOnApplyErrorMessage
(): string
100
{
101
return
Loc::getMessage
(
'SALE_PS_RESTRICTIONS_BY_PRICE_ON_APPLY_ERROR_MSG'
);
102
}
103
109
public
static
function
getParamsStructure
($entityId = 0)
110
{
111
return
array(
112
"MIN_VALUE"
=> array(
113
'TYPE'
=>
'NUMBER'
,
114
'DEFAULT'
=> 0,
115
'LABEL'
=>
Loc::getMessage
(
"SALE_PS_RESTRICTIONS_BY_PRICE_TYPE_MORE"
)
116
),
117
"MAX_VALUE"
=> array(
118
'TYPE'
=>
'NUMBER'
,
119
'DEFAULT'
=> 0,
120
'LABEL'
=>
Loc::getMessage
(
"SALE_PS_RESTRICTIONS_BY_PRICE_TYPE_LESS"
)
121
)
122
);
123
}
124
131
public
static
function
getRange
(
Payment
$payment, $params)
132
{
133
if
($payment instanceof
Payment
)
134
{
135
$p = static::extractParams($payment);
136
return
array(
137
'MAX'
=> static::getPrice($p, $params[
'MAX_VALUE'
]),
138
'MIN'
=> static::getPrice($p, $params[
'MIN_VALUE'
]),
139
);
140
}
141
142
throw
new
ArgumentTypeException
(
''
);
143
}
144
149
public
static
function
getSeverity
($mode)
150
{
151
return
Manager::SEVERITY_SOFT;
152
}
153
}
Bitrix\Catalog\Model\Entity
Definition
entity.php:12
Bitrix\Main\ArgumentTypeException
Definition
exception.php:114
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Entity\getField
getField($name)
Definition
entity.php:567
Bitrix\Sale\Helpers\Order
Definition
order.php:10
Bitrix\Sale\PaymentCollection
Definition
paymentcollection.php:18
Bitrix\Sale\Payment
Definition
payment.php:19
Bitrix\Sale\Services\PaySystem\Restrictions\Price
Definition
price.php:16
Bitrix\Sale\Services\PaySystem\Restrictions\Price\check
static check($params, array $restrictionParams, $serviceId=0)
Definition
price.php:23
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getClassTitle
static getClassTitle()
Definition
price.php:86
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getClassDescription
static getClassDescription()
Definition
price.php:94
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getPrice
static getPrice($entityParams, $paramValue)
Definition
price.php:78
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getOnApplyErrorMessage
static getOnApplyErrorMessage()
Definition
price.php:99
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getRange
static getRange(Payment $payment, $params)
Definition
price.php:131
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getParamsStructure
static getParamsStructure($entityId=0)
Definition
price.php:109
Bitrix\Sale\Services\PaySystem\Restrictions\Price\getSeverity
static getSeverity($mode)
Definition
price.php:149
Bitrix\Sale\Services\Base
Definition
concreteproductrestriction.php:3
Bitrix\Sale\Services\PaySystem\Restrictions
Definition
concreteproduct.php:3
modules
sale
lib
services
paysystem
restrictions
price.php
Создано системой
1.10.0