1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
paysystem.php
См. документацию.
1
<?php
2
namespace
Bitrix\Sale\Services\Company\Restrictions;
3
4
use Bitrix\Main\Localization\Loc;
5
use Bitrix\Sale\Internals\CollectableEntity;
6
use Bitrix\Sale\Internals\CompanyServiceTable;
7
use Bitrix\Sale;
8
use Bitrix\Sale\Services\Base;
9
10
Loc::loadMessages(__FILE__);
11
12
class
PaySystem
extends
Base\Restriction
13
{
14
public
static
$easeSort
= 200;
15
19
public
static
function
getClassTitle
()
20
{
21
return
Loc::getMessage(
"SALE_COMPANY_RULES_BY_PS_TITLE"
);
22
}
23
27
public
static
function
getClassDescription
()
28
{
29
return
Loc::getMessage(
"SALE_COMPANY_RULES_BY_PS_DESC"
);
30
}
31
38
public
static
function
check
(
$params
,
array
$restrictionParams, $serviceId = 0)
39
{
40
if
((
int
)$serviceId <= 0)
41
return
true
;
42
43
if
(!
$params
)
44
return
true
;
45
46
$paySystemIds = self::getPaySystemsByCompanyId($serviceId);
47
48
if
(empty($paySystemIds))
49
return
true
;
50
51
$diff = array_diff(
$params
, $paySystemIds);
52
53
return
empty($diff);
54
}
55
61
protected
static
function
extractParams(
Sale
\
Internals
\
Entity
$entity
)
62
{
63
$result
=
array
();
64
66
$paymentCollection
=
null
;
67
68
if
(
$entity
instanceof
Sale
\
Payment
)
69
{
70
$paymentCollection
=
$entity
->getCollection();
71
}
72
elseif
(
$entity
instanceof
Sale
\
Shipment
)
73
{
75
$shipmentCollection =
$entity
->getCollection();
76
if
($shipmentCollection)
77
{
79
$order
= $shipmentCollection->getOrder();
80
if
(
$order
)
81
$paymentCollection
=
$order
->getPaymentCollection();
82
}
83
}
84
elseif
(
$entity
instanceOf
Sale
\Order)
85
{
86
$paymentCollection
=
$entity
->getPaymentCollection();
87
}
88
89
if
(
$paymentCollection
!==
null
)
90
{
92
foreach
(
$paymentCollection
as
$payment
)
93
{
94
$paySystemId =
$payment
->getPaymentSystemId();
95
if
($paySystemId)
96
$result
[] = $paySystemId;
97
}
98
}
99
100
return
$result
;
101
}
102
106
protected
static
function
getPaySystemList
()
107
{
108
$result
=
array
();
109
110
$dbRes
=
Sale\PaySystem\Manager::getList
(
array
(
'select'
=>
array
(
'ID'
,
'NAME'
)));
111
while
($paySystem =
$dbRes
->fetch())
112
$result
[$paySystem[
'ID'
]] = $paySystem[
'NAME'
].
' ['
.$paySystem[
'ID'
].
']'
;
113
114
return
$result
;
115
}
116
121
public
static
function
getParamsStructure
(
$entityId
= 0)
122
{
123
$result
=
array
(
124
"PAYSYSTEM"
=>
array
(
125
"TYPE"
=>
"ENUM"
,
126
'MULTIPLE'
=>
'Y'
,
127
"LABEL"
=> Loc::getMessage(
"SALE_COMPANY_RULES_BY_PS"
),
128
"OPTIONS"
=> self::getPaySystemList()
129
)
130
);
131
132
return
$result
;
133
}
134
140
protected
static
function
getPaySystemsByCompanyId
($companyId = 0)
141
{
142
$result
=
array
();
143
if
($companyId == 0)
144
return
$result
;
145
146
$dbRes
= CompanyServiceTable::getList(
147
array
(
148
'select'
=>
array
(
'SERVICE_ID'
),
149
'filter'
=>
array
(
150
'COMPANY_ID'
=> $companyId,
151
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
)
152
)
153
);
154
155
while
(
$data
=
$dbRes
->fetch())
156
$result
[] =
$data
[
'SERVICE_ID'
];
157
158
return
$result
;
159
}
160
166
public
static
function
save
(
array
$fields
, $restrictionId = 0)
167
{
168
$serviceIds =
$fields
[
"PARAMS"
];
169
$fields
[
"PARAMS"
] =
array
();
170
171
if
($restrictionId > 0)
172
{
173
$dbRes
= CompanyServiceTable::getList(
174
array
(
175
'select'
=>
array
(
'SERVICE_ID'
),
176
'filter'
=>
array
(
177
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
,
178
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
]
179
)
180
)
181
);
182
183
while
(
$data
=
$dbRes
->fetch())
184
{
185
$key
= array_search(
$data
[
'SERVICE_ID'
], $serviceIds[
'PAYSYSTEM'
]);
186
if
(!
$key
)
187
{
188
CompanyServiceTable::delete(
array
(
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
],
'SERVICE_ID'
=>
$data
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
));
189
}
190
else
191
{
192
unset($serviceIds[
'PAYSYSTEM'
][
$key
]);
193
}
194
}
195
}
196
197
$result
= parent::save(
$fields
, $restrictionId);
198
199
$addFields =
array
(
'COMPANY_ID'
=>
$fields
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
);
200
foreach
($serviceIds[
'PAYSYSTEM'
] as $id)
201
{
202
$addFields[
'SERVICE_ID'
] = $id;
203
CompanyServiceTable::add($addFields);
204
}
205
206
return
$result
;
207
}
208
214
public
static
function
prepareParamsValues
(
array
$paramsValues,
$entityId
= 0)
215
{
216
return
array
(
"PAYSYSTEM"
=> self::getPaySystemsByCompanyId(
$entityId
));
217
}
218
225
public
static
function
delete
($restrictionId,
$entityId
= 0)
226
{
227
$dbRes
= CompanyServiceTable::getList(
228
array
(
229
'select'
=>
array
(
'SERVICE_ID'
),
230
'filter'
=>
array
(
231
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
,
232
'COMPANY_ID'
=>
$entityId
233
)
234
)
235
);
236
237
while
(
$data
=
$dbRes
->fetch())
238
{
239
CompanyServiceTable::delete(
array
(
'COMPANY_ID'
=>
$entityId
,
'SERVICE_ID'
=>
$data
[
'SERVICE_ID'
],
'SERVICE_TYPE'
=>
Sale
\
Services
\Company\
Restrictions
\
Manager::SERVICE_TYPE_PAYMENT
));
240
}
241
242
return
parent::delete($restrictionId);
243
}
244
}
Bitrix\Sale\PaySystem\Manager\getList
static getList(array $params=array())
Определения
manager.php:84
Bitrix\Sale\Payment
Определения
payment.php:19
Bitrix\Sale\Services\Base\RestrictionManager\SERVICE_TYPE_PAYMENT
const SERVICE_TYPE_PAYMENT
Определения
restrictionmanager.php:34
Bitrix\Sale\Services\Company\Restrictions\PaySystem\getPaySystemList
static getPaySystemList()
Определения
paysystem.php:106
Bitrix\Sale\Services\Company\Restrictions\PaySystem\prepareParamsValues
static prepareParamsValues(array $paramsValues, $entityId=0)
Определения
paysystem.php:214
Bitrix\Sale\Services\Company\Restrictions\PaySystem\$easeSort
static $easeSort
Определения
paysystem.php:14
Bitrix\Sale\Services\Company\Restrictions\PaySystem\check
static check($params, array $restrictionParams, $serviceId=0)
Определения
paysystem.php:38
Bitrix\Sale\Services\Company\Restrictions\PaySystem\getClassTitle
static getClassTitle()
Определения
paysystem.php:19
Bitrix\Sale\Services\Company\Restrictions\PaySystem\save
static save(array $fields, $restrictionId=0)
Определения
paysystem.php:166
Bitrix\Sale\Services\Company\Restrictions\PaySystem\getClassDescription
static getClassDescription()
Определения
paysystem.php:27
Bitrix\Sale\Services\Company\Restrictions\PaySystem\getParamsStructure
static getParamsStructure($entityId=0)
Определения
paysystem.php:121
Bitrix\Sale\Services\Company\Restrictions\PaySystem\getPaySystemsByCompanyId
static getPaySystemsByCompanyId($companyId=0)
Определения
paysystem.php:140
Bitrix\Sale\Shipment
Определения
shipment.php:21
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Catalog\Restriction
Определения
toolavailabilitymanager.php:3
Bitrix\Main\Entity
Определения
ufield.php:9
Bitrix\Sale\Cashbox\Internals
Bitrix\Sale\Cashbox\Restrictions
Определения
company.php:2
Bitrix\Sale\Delivery\Services
Определения
automatic.php:3
Bitrix\Sale\PaySystem
Определения
applepay.php:3
Bitrix\Sale
$payment
$payment
Определения
payment.php:14
$order
$order
Определения
payment.php:8
$paymentCollection
$paymentCollection
Определения
payment.php:11
$entityId
$entityId
Определения
payment.php:4
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
$dbRes
$dbRes
Определения
yandex_detail.php:168
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
services
company
restrictions
paysystem.php
Создано системой
1.14.0