Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
statistics.php
1
<?php
2
3
4
namespace
Bitrix\Sale\Exchange\Integration\Service\Command\Batch
;
5
6
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Main\Result
;
9
use
Bitrix\Sale\Exchange\Integration\EntityType
;
10
use
Bitrix\Sale\Exchange\Integration\Service\Command\IProxy
;
11
use
Bitrix\Sale\Exchange\Integration\Service\Container\Collection
;
12
use
Bitrix\Sale\Exchange\Integration\Service\Container\Item
;
13
use
Bitrix\Sale\Exchange\Integration\Service\Statistic\Entity\Order
;
14
15
class
Statistics
16
implements
IProxy
17
{
18
19
protected
$collection
;
20
24
public
function
getCollection
():
Collection
25
{
26
return
$this->collection
;
27
}
28
29
public
function
__construct
()
30
{
31
$this->collection =
new
Collection
();
32
}
33
public
function
init
($params)
34
{
35
foreach
($params as $index=>$item)
36
{
37
$this->collection->addItem(
38
Item::create(
39
(
new
Order
())
40
->setEntityId($index)
41
->setEntityTypeId(
EntityType::ORDER
)
42
->setDateUpdate($item[
'dateUpdate'
])
43
->setCurrency($item[
'currency'
])
44
->setProviderId($item[
'providerId'
])
45
->setStatus($item[
'status'
])
46
->setXmlId($item[
'xmlId'
])
47
->setAmount($item[
'amount'
]))
48
->setInternalIndex($index)
49
);
50
}
51
52
return
$this;
53
}
54
55
static
public
function
getProxy
()
56
{
57
return
new \Bitrix\Sale\Exchange\Integration\Rest\RemoteProxies\Sale\Statistics();
58
}
59
63
public
function
modify()
64
{
67
foreach
($this->
getCollection
() as $item)
68
{
69
$providerId = $item->getEntity()->getProviderId();
70
break
;
71
}
72
73
return
$this
74
->modifyFromParams([
75
'provider'
=>[
'id'
=>$providerId],
76
'statistics'
=>$this
77
->
getCollection
()
78
->toArray()
79
]);
80
}
81
82
static
protected
function
proxyModify
(array $list)
83
{
84
$proxy = static::getProxy();
85
$r = $proxy->modify($list);
86
if
($r->isSuccess())
87
{
88
$result = $r->getData()[
'DATA'
][
'result'
];
89
}
90
else
91
{
92
$result[
'error'
] = $r->getErrorMessages();
93
}
94
95
return
$result;
96
}
97
102
protected
function
modifyFromParams
(array $params)
103
{
104
$r =
new
Result
();
105
106
$res = static::proxyModify($params);
107
108
if
(!empty($res[
'error'
]))
109
{
110
foreach
($res[
'error'
] as $error)
111
{
112
$r->addError(
new
Error
($error));
113
}
114
}
115
116
return
$r;
117
}
118
119
}
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\Result
Definition
result.php:14
Bitrix\Sale\Exchange\Integration\CRM\EntityType
Definition
entitytype.php:5
Bitrix\Sale\Exchange\Integration\EntityType\ORDER
const ORDER
Definition
entitytype.php:12
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics
Definition
statistics.php:17
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\__construct
__construct()
Definition
statistics.php:29
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\init
init($params)
Definition
statistics.php:33
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\getProxy
static getProxy()
Definition
statistics.php:55
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\proxyModify
static proxyModify(array $list)
Definition
statistics.php:82
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\modifyFromParams
modifyFromParams(array $params)
Definition
statistics.php:102
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\$collection
$collection
Definition
statistics.php:19
Bitrix\Sale\Exchange\Integration\Service\Command\Batch\Statistics\getCollection
getCollection()
Definition
statistics.php:24
Bitrix\Sale\Exchange\Integration\Service\Container\Collection
Definition
collection.php:7
Bitrix\Sale\Exchange\Integration\Service\Container\Item
Definition
item.php:9
Bitrix\Sale\Exchange\Integration\Service\Statistic\Entity\Order
Definition
order.php:8
Bitrix\Sale\Exchange\Integration\Service\Command\IProxy
Definition
iproxy.php:6
Bitrix\Sale\Exchange\Integration\Service\Command\Batch
Definition
placement.php:2
modules
sale
lib
exchange
integration
service
command
batch
statistics.php
Создано системой
1.10.0