1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Iris\SaleWrapper; |
4
|
|
|
|
5
|
|
|
class Partner extends Base |
6
|
|
|
{ |
7
|
|
|
private $mappingClasses; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Gets an specific mapping classs |
11
|
|
|
* |
12
|
|
|
* @param string $mappingName |
13
|
|
|
*/ |
14
|
6 |
|
public function getMapping($mappingName) |
15
|
1 |
|
{ |
16
|
6 |
|
if (!$this->mappingClasses[$mappingName]) { |
17
|
3 |
|
$mappingClass = '\Iris\Mapping\\' . $mappingName; |
18
|
3 |
|
$this->mappingClasses[$mappingName] = $mappingClass::getInstance(); |
19
|
3 |
|
} |
20
|
|
|
|
21
|
6 |
|
return $this->mappingClasses[$mappingName]; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Set an specific mapping classs |
26
|
|
|
* |
27
|
|
|
* @param string $mappingName |
28
|
|
|
* @param $mappingClass |
29
|
|
|
* @return \Iris\SaleWrapper\Partner |
30
|
|
|
*/ |
31
|
3 |
|
public function setMapping($mappingName, $mappingClass) |
32
|
|
|
{ |
33
|
3 |
|
$this->mappingClasses[$mappingName] = $mappingClass; |
34
|
3 |
|
return $this; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Gets Stock service. |
39
|
|
|
* @return \Iris\Interfaces\Stock |
40
|
|
|
*/ |
41
|
2 |
|
public function getStockService() |
42
|
|
|
{ |
43
|
2 |
|
return $this->getManager()->getService(\Iris\Factory::STOCK); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Gets Stock service. |
48
|
|
|
* @return \Iris\Interfaces\Catalog |
49
|
|
|
*/ |
50
|
2 |
|
public function getCatalogService() |
51
|
|
|
{ |
52
|
2 |
|
return $this->getManager()->getService(\Iris\Factory::CATALOG); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
//order |
56
|
|
|
/** |
57
|
|
|
* Send order to venture |
58
|
|
|
* |
59
|
|
|
* @param \Iris\Transfer\Sales\Order $order, |
|
|
|
|
60
|
|
|
* @param string $ventureCode |
|
|
|
|
61
|
|
|
* @return bool |
62
|
|
|
* @throws \Iris\Exceptions\OrderNotFound |
63
|
|
|
* @throws \Iris\Exceptions\RetryMessage |
64
|
|
|
*/ |
65
|
1 |
|
public function createOrderOnVenture( |
66
|
|
|
\Iris\Transfer\Sales\Order $order, |
67
|
|
|
\Iris\Transfer\Venture $venture |
68
|
|
|
) { |
69
|
1 |
|
return $this->getPartnerApiClient() |
70
|
1 |
|
->createOrderOnVenture($order, $venture->getVentureCode()); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* As a Partner I expect to receive a reserve confirmation and quantity of stock for SalesOrderItem to remove its |
75
|
|
|
* reserve. |
76
|
|
|
* |
77
|
|
|
* @param integer $orderNr Partner order number |
78
|
|
|
* @return void |
79
|
|
|
* @throws \Iris\Exceptions\UnableToDropReserve |
80
|
|
|
*/ |
81
|
1 |
|
public function dropReserve($orderNr) |
82
|
|
|
{ |
83
|
1 |
|
$this->getOrderService()->dropReserve($orderNr); |
84
|
1 |
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Send a confirmation that the order is paid to the venture |
88
|
|
|
* |
89
|
|
|
* @param Iris\Transfer\Sales\Order $order |
90
|
|
|
* @param Iris\Transfer\Venture $venture |
91
|
|
|
* @return bool |
92
|
|
|
* @throws \Iris\Exceptions\OrderNotFound |
93
|
|
|
* @throws \Iris\Exceptions\RetryMessage |
94
|
|
|
*/ |
95
|
1 |
|
public function confirmOrderPaidOnVenture( |
96
|
|
|
\Iris\Transfer\Sales\Order $order, |
97
|
|
|
\Iris\Transfer\Venture $venture |
98
|
|
|
) { |
99
|
1 |
|
return $this->getPartnerApiClient() |
100
|
1 |
|
->confirmPaymentOnVenture( |
101
|
1 |
|
$order->getOrderNr(), |
102
|
1 |
|
$venture->getVentureCode() |
103
|
1 |
|
); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Sends a order cancel request to venture |
108
|
|
|
* |
109
|
|
|
* @param Iris\Transfer\Sales\Order $order |
110
|
|
|
* @param Iris\Transfer\Venture $venture |
111
|
|
|
* @return bool |
112
|
|
|
* @throws \Iris\Exceptions\OrderNotFound |
113
|
|
|
* @throws \Iris\Exceptions\RetryMessage |
114
|
|
|
*/ |
115
|
1 |
|
public function cancelOrderOnVenture( |
116
|
|
|
\Iris\Transfer\Sales\Order $order, |
117
|
|
|
\Iris\Transfer\Venture $venture |
118
|
|
|
) { |
119
|
1 |
|
return $this->getPartnerApiClient() |
120
|
1 |
|
->cancelOrderOnVenture( |
121
|
1 |
|
$order->getOrderNr(), |
122
|
1 |
|
$venture->getVentureCode() |
123
|
1 |
|
); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* As a Partner I want to receive a Venture Order Number to bind it with my Order Number. |
128
|
|
|
* |
129
|
|
|
* @param string $orderNr Order number. |
130
|
|
|
* @param string $ventureCode Venture code |
131
|
|
|
* @param string $ventureOrderNr Venture Order Number |
132
|
|
|
* @return void |
133
|
|
|
*/ |
134
|
|
|
public function bindVentureOrder($orderNr, $ventureCode, $ventureOrderNr) |
135
|
|
|
{ |
136
|
|
|
$this->getOrderService() |
137
|
|
|
->bindPartnerOrderWithVentureOrder( |
138
|
|
|
$orderNr, |
139
|
|
|
$ventureCode, |
140
|
|
|
$ventureOrderNr |
141
|
|
|
); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
//post payment |
145
|
|
|
/** |
146
|
|
|
* As a Partner I expect to receive a shipped notification from Venture. |
147
|
|
|
* |
148
|
|
|
* @param array $postPaymentData |
149
|
|
|
* @param string $ventureCode |
150
|
|
|
* @return array Returns an array as: |
151
|
|
|
* |
152
|
|
|
* [ |
153
|
|
|
* 'order_data' = [ |
154
|
|
|
* 'order_number' => '00000057', |
155
|
|
|
* 'items' => [ |
156
|
|
|
* [53 => [ |
157
|
|
|
* 'status' => true |
158
|
|
|
* ]], |
159
|
|
|
* [54 => [ |
160
|
|
|
* 'status' => false, |
161
|
|
|
* 'message' => 'Some error' |
162
|
|
|
* ] |
163
|
|
|
* ] |
164
|
|
|
* ] |
165
|
|
|
* ] |
166
|
|
|
*/ |
167
|
1 |
|
public function setOrderStatusToShippedFromVenture( |
168
|
|
|
array $postPaymentData, |
169
|
|
|
$ventureCode |
170
|
|
|
) { |
171
|
1 |
|
$postPaymentCollection = $this->getMapping('ShippedFromVenture') |
172
|
1 |
|
->assign($postPaymentData); |
173
|
|
|
|
174
|
1 |
|
foreach ($postPaymentCollection as $postPayment) { |
175
|
1 |
|
if (!$postPayment->getTrackingCode()) { |
176
|
1 |
|
$postPayment->setTrackingCode(md5($postPayment->getTrackingUrl())); |
177
|
1 |
|
} |
178
|
1 |
|
} |
179
|
|
|
|
180
|
1 |
|
return $this->getOrderService() |
181
|
1 |
|
->shippedFromVenture($postPaymentCollection, $ventureCode); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @param array $postPaymentData |
186
|
|
|
* @param string $ventureCode |
187
|
|
|
* @return array |
188
|
|
|
*/ |
189
|
1 |
|
public function cancelOrderFromVenture( |
190
|
|
|
array $postPaymentData, |
191
|
|
|
$ventureCode |
192
|
|
|
) { |
193
|
1 |
|
$postPaymentCollection = $this->getMapping('CancelFromVenture') |
194
|
1 |
|
->assign($postPaymentData); |
195
|
|
|
|
196
|
1 |
|
return $this->getOrderService() |
197
|
1 |
|
->cancelorderFromVenture($postPaymentCollection, $ventureCode); |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* As a Partner I expect to receive a delivered notification from Venture. |
202
|
|
|
* |
203
|
|
|
* @param array $postPaymentData |
204
|
|
|
* @param string $ventureCode |
205
|
|
|
* @return array Returns an array as: |
206
|
|
|
* |
207
|
|
|
* [ |
208
|
|
|
* 'order_data' = [ |
209
|
|
|
* 'order_number' => '00000057', |
210
|
|
|
* 'items' => [ |
211
|
|
|
* [53 => [ |
212
|
|
|
* 'status' => true |
213
|
|
|
* ]], |
214
|
|
|
* [54 => [ |
215
|
|
|
* 'status' => false, |
216
|
|
|
* 'message' => 'Some error' |
217
|
|
|
* ] |
218
|
|
|
* ] |
219
|
|
|
* ] |
220
|
|
|
* ] |
221
|
|
|
*/ |
222
|
1 |
|
public function setOrderStatusToDeliveredFromVenture( |
223
|
|
|
array $postPaymentData, |
224
|
|
|
$ventureCode |
225
|
|
|
) { |
226
|
1 |
|
$postPaymentCollection = $this->getMapping('DeliveredFromVenture') |
227
|
1 |
|
->assign($postPaymentData); |
228
|
|
|
|
229
|
1 |
|
return $this->getOrderService() |
230
|
1 |
|
->deliveredFromVenture($postPaymentCollection, $ventureCode); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* As a Partner I expect to receive a delivery failed notification from Venture. |
235
|
|
|
* @param array $orderData |
|
|
|
|
236
|
|
|
* @param string $ventureCode |
237
|
|
|
* @return array Returns an array as: |
238
|
|
|
* |
239
|
|
|
* [ |
240
|
|
|
* 'order_data' = [ |
241
|
|
|
* 'order_number' => '00000057', |
242
|
|
|
* 'items' => [ |
243
|
|
|
* [53 => [ |
244
|
|
|
* 'status' => true |
245
|
|
|
* ]], |
246
|
|
|
* [54 => [ |
247
|
|
|
* 'status' => false, |
248
|
|
|
* 'message' => 'Some error' |
249
|
|
|
* ] |
250
|
|
|
* ] |
251
|
|
|
* ] |
252
|
|
|
* ] |
253
|
|
|
*/ |
254
|
1 |
|
public function setOrderStatusToDeliveryFailedFromVenture( |
255
|
|
|
array $postPaymentData, |
256
|
|
|
$ventureCode |
257
|
|
|
) { |
258
|
1 |
|
$postPaymentCollection = $this->getMapping('DeliveryFailedFromVenture') |
259
|
1 |
|
->assign($postPaymentData); |
260
|
|
|
|
261
|
1 |
|
return $this->getOrderService() |
262
|
1 |
|
->deliveryFailedFromVenture($postPaymentCollection, $ventureCode); |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
//products |
266
|
|
|
/** |
267
|
|
|
* Create products from venture |
268
|
|
|
* |
269
|
|
|
* @param array $productsData |
270
|
|
|
* @param string $ventureCode |
271
|
|
|
* @return Iris\Transfer\Catalog\ConfigCollection |
272
|
|
|
*/ |
273
|
|
|
public function createProductsFromVenture(array $productsData, $ventureCode) |
274
|
|
|
{ |
275
|
|
|
$configCollection = $this->getMapping('ConfigCollection') |
276
|
|
|
->assign($productsData); |
277
|
|
|
|
278
|
|
|
return $this->getCatalogService()->createProducts($configCollection, $ventureCode); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Send product creation status to venture |
283
|
|
|
* |
284
|
|
|
* @param \Iris\Transfer\Catalog\ConfigCollection $configCollection |
285
|
|
|
* @param \Iris\Transfer\Venture $venture |
286
|
|
|
* @return void |
287
|
|
|
*/ |
288
|
|
|
public function sendProductCreationConfirmationToVenture( |
289
|
|
|
\Iris\Transfer\Catalog\ConfigCollection $configCollection, |
290
|
|
|
\Iris\Transfer\Venture $venture |
291
|
|
|
) { |
292
|
|
|
$productsData = $this->getMapping('ConfigCollection') |
293
|
|
|
->map($configCollection); |
294
|
|
|
|
295
|
|
|
$this->getPartnerApiClient() |
296
|
|
|
->sendProductCreationConfirmationToVenture( |
297
|
|
|
$productsData, |
298
|
|
|
$venture->getVentureCode() |
299
|
|
|
); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
/** |
303
|
|
|
* Update products information from venture |
304
|
|
|
* |
305
|
|
|
* @param array $productsData |
306
|
|
|
* @param string $ventureCode |
307
|
|
|
* @return void |
308
|
|
|
*/ |
309
|
|
|
public function updateProductsFromVenture(array $productsData, $ventureCode) |
310
|
|
|
{ |
311
|
|
|
$configCollection = $this->getMapping('ConfigCollection') |
312
|
|
|
->assign($productsData); |
313
|
|
|
|
314
|
|
|
$this->getCatalogService()->updateProducts( |
315
|
|
|
$configCollection, |
316
|
|
|
$ventureCode |
317
|
|
|
); |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Update price in batch based on the config collection information sent by the venture |
322
|
|
|
* |
323
|
|
|
* @param array $productsData |
324
|
|
|
* @param string $ventureCode |
325
|
|
|
* @return void |
326
|
|
|
*/ |
327
|
1 |
|
public function updatePriceFromVenture(array $productsData, $ventureCode) |
328
|
|
|
{ |
329
|
1 |
|
$configCollection = $this->getMapping('Price') |
330
|
1 |
|
->assign($productsData); |
331
|
|
|
|
332
|
1 |
|
$this->getCatalogService()->updatePrice( |
333
|
1 |
|
$configCollection, |
334
|
|
|
$ventureCode |
335
|
1 |
|
); |
336
|
1 |
|
} |
337
|
|
|
|
338
|
|
|
/** |
339
|
|
|
* Update the stock of a product from the venture |
340
|
|
|
* |
341
|
|
|
* @param array $productsData |
342
|
|
|
* @param string $ventureCode |
343
|
|
|
* @return bool |
344
|
|
|
*/ |
345
|
1 |
|
public function updateStockFromVenture(array $productsData, $ventureCode) |
|
|
|
|
346
|
|
|
{ |
347
|
1 |
|
$simpleCollection = $this->getMapping('Stock') |
348
|
1 |
|
->assign($productsData); |
349
|
|
|
|
350
|
1 |
|
return $this->getStockService()->update($simpleCollection); |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Update product images from venture |
355
|
|
|
* |
356
|
|
|
* @param array $productsData |
357
|
|
|
* @param string $ventureCode |
358
|
|
|
* @return void |
359
|
|
|
*/ |
360
|
|
|
public function updateProductImagesFromVenture(array $productsData, $ventureCode) |
361
|
|
|
{ |
362
|
|
|
$configCollection = $this->getMapping('Image')->assign($productsData); |
363
|
|
|
|
364
|
|
|
return $this->getCatalogService()->updateImages( |
365
|
|
|
$configCollection, |
366
|
|
|
$ventureCode |
367
|
|
|
); |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.