1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Daaner\NovaPoshta\Traits; |
4
|
|
|
|
5
|
|
|
trait AdditionalServiceProperty |
6
|
|
|
{ |
7
|
|
|
protected $Reason; |
8
|
|
|
protected $SubtypeReason; |
9
|
|
|
protected $ReturnAddressRef; |
10
|
|
|
protected $RecipientWarehouse; |
11
|
|
|
protected $RecipientSettlement; |
12
|
|
|
protected $Number; |
13
|
|
|
protected $Customer; |
14
|
|
|
protected $RecipientData; |
15
|
|
|
protected $StorageFinalDate; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @return void |
19
|
|
|
*/ |
20
|
|
|
public function getReason(): void |
21
|
|
|
{ |
22
|
|
|
$this->methodProperties['Reason'] = $this->Reason ?: config('novaposhta.ref_return_reasons'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Устанавливаем идентификатор причины возврата. |
27
|
|
|
* |
28
|
|
|
* @param string $Reason Ref возврата |
29
|
|
|
* @return $this |
30
|
|
|
*/ |
31
|
|
|
public function setReason(string $Reason): self |
32
|
|
|
{ |
33
|
|
|
$this->Reason = $Reason; |
34
|
|
|
|
35
|
|
|
return $this; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
public function getSubtypeReason(): void |
42
|
|
|
{ |
43
|
|
|
$this->methodProperties['SubtypeReason'] = $this->SubtypeReason ?: config('novaposhta.ref_return_reasons_sub'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Устанавливаем идентификатор подтипа причины возврата. |
48
|
|
|
* |
49
|
|
|
* @param string $SubtypeReason Ref подтипа возврата |
50
|
|
|
* @return $this |
51
|
|
|
*/ |
52
|
|
|
public function setSubtypeReason(string $SubtypeReason): self |
53
|
|
|
{ |
54
|
|
|
$this->SubtypeReason = $SubtypeReason; |
55
|
|
|
|
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return void |
61
|
|
|
*/ |
62
|
|
|
public function getReturnAddressRef(): void |
63
|
|
|
{ |
64
|
|
|
if ($this->ReturnAddressRef) { |
65
|
|
|
$this->methodProperties['ReturnAddressRef'] = $this->ReturnAddressRef; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Устанавливаем идентификатор адреса возврата. |
71
|
|
|
* Значение из метода CheckPossibilityCreateReturn. |
72
|
|
|
* |
73
|
|
|
* @param string $ReturnAddressRef Ref Адреса из доступных (CheckPossibilityCreateReturn) |
74
|
|
|
* @return $this |
75
|
|
|
*/ |
76
|
|
|
public function setReturnAddressRef(string $ReturnAddressRef): self |
77
|
|
|
{ |
78
|
|
|
$this->ReturnAddressRef = $ReturnAddressRef; |
79
|
|
|
|
80
|
|
|
// Очищаем данные предыдущих значений по возврату |
81
|
|
|
$this->RecipientWarehouse = null; |
82
|
|
|
$this->RecipientSettlement = null; |
83
|
|
|
|
84
|
|
|
return $this; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return void |
89
|
|
|
*/ |
90
|
|
|
public function getRecipientWarehouse(): void |
91
|
|
|
{ |
92
|
|
|
if ($this->RecipientWarehouse) { |
93
|
|
|
$this->methodProperties['RecipientWarehouse'] = $this->RecipientWarehouse; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
//Если другие идентификаторы не заполнены - оформляем возврат на отделение по умолчанию (из конфига) |
97
|
|
|
if (! $this->ReturnAddressRef && ! $this->RecipientWarehouse && ! $this->RecipientSettlement) { |
98
|
|
|
$this->methodProperties['RecipientWarehouse'] = config('novaposhta.ref_return_warehouse'); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Устанавливаем идентификатор возврата на новое отделение. |
104
|
|
|
* |
105
|
|
|
* @param string $RecipientWarehouse Ref отделения |
106
|
|
|
* @return $this |
107
|
|
|
*/ |
108
|
|
|
public function setRecipientWarehouse(string $RecipientWarehouse): self |
109
|
|
|
{ |
110
|
|
|
$this->RecipientWarehouse = $RecipientWarehouse; |
111
|
|
|
|
112
|
|
|
// Очищаем данные предыдущих значений по возврату |
113
|
|
|
$this->ReturnAddressRef = null; |
114
|
|
|
$this->RecipientSettlement = null; |
115
|
|
|
|
116
|
|
|
return $this; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return void |
121
|
|
|
*/ |
122
|
|
|
public function getRecipientSettlement(): void |
123
|
|
|
{ |
124
|
|
|
if ($this->RecipientSettlement) { |
125
|
|
|
$this->methodProperties['RecipientSettlement'] = $this->RecipientSettlement['settlement'] ?? ''; |
126
|
|
|
$this->methodProperties['RecipientSettlementStreet'] = $this->RecipientSettlement['street'] ?? ''; |
127
|
|
|
$this->methodProperties['BuildingNumber'] = $this->RecipientSettlement['building'] ?? ''; |
128
|
|
|
$this->methodProperties['NoteAddressRecipient'] = $this->RecipientSettlement['other'] ?? ''; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Устанавливаем идентификатор возврата на новое отделение. |
134
|
|
|
* |
135
|
|
|
* @param array $RecipientSettlement Массив адреса ['settlement', 'street', 'building', 'other'] |
136
|
|
|
* @return $this |
137
|
|
|
*/ |
138
|
|
|
public function setRecipientSettlement(array $RecipientSettlement): self |
139
|
|
|
{ |
140
|
|
|
$this->RecipientSettlement = $RecipientSettlement; |
141
|
|
|
|
142
|
|
|
// Очищаем данные предыдущих значений по возврату |
143
|
|
|
$this->ReturnAddressRef = null; |
144
|
|
|
$this->RecipientWarehouse = null; |
145
|
|
|
|
146
|
|
|
return $this; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return void |
151
|
|
|
*/ |
152
|
|
|
public function getNumber(): void |
153
|
|
|
{ |
154
|
|
|
if ($this->Number) { |
155
|
|
|
$this->methodProperties['Number'] = $this->Number; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* Устанавливаем номер заявки на переадресацию. |
161
|
|
|
* |
162
|
|
|
* @param string $Number Номер заявки ('102-00010160') |
163
|
|
|
* @return $this |
164
|
|
|
*/ |
165
|
|
|
public function setNumber(string $Number): self |
166
|
|
|
{ |
167
|
|
|
$this->Number = $Number; |
168
|
|
|
|
169
|
|
|
return $this; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @return void |
174
|
|
|
*/ |
175
|
|
|
public function getCustomer(): void |
176
|
|
|
{ |
177
|
|
|
$this->methodProperties['Customer'] = $this->Customer ?: 'Sender'; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
/** |
181
|
|
|
* Заказчик переадресации (получателю не разрешается изменять данные получателя). |
182
|
|
|
* |
183
|
|
|
* @param string $Customer тип |
184
|
|
|
* @return $this |
185
|
|
|
*/ |
186
|
|
|
public function setCustomer(string $Customer): self |
187
|
|
|
{ |
188
|
|
|
$this->Customer = $Customer; |
189
|
|
|
|
190
|
|
|
return $this; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* @return void |
195
|
|
|
*/ |
196
|
|
|
public function getRecipientData(): void |
197
|
|
|
{ |
198
|
|
|
if ($this->RecipientData) { |
199
|
|
|
if (isset($this->RecipientData['Recipient'])) { |
200
|
|
|
$this->methodProperties['Recipient'] = $this->RecipientData['Recipient']; |
201
|
|
|
} |
202
|
|
|
$this->methodProperties['RecipientContactName'] = $this->RecipientData['RecipientContactName'] ?? ''; |
203
|
|
|
$this->methodProperties['RecipientPhone'] = $this->RecipientData['RecipientPhone'] ?? ''; |
204
|
|
|
|
205
|
|
|
if (isset($this->methodProperties['SenderContactName'])) { |
206
|
|
|
$this->methodProperties['SenderContactName'] = $this->RecipientData['SenderContactName']; |
207
|
|
|
} |
208
|
|
|
if (isset($this->methodProperties['SenderPhone'])) { |
209
|
|
|
$this->methodProperties['SenderPhone'] = $this->RecipientData['SenderPhone']; |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
/** |
215
|
|
|
* Смена получателя. Игнорируется, если выполняет получатель. |
216
|
|
|
* |
217
|
|
|
* @param array $RecipientData тип |
218
|
|
|
* @return $this |
219
|
|
|
*/ |
220
|
|
|
public function changeRecipientData(array $RecipientData): self |
221
|
|
|
{ |
222
|
|
|
$this->RecipientData = $RecipientData; |
223
|
|
|
|
224
|
|
|
return $this; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* @return void |
229
|
|
|
*/ |
230
|
|
|
public function getStorageFinalDate(): void |
231
|
|
|
{ |
232
|
|
|
$this->methodProperties['StorageFinalDate'] = $this->StorageFinalDate; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Устанавливаем дату продления посылки. |
237
|
|
|
* |
238
|
|
|
* @param string $StorageFinalDate Ref возврата |
239
|
|
|
* @return $this |
240
|
|
|
*/ |
241
|
|
|
public function setStorageFinalDate(string $StorageFinalDate): self |
242
|
|
|
{ |
243
|
|
|
$this->StorageFinalDate = $StorageFinalDate; |
244
|
|
|
|
245
|
|
|
return $this; |
246
|
|
|
} |
247
|
|
|
} |
248
|
|
|
|