1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
orderprocessing.php
См. документацию.
1<?php
2namespace Bitrix\Sale\Internals;
3
4use Bitrix\Main;
5use Bitrix\Main\Entity\DataManager;
6use Bitrix\Main\Application;
7
25{
27
28 public static function getTableName(): string
29 {
30 return "b_sale_order_processing";
31 }
32
33 public static function getMap(): array
34 {
35 return [
36 'ORDER_ID' => [
37 'primary' => true,
38 'data_type' => 'integer',
39 ],
40 'PRODUCTS_ADDED' => [
41 'data_type' => 'boolean',
42 'values' => ['N','Y'],
43 ],
44 'PRODUCTS_REMOVED' => [
45 'data_type' => 'boolean',
46 'values' => ['N','Y'],
47 ],
48 'ORDER' => [
49 'data_type' => "Bitrix\\Sale\\OrderTable",
50 'reference' => ['=this.ORDER_ID' => 'ref.ID'],
51 ],
52 ];
53 }
54
62 public static function hasAddedProducts($orderId = 0): bool
63 {
64 $orderId = (int)$orderId;
65 $row = static::getRow([
66 'filter' => [
67 '=ORDER_ID' => $orderId,
68 ],
69 ]);
70
71 return ($row['PRODUCTS_ADDED'] ?? null) === 'Y';
72 }
73
81 public static function hasRemovedProducts($orderId = 0): bool
82 {
83 $orderId = (int)$orderId;
84 $row = static::getRow([
85 'filter' => [
86 '=ORDER_ID' => $orderId,
87 ],
88 ]);
89
90 return ($row['PRODUCTS_REMOVED'] ?? null) === 'Y';
91 }
92
100 public static function markProductsAdded($orderId = 0): void
101 {
102 $orderId = (int)$orderId;
103 if ($orderId <= 0)
104 {
105 return;
106 }
107 $row = static::getRow([
108 'filter' => [
109 '=ORDER_ID' => $orderId,
110 ],
111 ]);
112 if ($row)
113 {
114 static::update($orderId, ['PRODUCTS_ADDED' => 'Y']);
115 }
116 else
117 {
118 static::add([
119 'ORDER_ID' => $orderId,
120 'PRODUCTS_ADDED' => 'Y',
121 ]);
122 }
123 }
124
132 public static function markProductsAddedByList(array $orderIds): void
133 {
135 if (empty($orderIds))
136 {
137 return;
138 }
139
141 $sqlUpdate = "UPDATE ". static::getTableName() ." SET PRODUCTS_ADDED = 'Y' WHERE ORDER_ID IN (".implode(',', $orderIds).")";
142 $connection->queryExecute($sqlUpdate);
143 }
144
152 public static function markProductsRemoved($orderId = 0): void
153 {
154 $orderId = (int)$orderId;
155 if ($orderId <= 0)
156 {
157 return;
158 }
159 $row = static::getRow([
160 'filter' => [
161 '=ORDER_ID' => $orderId,
162 ],
163 ]);
164 if ($row)
165 {
166 static::update($orderId, ['PRODUCTS_REMOVED' => 'Y']);
167 }
168 else
169 {
170 static::add([
171 'ORDER_ID' => $orderId,
172 'PRODUCTS_REMOVED' => 'Y',
173 ]);
174 }
175 }
176
182 public static function deleteByOrderId($orderId)
183 {
184 $orderId = (int)$orderId;
185 if ($orderId <= 0)
186 {
187 return false;
188 }
189
191 $con->queryExecute("DELETE FROM ". static::getTableName() ." WHERE ORDER_ID=".$orderId);
192
193 return true;
194 }
195
200 public static function clear()
201 {
202 $connection = Application::getConnection();
203 $sql = "DELETE FROM " . static::getTableName() . "
204 WHERE ORDER_ID NOT IN (SELECT ID FROM b_sale_order)";
205 $connection->queryExecute($sql);
206 }
207}
$connection
Определения actionsdefinitions.php:38
$con
Определения admin_tab.php:7
static getConnection($name="")
Определения application.php:638
static normalizeArrayValuesByInt(&$map, $sorted=true)
Определения collection.php:150
static markProductsAddedByList(array $orderIds)
Определения orderprocessing.php:132
static hasRemovedProducts($orderId=0)
Определения orderprocessing.php:81
static deleteByOrderId($orderId)
Определения orderprocessing.php:182
static hasAddedProducts($orderId=0)
Определения orderprocessing.php:62
static markProductsAdded($orderId=0)
Определения orderprocessing.php:100
static markProductsRemoved($orderId=0)
Определения orderprocessing.php:152
$orderId
Определения payment.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804