1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
paymentrepository.php
См. документацию.
1<?php
2
3namespace Bitrix\Sale\Repository;
4
5use Bitrix\Sale;
6
13{
15 private static $instance;
16
20 private function __construct()
21 {}
22
26 public static function getInstance(): PaymentRepository
27 {
28 if (is_null(self::$instance))
29 {
30 self::$instance = new self();
31 }
32
33 return self::$instance;
34 }
35
40 public function getById(int $id): ?Sale\Payment
41 {
42 $paymentList = $this->getList([
43 'select' => ['ID', 'ORDER_ID'],
44 'filter' => [
45 '=ID' => $id
46 ],
47 ]);
48
49 return $paymentList[0] ?? null;
50 }
51
56 public function getByIds(array $ids): array
57 {
58 return $this->getList([
59 'select' => ['ID', 'ORDER_ID'],
60 'filter' => [
61 '@ID' => $ids
62 ],
63 ]);
64 }
65
70 public function getList(array $parameters): array
71 {
72 $result = [];
73
75 $paymentClass = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER)->getPaymentClassName();
76
77 $paymentList = $paymentClass::getList($parameters);
78 while ($paymentRow = $paymentList->fetch())
79 {
80 $payment = $this->getByRow($paymentRow);
81 if (is_null($payment))
82 {
83 continue;
84 }
85
86 $result[] = $payment;
87 }
88
89 return $result;
90 }
91
96 private function getByRow(array $paymentRow): ?Sale\Payment
97 {
98 $orderClassName = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER)->getOrderClassName();
99
101 $order = $orderClassName::load($paymentRow['ORDER_ID']);
102 if ($order === null)
103 {
104 return null;
105 }
106
107 $paymentId = (int)$paymentRow['ID'];
108 if ($paymentId > 0)
109 {
111 $payment = $order->getPaymentCollection()->getItemById($paymentRow['ID']);
112
113 return $payment;
114 }
115
116 return null;
117 }
118}
Определения payment.php:19
static getInstance($type)
Определения registry.php:183
const REGISTRY_TYPE_ORDER
Определения registry.php:16
</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
$payment
Определения payment.php:14
$order
Определения payment.php:8