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