1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Models; |
4
|
|
|
|
5
|
|
|
use Daaner\NovaPoshta\NovaPoshta; |
6
|
|
|
use Daaner\NovaPoshta\Traits\AdditionalServiceProperty; |
7
|
|
|
use Daaner\NovaPoshta\Traits\DateTimes; |
8
|
|
|
use Daaner\NovaPoshta\Traits\InternetDocumentProperty; |
9
|
|
|
use Daaner\NovaPoshta\Traits\Limit; |
10
|
|
|
|
11
|
|
|
class AdditionalService extends NovaPoshta |
12
|
|
|
{ |
13
|
|
|
protected $model = 'AdditionalService'; |
14
|
|
|
protected $calledMethod; |
15
|
|
|
protected $methodProperties = null; |
16
|
|
|
|
17
|
|
|
use InternetDocumentProperty, AdditionalServiceProperty, Limit, DateTimes; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Проверка возможности создания заявки на возврат. |
21
|
|
|
* |
22
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a778f519-8512-11ec-8ced-005056b2dbe1 Возможность возврата |
23
|
|
|
* |
24
|
|
|
* @param string $ttn Номер ТТН |
25
|
|
|
* @return array |
26
|
|
|
*/ |
27
|
|
|
public function CheckPossibilityCreateReturn(string $ttn): array |
28
|
|
|
{ |
29
|
|
|
$this->calledMethod = 'CheckPossibilityCreateReturn'; |
30
|
|
|
|
31
|
|
|
$this->methodProperties['Number'] = $ttn; |
32
|
|
|
|
33
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Проверка возможности создания заявки на переадресацию отправки. |
38
|
|
|
* |
39
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8d29fc2-8512-11ec-8ced-005056b2dbe1 Возможность переадресации |
40
|
|
|
* |
41
|
|
|
* @param string $ttn Номер ТТН |
42
|
|
|
* @return array |
43
|
|
|
*/ |
44
|
|
|
public function checkPossibilityForRedirecting(string $ttn): array |
45
|
|
|
{ |
46
|
|
|
$this->calledMethod = 'checkPossibilityForRedirecting'; |
47
|
|
|
|
48
|
|
|
$this->methodProperties['Number'] = $ttn; |
49
|
|
|
|
50
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Получение списка причин возврата. |
55
|
|
|
* |
56
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7a6bacb-8512-11ec-8ced-005056b2dbe1 Список причин возврата |
57
|
|
|
* |
58
|
|
|
* @return array |
59
|
|
|
*/ |
60
|
|
|
public function getReturnReasons(): array |
61
|
|
|
{ |
62
|
|
|
$this->calledMethod = 'getReturnReasons'; |
63
|
|
|
|
64
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Получение списка подтипов причины возврата. |
69
|
|
|
* |
70
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список подтипов причины возврата |
71
|
|
|
* |
72
|
|
|
* @param string|null $ref Ref причины |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
public function getReturnReasonsSubtypes(?string $ref = null): array |
76
|
|
|
{ |
77
|
|
|
$this->calledMethod = 'getReturnReasonsSubtypes'; |
78
|
|
|
|
79
|
|
|
$this->methodProperties['ReasonRef'] = $ref ?: config('novaposhta.ref_return_reasons'); |
80
|
|
|
|
81
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Получение списка заявок на возврат. |
86
|
|
|
* |
87
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7cb69ee-8512-11ec-8ced-005056b2dbe1 Список заявок на возврат |
88
|
|
|
* |
89
|
|
|
* @since 2022-10-29 Проверено |
90
|
|
|
* |
91
|
|
|
* @return array |
92
|
|
|
*/ |
93
|
|
|
public function getReturnOrdersList(): array |
94
|
|
|
{ |
95
|
|
|
$this->calledMethod = 'getReturnOrdersList'; |
96
|
|
|
|
97
|
|
|
$this->addLimit(); |
98
|
|
|
$this->getPage(); |
99
|
|
|
$this->getDateBeginEnd(); |
100
|
|
|
|
101
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Получение списка заявок на переадресацию отправлений. |
106
|
|
|
* |
107
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a8faa2e6-8512-11ec-8ced-005056b2dbe1 Список заявок на переадресацию |
108
|
|
|
* |
109
|
|
|
* @return array |
110
|
|
|
*/ |
111
|
|
|
public function getRedirectionOrdersList(): array |
112
|
|
|
{ |
113
|
|
|
$this->calledMethod = 'getRedirectionOrdersList'; |
114
|
|
|
|
115
|
|
|
$this->methodProperties = null; |
116
|
|
|
|
117
|
|
|
$this->addLimit(); |
118
|
|
|
$this->getPage(); |
119
|
|
|
|
120
|
|
|
$this->getNumber(); |
121
|
|
|
$this->getDateBeginEnd(); |
122
|
|
|
|
123
|
|
|
if ($this->Ref) { |
124
|
|
|
$this->methodProperties['Ref'] = $this->Ref; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Создание заявки на возврат. |
132
|
|
|
* |
133
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a7fb4a3a-8512-11ec-8ced-005056b2dbe1 Возврат на адрес отправителя |
134
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/5a64f960-e7fa-11ec-a60f-48df37b921db Возврат на новый адрес отделения |
135
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/175baec3-8f0d-11ec-8ced-005056b2dbe1 Возврат на новый адрес по адресной доставке |
136
|
|
|
* |
137
|
|
|
* @param string $ttn Номер ТТН |
138
|
|
|
* @param string|null $ownerDocumentType Тип документа |
139
|
|
|
* @return array |
140
|
|
|
*/ |
141
|
|
|
public function save(string $ttn, ?string $ownerDocumentType = 'orderCargoReturn'): array |
142
|
|
|
{ |
143
|
|
|
$this->calledMethod = 'save'; |
144
|
|
|
|
145
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
146
|
|
|
|
147
|
|
|
$this->getPaymentMethod(); |
148
|
|
|
$this->getNote(); |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* ======================== |
152
|
|
|
* Тип оформления |
153
|
|
|
* ======================== |
154
|
|
|
*/ |
155
|
|
|
// Обычный возврат |
156
|
|
|
if ($ownerDocumentType == 'orderCargoReturn') { |
157
|
|
|
$this->methodProperties['OrderType'] = 'orderCargoReturn'; |
158
|
|
|
// При возврате нужно указать причину и подтип причины |
159
|
|
|
$this->getReason(); |
160
|
|
|
$this->getSubtypeReason(); |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Возврат/переадресация на адрес отправления. |
164
|
|
|
*/ |
165
|
|
|
$this->getReturnAddressRef(); |
166
|
|
|
|
167
|
|
|
if (! $this->Note) { |
168
|
|
|
$this->methodProperties['Note'] = config('novaposhta.redirecting_note'); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
// Переадресация |
173
|
|
|
if ($ownerDocumentType == 'orderRedirecting') { |
174
|
|
|
$this->methodProperties['OrderType'] = 'orderRedirecting'; |
175
|
|
|
$this->getPayerType(); |
176
|
|
|
$this->getCustomer(); |
177
|
|
|
$this->getServiceType(); |
178
|
|
|
$this->getRecipientData(); |
179
|
|
|
|
180
|
|
|
if (! $this->Note) { |
181
|
|
|
$this->methodProperties['Note'] = config('novaposhta.return_note'); |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
|
186
|
|
|
|
187
|
|
|
|
188
|
|
|
// Доп поля, если переадресация / возврат |
189
|
|
|
if ($ownerDocumentType == 'orderCargoReturn' || $ownerDocumentType == 'orderRedirecting') { |
190
|
|
|
/** |
191
|
|
|
* Возврат/переадресация на новый адрес отделения. |
192
|
|
|
*/ |
193
|
|
|
$this->getRecipientWarehouse(); |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Возврат/переадресация на новый адрес по адресной доставке. |
197
|
|
|
*/ |
198
|
|
|
$this->getRecipientSettlement(); |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Создание заявки на переадресацию. |
206
|
|
|
* |
207
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/98acb0f6-8f0b-11ec-8ced-005056b2dbe1 Создание заявки на переадресацию |
208
|
|
|
* |
209
|
|
|
* @param string $ttn Номер ТТН |
210
|
|
|
* @return array |
211
|
|
|
*/ |
212
|
|
|
public function saveRedirecting(string $ttn): array |
213
|
|
|
{ |
214
|
|
|
return $this->save($ttn, 'orderRedirecting'); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Удаление заявки на возврат, заявку об изменении данных или заявку переадресации. |
219
|
|
|
* |
220
|
|
|
* @since 2022-10-29 Проверено |
221
|
|
|
* |
222
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a85bb34b-8512-11ec-8ced-005056b2dbe1 Удаление заявки |
223
|
|
|
* |
224
|
|
|
* @param string $Ref Ref заявки |
225
|
|
|
* @return array |
226
|
|
|
*/ |
227
|
|
|
public function delete(string $Ref): array |
228
|
|
|
{ |
229
|
|
|
$this->calledMethod = 'delete'; |
230
|
|
|
|
231
|
|
|
$this->methodProperties['Ref'] = $Ref; |
232
|
|
|
|
233
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* Проверка продления хранения ТТН. |
238
|
|
|
* |
239
|
|
|
* @param string $ttn Номер ТТН |
240
|
|
|
* @return array |
241
|
|
|
*/ |
242
|
|
|
public function CheckPossibilityTermExtension(string $ttn): array |
243
|
|
|
{ |
244
|
|
|
$this->calledMethod = 'CheckPossibilityTermExtension'; |
245
|
|
|
|
246
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
247
|
|
|
|
248
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Проверка на изменения в ТТН. |
253
|
|
|
* |
254
|
|
|
* @see https://developers.novaposhta.ua/view/model/a7682c1a-8512-11ec-8ced-005056b2dbe1/method/a886b776-8512-11ec-8ced-005056b2dbe1 Проверка на изменения в накладной |
255
|
|
|
* |
256
|
|
|
* @param string $ttn Номер ТТН |
257
|
|
|
* @return array |
258
|
|
|
*/ |
259
|
|
|
public function CheckPossibilityChangeEW(string $ttn): array |
260
|
|
|
{ |
261
|
|
|
$this->calledMethod = 'CheckPossibilityChangeEW'; |
262
|
|
|
|
263
|
|
|
$this->methodProperties['IntDocNumber'] = $ttn; |
264
|
|
|
|
265
|
|
|
return $this->getResponse($this->model, $this->calledMethod, $this->methodProperties); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
|
269
|
|
|
} |
270
|
|
|
|