1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
statistic.php
См. документацию.
1
<?php
2
3
4
namespace
Bitrix\Sale\Exchange\Integration\RestView
;
5
6
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Rest\Integration\View\Attributes
;
9
use
Bitrix\Rest\Integration\View\Base
;
10
use
Bitrix\Rest\Integration\View\DataType
;
11
use
Bitrix\Main\NotImplementedException
;
12
use
Bitrix\Sale\Result
;
13
14
final
class
Statistic
extends
Base
15
{
16
17
public
function
getFields
()
18
{
19
return
[
20
'ID'
=>[
21
'TYPE'
=>DataType::TYPE_INT,
22
'ATTRIBUTES'
=>[
23
Attributes::READONLY
24
]
25
],
26
'ENTITY_TYPE_ID'
=>[
27
'TYPE'
=>DataType::TYPE_INT,
28
'ATTRIBUTES'
=>[
29
Attributes::REQUIRED,
30
Attributes::IMMUTABLE
31
]
32
],
33
'ENTITY_ID'
=>[
34
'TYPE'
=>DataType::TYPE_INT,
35
'ATTRIBUTES'
=>[
36
Attributes::REQUIRED,
37
Attributes::IMMUTABLE
38
]
39
],
40
'DATE_UPDATE'
=>[
41
'TYPE'
=>DataType::TYPE_DATETIME,
42
'ATTRIBUTES'
=>[
43
Attributes::REQUIRED
44
]
45
],
46
'TIMESTAMP_X'
=>[
47
'TYPE'
=>DataType::TYPE_DATETIME,
48
'ATTRIBUTES'
=>[
49
Attributes::READONLY
50
]
51
],
52
'PROVIDER_ID'
=>[
53
'TYPE'
=>DataType::TYPE_INT,
54
'ATTRIBUTES'
=>[
55
Attributes::REQUIRED,
56
Attributes::IMMUTABLE
57
]
58
],
59
'CURRENCY'
=>[
60
'TYPE'
=>DataType::TYPE_STRING,
61
'ATTRIBUTES'
=>[
62
Attributes::REQUIRED
63
]
64
],
65
'STATUS'
=>[
66
'TYPE'
=>DataType::TYPE_STRING,
67
'ATTRIBUTES'
=>[
68
Attributes::REQUIRED
69
]
70
],
71
'XML_ID'
=>[
72
'TYPE'
=>DataType::TYPE_STRING,
73
'ATTRIBUTES'
=>[
74
Attributes::REQUIRED
75
]
76
],
77
'AMOUNT'
=>[
78
'TYPE'
=>DataType::TYPE_FLOAT,
79
'ATTRIBUTES'
=>[
80
Attributes::REQUIRED
81
]
82
]
83
];
84
}
85
86
public
function
convertKeysToSnakeCaseArguments
(
$name
, $arguments)
87
{
88
if
(
$name
==
'upsert'
)
89
{
90
if
(isset($arguments[
'fields'
]))
91
{
92
$fields
= $arguments[
'fields'
];
93
if
(!empty(
$fields
))
94
{
95
$arguments[
'fields'
] = $this->
convertKeysToSnakeCaseFields
(
$fields
);
96
}
97
}
98
}
99
elseif
(
$name
==
'modify'
)
100
{
101
$fields
= $arguments[
'fields'
];
102
$arguments[
'fields'
] = $this->
convertKeysToSnakeCaseFieldsModify
(
$fields
);
103
}
104
else
105
{
106
throw
new
NotImplementedException
(
'Convert arguments. The method '
.
$name
.
' is not implemented.'
);
107
}
108
109
return
$arguments;
110
}
111
112
protected
function
convertKeysToSnakeCaseFieldsModify
(
$fields
)
113
{
114
$fields
= $this->
convertKeysToSnakeCaseFields
(
$fields
);
115
116
return
$fields
;
117
}
118
119
public
function
checkArguments
(
$name
, $arguments): \
Bitrix
\
Main
\
Result
120
{
121
$r =
new
Result
();
122
123
if
(
$name
==
'upsert'
)
124
{
125
$r = $this->
checkFieldsAdd
($arguments[
'fields'
]);
126
}
127
elseif
(
$name
==
'modify'
)
128
{
129
$required = $this->
checkFieldsModify
($arguments[
'fields'
]);
130
131
if
($required->isSuccess() ===
false
)
132
{
133
$r->addError(
new
Error
(implode(
', '
, $required->getErrorMessages())));
134
}
135
}
136
else
137
{
138
throw
new
NotImplementedException
(
'Check arguments. The method '
.
$name
.
' is not implemented.'
);
139
}
140
return
$r;
141
}
142
143
protected
function
checkFieldsModify
(
$fields
)
144
{
145
$r =
new
Result
();
146
147
$emptyFields = [];
148
if
(!isset(
$fields
[
'PROVIDER'
][
'ID'
]))
149
{
150
$emptyFields[] =
'[provider][id]'
;
151
}
152
if
(!isset(
$fields
[
'STATISTICS'
]) || !is_array(
$fields
[
'STATISTICS'
]))
153
{
154
$emptyFields[] =
'[statistics][]'
;
155
}
156
157
if
(
count
($emptyFields)>0)
158
{
159
$r->addError(
new
Error
(
'Required fields: '
.implode(
', '
, $emptyFields)));
160
}
161
else
162
{
163
foreach
(
$fields
[
'STATISTICS'
] as
$k
=>
$fields
)
164
{
165
$required = $this->
checkFieldsAdd
(
$fields
);
166
if
($required->isSuccess() ===
false
)
167
{
168
$r->addError(
new
Error
(
'[fields][statistics]['
.
$k
.
'] - '
.implode(
', '
, $required->getErrorMessages()).
'.'
));
169
}
170
}
171
}
172
173
return
$r;
174
}
175
176
public
function
internalizeArguments
(
$name
, $arguments):
array
177
{
178
if
(
$name
==
'upsert'
)
179
{
180
$fields
= $arguments[
'fields'
];
181
if
(!empty(
$fields
))
182
{
183
$arguments[
'fields'
] = $this->
internalizeFieldsAdd
(
$fields
);
184
}
185
}
186
elseif
(
$name
==
'modify'
)
187
{
188
$fields
= $arguments[
'fields'
];
189
$arguments[
'fields'
] = $this->
internalizeFieldsModify
(
$fields
);
190
}
191
else
192
{
193
parent::internalizeArguments(
$name
, $arguments);
194
}
195
196
return
$arguments;
197
}
198
199
protected
function
internalizeFieldsModify
(
$fields
)
200
{
201
$result
= [];
202
203
$result
[
'PROVIDER'
][
'ID'
] = (int)
$fields
[
'PROVIDER'
][
'ID'
];
204
205
foreach
(
$fields
[
'STATISTICS'
] as
$k
=>$statistic)
206
{
207
$result
[
'STATISTICS'
][
$k
] = $this->
internalizeFieldsAdd
($statistic);
208
}
209
210
return
$result
;
211
}
212
213
public
function
externalizeResult
(
$name
,
$fields
):
array
214
{
215
if
(
$name
==
'upsert'
)
216
{
217
return
$this->
externalizeFieldsGet
(
$fields
);
218
}
219
elseif
(
$name
==
'modify'
)
220
{
221
$provider
=
new
StatisticProvider
();
222
$fields
[
'PROVIDER'
] = $this->
externalizeFieldsGet
(
$fields
[
'PROVIDER'
],
$provider
->getFields());
223
}
224
else
225
{
226
parent::externalizeResult(
$name
,
$fields
);
227
}
228
229
return
$fields
;
230
}
231
}
$provider
if(!Loader::includeModule('messageservice')) $provider
Определения
callback_ednaruimhpx.php:21
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\NotImplementedException
Определения
NotImplementedException.php:9
Bitrix\Rest\Integration\View\Attributes
Определения
attributes.php:6
Bitrix\Rest\Integration\View\Base
Определения
base.php:17
Bitrix\Rest\Integration\View\Base\internalizeFieldsAdd
internalizeFieldsAdd($fields, $fieldsInfo=[])
Определения
base.php:189
Bitrix\Rest\Integration\View\Base\externalizeFieldsGet
externalizeFieldsGet($fields, $fieldsInfo=[])
Определения
base.php:855
Bitrix\Rest\Integration\View\Base\checkFieldsAdd
checkFieldsAdd($fields)
Определения
base.php:870
Bitrix\Rest\Integration\View\Base\convertKeysToSnakeCaseFields
convertKeysToSnakeCaseFields($fields)
Определения
base.php:88
Bitrix\Rest\Integration\View\DataType
Определения
datatype.php:11
Bitrix\Sale\Exchange\Integration\RestView\Statistic
Определения
statistic.php:15
Bitrix\Sale\Exchange\Integration\RestView\Statistic\internalizeArguments
internalizeArguments($name, $arguments)
Определения
statistic.php:176
Bitrix\Sale\Exchange\Integration\RestView\Statistic\checkFieldsModify
checkFieldsModify($fields)
Определения
statistic.php:143
Bitrix\Sale\Exchange\Integration\RestView\Statistic\convertKeysToSnakeCaseFieldsModify
convertKeysToSnakeCaseFieldsModify($fields)
Определения
statistic.php:112
Bitrix\Sale\Exchange\Integration\RestView\Statistic\convertKeysToSnakeCaseArguments
convertKeysToSnakeCaseArguments($name, $arguments)
Определения
statistic.php:86
Bitrix\Sale\Exchange\Integration\RestView\Statistic\checkArguments
checkArguments($name, $arguments)
Определения
statistic.php:119
Bitrix\Sale\Exchange\Integration\RestView\Statistic\externalizeResult
externalizeResult($name, $fields)
Определения
statistic.php:213
Bitrix\Sale\Exchange\Integration\RestView\Statistic\internalizeFieldsModify
internalizeFieldsModify($fields)
Определения
statistic.php:199
Bitrix\Sale\Exchange\Integration\RestView\Statistic\getFields
getFields()
Определения
statistic.php:17
Bitrix\Sale\Exchange\Integration\RestView\StatisticProvider
Определения
statisticprovider.php:12
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$name
$name
Определения
menu_edit.php:35
Bitrix\Main
Bitrix\Sale\Discount\Result
Определения
compatibleformat.php:2
Bitrix\Sale\Exchange\Integration\RestView
Определения
statistic.php:4
Bitrix
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
count
</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
$k
$k
Определения
template_pdf.php:567
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
exchange
integration
restview
statistic.php
Создано системой
1.14.0