1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pay_system.php
См. документацию.
1<?php
4
6
9{
10 public static function DoProcessOrder(&$arOrder, $paySystemId, &$arErrors)
11 {
12 if (intval($paySystemId) > 0)
13 {
14 $arPaySystem = array();
15
16 $dbPaySystem = CSalePaySystem::GetList(
17 array("SORT" => "ASC", "PSA_NAME" => "ASC"),
18 array(
19 "ACTIVE" => "Y",
20 "PERSON_TYPE_ID" => $arOrder["PERSON_TYPE_ID"],
21 "PSA_HAVE_PAYMENT" => "Y"
22 )
23 );
24
25 while ($arPaySystem = $dbPaySystem->Fetch())
26 {
27 if ($arPaySystem["ID"] == $paySystemId)
28 {
29 $arOrder["PAY_SYSTEM_ID"] = $paySystemId;
30
31 $arOrder["PAY_SYSTEM_PRICE"] = CSalePaySystemsHelper::getPSPrice(
32 $arPaySystem,
33 $arOrder["ORDER_PRICE"],
34 $arOrder["PRICE_DELIVERY"],
35 $arOrder["DELIVERY_LOCATION"]
36 );
37 break;
38 }
39 }
40
41 if (empty($arPaySystem))
42 {
43 $arErrors[] = array("CODE" => "CALCULATE", "TEXT" => GetMessage('SKGPS_PS_NOT_FOUND'));
44 }
45 }
46 }
47
48 public static function DoLoadPaySystems($personType, $deliveryId = 0, $arDeliveryMap = null)
49 {
50 $arResult = array();
51
53 "=ACTIVE" => "Y",
54 "PERSON_TYPE_ID" => $personType,
55 "=PSA_HAVE_PAYMENT" => "Y"
56 );
57
58 // $arDeliveryMap = array(array($deliveryId => 8), array($deliveryId => array(34, 22)), ...)
59 if (is_array($arDeliveryMap) && (count($arDeliveryMap) > 0))
60 {
61 foreach ($arDeliveryMap as $val)
62 {
63 if (is_array($val[$deliveryId]))
64 {
65 foreach ($val[$deliveryId] as $v)
66 $arFilter["ID"][] = $v;
67 }
68 elseif (intval($val[$deliveryId]) > 0)
69 $arFilter["ID"][] = $val[$deliveryId];
70 }
71 }
72 $dbPaySystem = CSalePaySystem::GetList(
73 array("SORT" => "ASC", "PSA_NAME" => "ASC"),
75 );
76 while ($arPaySystem = $dbPaySystem->GetNext())
77 $arResult[$arPaySystem["ID"]] = $arPaySystem;
78
79 return $arResult;
80 }
81
82 public static function GetByID($id, $personTypeId = 0)
83 {
84 $id = (int)$id;
85 $personTypeId = (int)$personTypeId;
86
87 if ($personTypeId > 0)
88 {
89 $select = array_merge(array('ID', 'NAME', 'DESCRIPTION', 'ACTIVE', 'SORT'), self::getAliases());
90
92 'select' => $select,
93 'filter' => array('ID' => $id)
94 ));
95 }
96 else
97 {
99 }
100
101 if ($result = $dbRes->fetch())
102 {
104 $key = array_search($result['ACTION_FILE'], $map);
105
106 if ($key !== false)
107 $result['ACTION_FILE'] = $key;
108
109 return $result;
110 }
111
112 return false;
113 }
114
115 protected static function getAliases()
116 {
117 $aliases = array(
118 "PSA_ID" => 'ID',
119 "PSA_ACTION_FILE" => 'ACTION_FILE',
120 "PSA_RESULT_FILE" => 'RESULT_FILE',
121 "PSA_NEW_WINDOW" => 'NEW_WINDOW',
122 "PSA_PERSON_TYPE_ID" => 'PERSON_TYPE_ID',
123 "PSA_PARAMS" => 'PARAMS',
124 "PSA_TARIF" => 'TARIF',
125 "PSA_HAVE_PAYMENT" => 'HAVE_PAYMENT',
126 "PSA_HAVE_ACTION" => 'HAVE_ACTION',
127 "PSA_HAVE_RESULT" => 'HAVE_RESULT',
128 "PSA_HAVE_PREPAY" => 'HAVE_PREPAY',
129 "PSA_HAVE_RESULT_RECEIVE" => 'HAVE_RESULT_RECEIVE',
130 "PSA_ENCODING" => 'ENCODING',
131 "PSA_LOGOTIP" => 'LOGOTIP'
132 );
133 return $aliases;
134 }
135
136 public static function CheckFields($ACTION, &$arFields)
137 {
138 global $DB, $USER;
139
140 if ((is_set($arFields, "NAME") || $ACTION=="ADD") && $arFields["NAME"] == '')
141 {
142 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPS_EMPTY_NAME"), "ERROR_NO_NAME");
143 return false;
144 }
145
146 if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"]!="Y")
147 $arFields["ACTIVE"] = "N";
148 if (is_set($arFields, "SORT") && intval($arFields["SORT"])<=0)
149 $arFields["SORT"] = 100;
150
151 return True;
152 }
153
154 public static function Update($id, $arFields)
155 {
156 if (isset($arFields['LID']))
157 unset($arFields['LID']);
158
159 if (isset($arFields['CURRENCY']))
160 unset($arFields['CURRENCY']);
161
162 $id = (int)$id;
163
165 return false;
166
168 }
169
170 public static function Delete($id)
171 {
172 $id = (int)$id;
173
175 if (!$dbRes->fetch())
176 {
177 $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPS_ORDERS_TO_PAYSYSTEM"), "ERROR_ORDERS_TO_PAYSYSTEM");
178 return false;
179 }
180
182
183 return $dbRes->isSuccess();
184 }
185
186 public static function getNewIdsFromOld($ids, $personTypeId = null)
187 {
189 'select' => array('ID'),
190 'filter' => array('PAY_SYSTEM_ID' => $ids)
191 ));
192
193 $data = array();
194 while ($ps = $dbRes->fetch())
195 {
196 if (!is_null($personTypeId))
197 {
198 $dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array(
199 'filter' => array(
200 'SERVICE_ID' => $ps['ID'],
202 '=CLASS_NAME' => '\\'.\Bitrix\Sale\Services\PaySystem\Restrictions\PersonType::class
203 )
204 ));
205
206 while ($restriction = $dbRestriction->fetch())
207 {
208 if (!in_array($personTypeId, $restriction['PARAMS']['PERSON_TYPE_ID']))
209 continue(2);
210 }
211 }
212
213 $data[] = $ps['ID'];
214 }
215
216 return $data;
217 }
218
219 public static function getPaySystemPersonTypeIds($paySystemId)
220 {
221 $data = array();
222
223 $dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array(
224 'filter' => array(
225 'SERVICE_ID' => $paySystemId,
227 '=CLASS_NAME' => '\\'.\Bitrix\Sale\Services\PaySystem\Restrictions\PersonType::class
228 )
229 ));
230 while ($restriction = $dbRestriction->fetch())
231 $data = array_merge($data, $restriction['PARAMS']['PERSON_TYPE_ID']);
232
233 return $data;
234 }
235
236 public static function GetList($arOrder = array("SORT" => "ASC", "NAME" => "ASC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
237 {
238 if (array_key_exists("PSA_PERSON_TYPE_ID", $arFilter))
239 {
240 $arFilter['PERSON_TYPE_ID'] = $arFilter['PSA_PERSON_TYPE_ID'];
241 unset($arFilter["PSA_PERSON_TYPE_ID"]);
242 }
243
244 $salePaySystemFields = array('ID', 'NAME', 'ACTIVE', 'SORT', 'DESCRIPTION');
245 $ignoredFields = array('LID', 'CURRENCY', 'PERSON_TYPE_ID');
246
247 if (!$arSelectFields)
248 {
249 $select = array('ID', 'NAME', 'ACTIVE', 'SORT', 'DESCRIPTION');
250 }
251 else
252 {
253 $select = array();
254 foreach ($arSelectFields as $key => $field)
255 {
256 if (in_array($field, $ignoredFields))
257 continue;
258
259 $select[$key] = self::getAlias($field);
260 }
261 }
262
263 $filter = array();
264 foreach ($arFilter as $key => $value)
265 {
266 if (in_array($key, $ignoredFields))
267 continue;
268
269 $filter[self::getAlias($key)] = $value;
270 }
271
272 if (isset($arFilter['PERSON_TYPE_ID']))
273 $select = array_merge($select, array('PSA_ID' => 'ID', 'PSA_NAME', 'ACTION_FILE', 'RESULT_FILE', 'NEW_WINDOW', 'PERSON_TYPE_ID', 'PARAMS', 'TARIF', 'HAVE_PAYMENT', 'HAVE_ACTION', 'HAVE_RESULT', 'HAVE_PREPAY', 'HAVE_RESULT_RECEIVE', 'ENCODING', 'LOGOTIP'));
274
275 if (in_array('PARAMS', $select) && !array_key_exists('PSA_ID', $select))
276 $select['PSA_ID'] = 'ID';
277
278 if (in_array('PARAMS', $select) && !in_array('PERSON_TYPE_ID', $select))
279 $select[] = 'PERSON_TYPE_ID';
280
281 $order = array();
282 foreach ($arOrder as $key => $value)
283 $order[self::getAlias($key)] = $value;
284
285 $groupBy = array();
286 if ($arGroupBy !== false)
287 {
288 $arGroupBy = !is_array($arGroupBy) ? array($arGroupBy) : $arGroupBy;
289
290 foreach ($arGroupBy as $key => $value)
291 $groupBy[$key] = self::getAlias($value);
292 }
294 array(
295 'select' => $select,
296 'filter' => $filter,
297 'order' => $order,
298 'group' => $groupBy,
299 )
300 );
301
302 $limit = null;
303 if (is_array($arNavStartParams) && isset($arNavStartParams['nTopCount']))
304 {
305 if ($arNavStartParams['nTopCount'] > 0)
306 $limit = $arNavStartParams['nTopCount'];
307 }
308
309 $result = array();
310
311 while ($data = $dbRes->fetch())
312 {
313 if ($limit !== null && !$limit)
314 break;
315
316 $dbRestriction = \Bitrix\Sale\Internals\ServiceRestrictionTable::getList(array(
317 'filter' => array(
318 'SERVICE_ID' => $data['ID'],
320 )
321 ));
322
323 while ($restriction = $dbRestriction->fetch())
324 {
326 continue(2);
327 }
328
329 if (isset($data['ACTION_FILE']))
330 {
331 $oldHandler = array_search($data['ACTION_FILE'], CSalePaySystemAction::getOldToNewHandlersMap());
332 if ($oldHandler !== false)
333 $data['ACTION_FILE'] = $oldHandler;
334 }
335
336 if (array_key_exists('PARAMS', $data))
337 {
338 $params = CSalePaySystemAction::getParamsByConsumer('PAYSYSTEM_'.$data['PSA_ID'], $data['PERSON_TYPE_ID']);
339 $params['BX_PAY_SYSTEM_ID'] = array('TYPE' => '', 'VALUE' => $data['PSA_ID']);
340 $data['PARAMS'] = serialize($params);
341 }
342
343 foreach ($data as $key => $value)
344 {
345 if (!in_array($key, $salePaySystemFields))
346 {
347 $newKey = self::getAliasBack($key);
348 if ($newKey != $key)
349 {
350 $data[$newKey] = $value;
351 unset($data[$key]);
352 }
353 }
354 }
355
356 $result[] = $data;
357 $limit--;
358 }
359
360 $dbRes = new \CDBResult();
361 $dbRes->InitFromArray($result);
362
363 return $dbRes;
364 }
365
366 private static function getAlias($key)
367 {
368 $prefix = '';
369 $pos = mb_strpos($key, 'PSA_');
370 if ($pos > 0)
371 {
372 $prefix = mb_substr($key, 0, $pos);
373 $key = mb_substr($key, $pos);
374 }
375
376 $aliases = self::getAliases();
377
378 if (isset($aliases[$key]))
379 $key = $aliases[$key];
380
381 return $prefix.$key;
382 }
383
384 private static function getAliasBack($value)
385 {
386 $aliases = self::getAliases();
387 $result = array_search($value, $aliases);
388
389 return $result !== false ? $result : $value;
390 }
391
397 public static function Add($arFields)
398 {
399 if (isset($arFields['LID']))
400 unset($arFields['LID']);
401
402 if (isset($arFields['CURRENCY']))
403 unset($arFields['CURRENCY']);
404
406 return false;
407
408 return CSalePaySystemAction::add($arFields);
409 }
410}
$arResult
Определения generate_coupon.php:16
static getById($id)
Определения datamanager.php:364
static getList(array $params=array())
Определения manager.php:84
static delete($primary)
Определения manager.php:815
static getOldToNewHandlersMap()
Определения pay_system_action.php:1631
static Update($id, $fields)
Определения pay_system_action.php:1005
static checkRestriction($restriction, $filter)
Определения pay_system_action.php:844
static getParamsByConsumer($consumer, $personTypeId)
Определения pay_system_action.php:866
Определения pay_system.php:9
static getPaySystemPersonTypeIds($paySystemId)
Определения pay_system.php:219
static DoLoadPaySystems($personType, $deliveryId=0, $arDeliveryMap=null)
Определения pay_system.php:48
static DoProcessOrder(&$arOrder, $paySystemId, &$arErrors)
Определения pay_system.php:10
static Delete($id)
Определения pay_system.php:170
static Add($arFields)
Определения pay_system.php:397
static getAliases()
Определения pay_system.php:115
static GetByID($id, $personTypeId=0)
Определения pay_system.php:82
static CheckFields($ACTION, &$arFields)
Определения pay_system.php:136
static getNewIdsFromOld($ids, $personTypeId=null)
Определения pay_system.php:186
static GetList($arOrder=array("SORT"=> "ASC", "NAME"=> "ASC"), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения pay_system.php:236
static Update($id, $arFields)
Определения pay_system.php:154
static getPSPrice($arPaySystem, $orderPrice, $deliveryPrice, $buyerLocationId)
Определения pay_system_helper.php:51
$arFields
Определения dblapprove.php:5
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$select
Определения iblock_catalog_list.php:194
$filter
Определения iblock_catalog_list.php:54
global $DB
Определения cron_frame.php:29
global $USER
Определения csv_new_run.php:40
$ACTION
Определения csv_new_setup.php:27
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
is_set($a, $k=false)
Определения tools.php:2133
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$map
Определения config.php:5
$value
Определения Param.php:39
$GLOBALS['____1690880296']
Определения license.php:1
$order
Определения payment.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$val
Определения options.php:1793
$arFilter
Определения user_search.php:106
$dbRes
Определения yandex_detail.php:168