Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
orderprocessing.php
1
<?php
2
namespace
Bitrix\Sale\Internals
;
3
use \Bitrix\Main\Entity\DataManager as DataManager;
4
use \Bitrix\Main\Type\DateTime as DateTime;
5
use \Bitrix\Main\Application as Application;
6
use
Bitrix\Main\Localization\Loc
;
7
8
Loc::loadMessages
(__FILE__);
9
10
27
class
OrderProcessingTable
extends
DataManager
28
{
29
protected
$orderProcessedCache
= array();
30
31
public
static
function
getTableName
()
32
{
33
return
"b_sale_order_processing"
;
34
}
35
36
public
static
function
getMap
()
37
{
38
return
array(
39
'ORDER_ID'
=> array(
40
'primary'
=>
true
,
41
'data_type'
=>
'integer'
,
42
),
43
'PRODUCTS_ADDED'
=> array(
44
'data_type'
=>
'boolean'
,
45
'values'
=> array(
'N'
,
'Y'
)
46
),
47
'PRODUCTS_REMOVED'
=>array (
48
'data_type'
=>
'boolean'
,
49
'values'
=> array(
'N'
,
'Y'
)
50
),
51
'ORDER'
=> array(
52
'data_type'
=>
"Bitrix\\Sale\\OrderTable"
,
53
'reference'
=> array(
'=this.ORDER_ID'
=>
'ref.ID'
)
54
)
55
);
56
}
57
65
public
static
function
hasAddedProducts
($orderId = 0)
66
{
67
$orderId = (int)$orderId;
68
$iterator = static::getList(array(
69
"filter"
=> array(
"ORDER_ID"
=> $orderId)
70
));
71
72
$row = $iterator->fetch();
73
return
$row && $row[
'PRODUCTS_ADDED'
] ==
"Y"
;
74
}
75
83
public
static
function
hasRemovedProducts
($orderId = 0)
84
{
85
$orderId = (int)$orderId;
86
$iterator = static::getList(array(
87
"filter"
=> array(
"ORDER_ID"
=> $orderId)
88
));
89
90
$row = $iterator->fetch();
91
return
$row && $row[
'PRODUCTS_REMOVED'
] ==
"Y"
;
92
}
93
99
public
static
function
markProductsAdded
($orderId = 0)
100
{
101
$orderId = (int)$orderId;
102
$iterator = static::getList(array(
103
"filter"
=> array(
"ORDER_ID"
=> $orderId)
104
));
105
if
($row = $iterator->fetch())
106
{
107
static::update($orderId, array(
"PRODUCTS_ADDED"
=>
'Y'
));
108
}
109
else
110
{
111
static::add(array(
"ORDER_ID"
=> $orderId,
"PRODUCTS_ADDED"
=>
'Y'
));
112
}
113
}
114
120
public
static
function
markProductsAddedByList
(array $orderIds)
121
{
122
$preparedIds = array();
123
foreach
( $orderIds as $orderId)
124
{
125
if
((
int
)$orderId > 0)
126
$preparedIds[] = (int)$orderId;
127
}
128
129
$connection = \Bitrix\Main\Application::getConnection();
130
$type = $connection->getType();
131
if
($type ==
"mysql"
&& !empty($preparedIds))
132
{
133
$sqlUpdate =
"UPDATE "
. static::getTableName() .
" SET PRODUCTS_ADDED = 'Y' WHERE ORDER_ID IN ("
.implode(
','
, $preparedIds).
")"
;
134
$connection->query($sqlUpdate);
135
}
136
}
137
143
public
static
function
markProductsRemoved
($orderId = 0)
144
{
145
$orderId = (int)$orderId;
146
$iterator = static::getList(array(
147
"filter"
=> array(
"ORDER_ID"
=> $orderId)
148
));
149
if
($row = $iterator->fetch())
150
{
151
static::update($orderId, array(
"PRODUCTS_REMOVED"
=>
'Y'
));
152
}
153
else
154
{
155
static::add(array(
"ORDER_ID"
=> $orderId,
"PRODUCTS_REMOVED"
=>
'Y'
));
156
}
157
}
158
164
public
static
function
deleteByOrderId
($orderId)
165
{
166
if
((
int
)($orderId) <= 0)
167
return
false
;
168
169
$con = \Bitrix\Main\Application::getConnection();
170
$con->queryExecute(
"DELETE FROM "
. static::getTableName() .
" WHERE ORDER_ID="
.(
int
)($orderId));
171
return
true
;
172
}
173
178
public
static
function
clear
()
179
{
180
$connection =
Application::getConnection
();
181
$sql =
"DELETE FROM "
. static::getTableName() .
"
182
WHERE ORDER_ID NOT IN (SELECT ID FROM b_sale_order)"
;
183
$connection->query($sql);
184
}
185
}
186
187
?>
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Sale\Internals\OrderProcessingTable
Definition
orderprocessing.php:28
Bitrix\Sale\Internals\OrderProcessingTable\$orderProcessedCache
$orderProcessedCache
Definition
orderprocessing.php:29
Bitrix\Sale\Internals\OrderProcessingTable\markProductsAddedByList
static markProductsAddedByList(array $orderIds)
Definition
orderprocessing.php:120
Bitrix\Sale\Internals\OrderProcessingTable\getMap
static getMap()
Definition
orderprocessing.php:36
Bitrix\Sale\Internals\OrderProcessingTable\hasRemovedProducts
static hasRemovedProducts($orderId=0)
Definition
orderprocessing.php:83
Bitrix\Sale\Internals\OrderProcessingTable\clear
static clear()
Definition
orderprocessing.php:178
Bitrix\Sale\Internals\OrderProcessingTable\deleteByOrderId
static deleteByOrderId($orderId)
Definition
orderprocessing.php:164
Bitrix\Sale\Internals\OrderProcessingTable\hasAddedProducts
static hasAddedProducts($orderId=0)
Definition
orderprocessing.php:65
Bitrix\Sale\Internals\OrderProcessingTable\markProductsAdded
static markProductsAdded($orderId=0)
Definition
orderprocessing.php:99
Bitrix\Sale\Internals\OrderProcessingTable\markProductsRemoved
static markProductsRemoved($orderId=0)
Definition
orderprocessing.php:143
Bitrix\Sale\Internals\OrderProcessingTable\getTableName
static getTableName()
Definition
orderprocessing.php:31
Bitrix\Sale\Internals
Definition
accountnumber.php:3
modules
sale
lib
internals
orderprocessing.php
Создано системой
1.10.0