1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Iris\SaleWrapper; |
4
|
|
|
|
5
|
|
|
class Partner extends Base implements PartnerInterface |
6
|
|
|
{ |
7
|
|
|
private $mappingClasses; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* {@inheritdoc} |
11
|
|
|
*/ |
12
|
|
|
public function getName() |
13
|
|
|
{ |
14
|
4 |
|
return 'partner'; |
15
|
|
|
} |
16
|
4 |
|
|
17
|
|
|
/** |
18
|
|
|
* Gets Venture service. |
19
|
|
|
* @return \Iris\Interfaces\IrisVenture |
20
|
|
|
*/ |
21
|
|
|
public function getVentureService() |
22
|
|
|
{ |
23
|
3 |
|
return $this->getManager()->getService(\Iris\Factory::VENTURE); |
24
|
|
|
} |
25
|
3 |
|
|
26
|
|
|
/** |
27
|
|
|
* Gets Stock service. |
28
|
|
|
* @return \Iris\Interfaces\Stock |
29
|
|
|
*/ |
30
|
|
|
public function getStockService() |
31
|
|
|
{ |
32
|
2 |
|
return $this->getManager()->getService(\Iris\Factory::STOCK); |
33
|
|
|
} |
34
|
2 |
|
|
35
|
|
|
/** |
36
|
|
|
* Gets Stock service. |
37
|
|
|
* @return \Iris\Interfaces\Catalog |
38
|
|
|
*/ |
39
|
|
|
public function getCatalogService() |
40
|
2 |
|
{ |
41
|
|
|
return $this->getManager()->getService(\Iris\Factory::CATALOG); |
42
|
2 |
|
} |
43
|
2 |
|
|
44
|
2 |
|
|
45
|
|
|
//order |
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
1 |
|
public function isVentureItem(\Iris\Transfer\Sales\Order\Item $item) |
50
|
|
|
{ |
51
|
1 |
|
$irisVenture = $this->getVentureService() |
52
|
|
|
->getIrisVentureBySalesOrderId($item->getFkSalesOrder()); |
53
|
1 |
|
|
54
|
1 |
|
return ($irisVenture instanceof \Iris\Transfer\Venture); |
55
|
1 |
|
} |
56
|
1 |
|
|
57
|
|
|
/** |
58
|
1 |
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
1 |
|
public function sendOrderToVenture( |
61
|
1 |
|
\Iris\Transfer\Sales\Order $order, |
62
|
|
|
$ventureCode |
63
|
|
|
) { |
64
|
|
|
return $this->getPartnerApiClient() |
65
|
|
|
->createOrderOnVenture($order, $ventureCode); |
|
|
|
|
66
|
1 |
|
} |
67
|
|
|
|
68
|
1 |
|
/** |
69
|
1 |
|
* {@inheritdoc} |
70
|
|
|
*/ |
71
|
|
|
public function dropReserveAndUpdateStock( |
72
|
|
|
array $orderData, |
73
|
|
|
$ventureCode |
74
|
|
|
) { |
75
|
1 |
|
$order = $this->getMapping('Order')->assign($orderItems); |
|
|
|
|
76
|
|
|
$configCollection = $this->getMapping('ConfigCollection') |
77
|
1 |
|
->assgin($orderItems); |
78
|
1 |
|
|
79
|
|
|
$this->getStockService()->dropReserve($order->getItemCollection()); |
|
|
|
|
80
|
|
|
$this->updateStockFromVenture($configCollection); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
4 |
|
* {@inheritdoc} |
85
|
|
|
*/ |
86
|
4 |
|
public function confirmOrderPaidOnVenture( |
87
|
|
|
\Iris\Transfer\Sales\Order $order, |
88
|
|
|
\Iris\Transfer\Venture $venture |
89
|
|
|
) { |
90
|
|
|
return $this->getPartnerApiClient() |
91
|
|
|
->confirmPaymentOnVenture( |
92
|
1 |
|
$venture->getVentureCode(), |
93
|
|
|
$order->getOrderNr() |
94
|
1 |
|
); |
95
|
|
|
} |
96
|
1 |
|
|
97
|
1 |
|
/** |
98
|
|
|
* {@inheritdoc} |
99
|
|
|
*/ |
100
|
|
|
public function confirmOrderFromVenture(array $orderData, $ventureCode) |
101
|
|
|
{ |
102
|
|
|
$order = $this->getMapping('Order')->assign($orderData); |
103
|
1 |
|
$this->getOrderService()->confirmOrderFromVenture($order, $ventureCode); |
|
|
|
|
104
|
|
|
} |
105
|
1 |
|
|
106
|
1 |
|
/** |
107
|
|
|
* {@inheritdoc} |
108
|
|
|
*/ |
109
|
|
|
public function cancelOrderOnVenture( |
110
|
|
|
\Iris\Transfer\Sales\Order $order, |
111
|
|
|
\Iris\Transfer\Venture $venture |
112
|
1 |
|
) { |
113
|
|
|
return $this->getPartnerApiClient() |
114
|
1 |
|
->cancelOrderOnVenture( |
115
|
1 |
|
$venture->getVentureCode(), |
116
|
|
|
$order->getOrderNr() |
117
|
|
|
); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
1 |
|
* {@inheritdoc} |
122
|
|
|
*/ |
123
|
1 |
|
public function bindVentureOrder($orderNr, $ventureCode, $ventureorderNr) |
124
|
1 |
|
{ |
125
|
1 |
|
$this->getOrderService() |
126
|
1 |
|
->bindPartnerOrderWithVentureOrder( |
127
|
1 |
|
$orderNr, |
128
|
1 |
|
$ventureCode, |
129
|
1 |
|
$ventureOrderNr |
|
|
|
|
130
|
|
|
); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Gets an specific mapping classs |
135
|
2 |
|
* |
136
|
|
|
* @param string $mappingName |
137
|
2 |
|
*/ |
138
|
|
|
public function getMapping($mappingName) |
139
|
|
|
{ |
140
|
|
|
if (!$this->mappingClasses[$mappingName]) { |
141
|
|
|
$mappingClass = '\Iris\Mapping\\' . $mappingName; |
142
|
|
|
$this->mappingClasses[$mappingName] = $mappingClass::getInstance(); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
return $this->mappingClasses[$mappingName]; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Set an specific mapping classs |
150
|
|
|
* |
151
|
|
|
* @param string $mappingName |
152
|
|
|
* @param $mappingClass |
153
|
|
|
* @return \Iris\SaleWrapper\Partner |
154
|
|
|
*/ |
155
|
|
|
public function setMapping($mappingName, $mappingClass) |
156
|
|
|
{ |
157
|
|
|
$this->mappingClasses[$mappingName] = $mappingClass; |
158
|
|
|
return $this; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
//post payment |
162
|
|
|
/** |
163
|
|
|
* {@inheritdoc} |
164
|
|
|
*/ |
165
|
|
|
public function setOrderStatusToShippedFromVenture( |
166
|
|
|
array $postPaymentData, |
167
|
|
|
$ventureCode |
168
|
|
|
) { |
169
|
|
|
$postPaymentCollection = $this->getMapping('PostPayment') |
170
|
|
|
->assign($postPaymentData); |
171
|
|
|
|
172
|
|
|
foreach ($postPaymentCollection as $postPayment) { |
173
|
|
|
if (!$postPayment->getTrackingCode()) { |
174
|
|
|
$postPayment->setTrackingCode(md5($postPayment->getTrackingUrl())); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
return $this->getOrderService()->shippedFromVenture($postPaymentCollection); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* {@inheritdoc} |
183
|
|
|
*/ |
184
|
|
|
public function cancelOrderFromVenture( |
185
|
|
|
array $postPaymentData, |
186
|
|
|
$ventureCode |
187
|
|
|
) { |
188
|
|
|
$postPaymentCollection = $this->getMapping('PostPayment') |
189
|
|
|
->assign($postPaymentData); |
190
|
|
|
|
191
|
|
|
return $this->getOrderService() |
192
|
|
|
->deliveredFromVenture($postPaymentCollection, $ventureCode); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* {@inheritdoc} |
197
|
|
|
*/ |
198
|
|
|
public function setOrderStatusToDeliveredFromVenture( |
199
|
|
|
array $postPaymentData, |
200
|
|
|
$ventureCode |
201
|
|
|
) { |
202
|
|
|
$postPaymentCollection = $this->getMapping('PostPayment') |
203
|
|
|
->assign($postPaymentData); |
204
|
|
|
|
205
|
|
|
return $this->getOrderService() |
206
|
|
|
->deliveredFromVenture($postPaymentCollection, $ventureCode); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* {@inheritdoc} |
211
|
|
|
*/ |
212
|
|
|
public function setOrderStatusToDeliveryFailedFromVenture( |
213
|
|
|
array $postPaymentData, |
214
|
|
|
$ventureCode |
215
|
|
|
) { |
216
|
|
|
$postPaymentCollection = $this->getMapping('PostPayment') |
217
|
|
|
->assign($postPaymentData); |
218
|
|
|
|
219
|
|
|
return $this->getOrderService() |
220
|
|
|
->deliveryFailedFromVenture($postPaymentCollection, $ventureCode); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
//products |
224
|
|
|
/** |
225
|
|
|
* {@inheritdoc} |
226
|
|
|
*/ |
227
|
|
|
public function updatePriceFromVenture(array $productsData, $ventureCode) |
228
|
|
|
{ |
229
|
|
|
$configCollection = $this->getMapping('Price') |
230
|
|
|
->assign($productsData); |
231
|
|
|
|
232
|
|
|
return $this->getCatalogService()->updatePrice( |
233
|
|
|
$configCollection, |
234
|
|
|
$ventureCode |
|
|
|
|
235
|
|
|
); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* {@inheritdoc} |
240
|
|
|
*/ |
241
|
|
|
public function updateStockFromVenture(array $productsData, $ventureCode) |
242
|
|
|
{ |
243
|
|
|
$simpleCollection = $this->getMapping('Stock') |
244
|
|
|
->assign($productsData); |
245
|
|
|
|
246
|
|
|
return $this->getStockService()->updateAbsoluteStock($simpleCollection); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* {@inheritdoc} |
251
|
|
|
*/ |
252
|
|
|
public function createProductsFromVenture(array $productsData, $ventureCode) |
253
|
|
|
{ |
254
|
|
|
$configCollection = $this->getMapping('ConfigCollection') |
255
|
|
|
->assign($productsData); |
256
|
|
|
|
257
|
|
|
return $this->getCatalogService()->createProducts($configCollection, $ventureCode); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* {@inheritdoc} |
262
|
|
|
*/ |
263
|
|
|
public function sendProductCreationConfirmationToVenture( |
264
|
|
|
\Iris\Transfer\Catalog\ConfigCollection $configCollection, |
265
|
|
|
\Iris\Transfer\Venture $venture |
266
|
|
|
) { |
267
|
|
|
$productsData = $this->getMapping('ConfigCollection') |
268
|
|
|
->map($configCollection); |
269
|
|
|
|
270
|
|
|
$this->getPartnerApiClient() |
271
|
|
|
->sendProductCreationConfirmationToVenture( |
272
|
|
|
$productsData, |
273
|
|
|
$venture->getVentureCode() |
274
|
|
|
); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* {@inheritdoc} |
279
|
|
|
*/ |
280
|
|
|
public function updateProductsFromVenture(array $productsData, $ventureCode) |
281
|
|
|
{ |
282
|
|
|
$configCollection = $this->getMapping('ConfigCollection') |
283
|
|
|
->assign($productsData); |
284
|
|
|
|
285
|
|
|
return $this->getCatalogService()->updateProducts($configCollection, $ventureCode); |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* {@inheritdoc} |
290
|
|
|
*/ |
291
|
|
|
public function updateProductImagesFromVenture(array $productsData, $ventureCode) |
292
|
|
|
{ |
293
|
|
|
$config = $this->getMapping('Image')->assign($productsData); |
294
|
|
|
|
295
|
|
|
return $this->getCatalogService()->updateImages( |
296
|
|
|
$config, |
297
|
|
|
$ventureCode |
298
|
|
|
); |
299
|
|
|
} |
300
|
|
|
|
301
|
|
|
/** |
302
|
|
|
* {@inheritdoc} |
303
|
|
|
*/ |
304
|
|
|
public function isInvalidOrder(\Iris\Transfer\Sales\Order $order) |
305
|
|
|
{ |
306
|
|
|
return $this->getOrderService()->isInvalidOrder($order); |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: