1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Iris\SaleWrapper; |
4
|
|
|
|
5
|
|
|
use \Iris\Mapping\Order; |
6
|
|
|
|
7
|
|
|
class Partner extends Base implements PartnerInterface |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Gets Venture service. |
11
|
|
|
* @return Iris\Interfaces\IrisVenture |
12
|
|
|
*/ |
13
|
|
|
public function getVentureService() |
14
|
4 |
|
{ |
15
|
|
|
return $this->getManager()->getService(\Iris\Factory::VENTURE); |
16
|
4 |
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Gets Stock service. |
20
|
|
|
* @return Iris\Interfaces\Stock |
21
|
|
|
*/ |
22
|
|
|
public function getStockService() |
23
|
3 |
|
{ |
24
|
|
|
return $this->getManager()->getService(\Iris\Factory::STOCK); |
25
|
3 |
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Gets Stock service. |
29
|
|
|
* @return Iris\Interfaces\Catalog |
30
|
|
|
*/ |
31
|
|
|
public function getCatalogService() |
32
|
2 |
|
{ |
33
|
|
|
return $this->getManager()->getService(\Iris\Factory::CATALOG); |
34
|
2 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function dropReserveAndUpdateStock( |
40
|
2 |
|
\Iris\Transfer\Sales\Order\Item $orderItem, |
41
|
|
|
\Iris\Transfer\Catalog\Simple $product |
42
|
2 |
|
) { |
43
|
2 |
|
$this->getStockService()->dropReserve($orderItem); |
|
|
|
|
44
|
2 |
|
$this->updateStockFromVenture($product); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* {@inheritdoc} |
49
|
1 |
|
*/ |
50
|
|
|
public function isVentureItem(\Iris\Transfer\Sales\Order\Item $item) |
51
|
1 |
|
{ |
52
|
|
|
$irisVenture = $this->getVentureService() |
|
|
|
|
53
|
1 |
|
->getIrisVentureBySalesOrderId($item->getFkSalesOrder()); |
54
|
1 |
|
|
55
|
1 |
|
return ($irisVenture instanceof \Iris\Transfer\Venture); |
56
|
1 |
|
} |
57
|
|
|
|
58
|
1 |
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
1 |
|
*/ |
61
|
1 |
|
public function sendOrderToVenture( |
62
|
|
|
\Iris\Transfer\Sales\Order $order, |
63
|
|
|
\Iris\Transfer\Venture $venture |
64
|
|
|
) { |
65
|
|
|
$mappedOrder = $this->getOrderMapping()->map($order); |
66
|
1 |
|
|
67
|
|
|
return $this->getPartnerApiClient() |
68
|
1 |
|
->createOrderOnVenture($venture, $mappedOrder); |
|
|
|
|
69
|
1 |
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function confirmOrderPaidOnVenture( |
75
|
1 |
|
\Iris\Transfer\Sales\Order $order, |
76
|
|
|
\Iris\Transfer\Venture $venture |
77
|
1 |
|
) { |
78
|
1 |
|
return $this->getPartnerApiClient() |
79
|
|
|
->confirmPaymentOnVenture( |
80
|
|
|
$venture->getVentureCode(), |
81
|
|
|
$order->getOrderNr() |
82
|
|
|
); |
83
|
|
|
} |
84
|
4 |
|
|
85
|
|
|
/** |
86
|
4 |
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function cancelOrderOnVenture( |
89
|
|
|
\Iris\Transfer\Sales\Order $order, |
90
|
|
|
\Iris\Transfer\Venture $venture |
91
|
|
|
) { |
92
|
1 |
|
return $this->getPartnerApiClient() |
93
|
|
|
->cancelOrderOnVenture( |
94
|
1 |
|
$venture->getVentureCode(), |
95
|
|
|
$order->getOrderNr() |
96
|
1 |
|
); |
97
|
1 |
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* {@inheritdoc} |
101
|
|
|
*/ |
102
|
|
|
public function cancelOrderFromVenture($orderNr, $ventureCode) { |
103
|
1 |
|
|
104
|
|
|
$order = $this->getOrderService() |
105
|
1 |
|
->getOrderByOrderNumberAndVentureCode($orderNr, $ventureCode); |
106
|
1 |
|
|
107
|
|
|
$this->getOrderService()->cancelOrderFromVenture($order); |
108
|
|
|
return ['order_number' => $order->getOrderNr()]; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
1 |
|
* {@inheritdoc} |
113
|
|
|
*/ |
114
|
1 |
|
public function getName() |
115
|
1 |
|
{ |
116
|
|
|
return 'partner'; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* {@inheritdoc} |
121
|
1 |
|
*/ |
122
|
|
|
public function setOrderStatusToShippedFromVenture(array $orderData) |
123
|
1 |
|
{ |
124
|
1 |
|
$order = \Iris\Mapping\Order::assign($orderData); |
125
|
1 |
|
|
126
|
1 |
|
foreach ($order->getItemCollection() as $item) { |
127
|
1 |
|
if (!$item->getTrackingCode()) { |
128
|
1 |
|
$item->setTrackingCode(md5($item->getTrackingUrl())); |
129
|
1 |
|
} |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
return $this->getOrderService()->shippedByVenture($salesOrder); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
|
135
|
2 |
|
/** |
136
|
|
|
* {@inheritdoc} |
137
|
2 |
|
*/ |
138
|
|
|
public function setOrderStatusToDeliveredFromVenture(array $orderData) |
139
|
|
|
{ |
140
|
|
|
$order = \Iris\Mapping\Order::assign($orderData); |
141
|
|
|
return $this->getOrderService()->deliveredByVenture($order, $venture); |
|
|
|
|
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* {@inheritdoc} |
146
|
|
|
*/ |
147
|
|
|
public function setOrderStatusToDeliveryFailedFromVenture(array $orderData) |
148
|
|
|
{ |
149
|
|
|
$order = \Iris\Mapping\Order::assign($orderData); |
150
|
|
|
return $this->getOrderService() |
151
|
|
|
->deliveryFailedByVenture($order, $venture); |
|
|
|
|
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* {@inheritdoc} |
156
|
|
|
*/ |
157
|
|
|
public function isInvalidOrder(\Iris\Transfer\Sales\Order $order) |
158
|
|
|
{ |
159
|
|
|
return $this->getOrderService()->isInvalidOrder($order); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* {@inheritdoc} |
164
|
|
|
*/ |
165
|
|
|
public function bindVentureOrder($orderNumber, $ventureCode, $ventureOrderNumber) |
166
|
|
|
{ |
167
|
|
|
$venture = $this->getVentureService()->findByCode($ventureCode); |
|
|
|
|
168
|
|
|
|
169
|
|
|
$order = $this->getOrderService() |
|
|
|
|
170
|
|
|
->getOrderByOrderNumberAndVentureCode( |
171
|
|
|
$orderNumber, |
172
|
|
|
$ventureCode |
173
|
|
|
); |
174
|
|
|
|
175
|
|
|
$this->getVentureService() |
|
|
|
|
176
|
|
|
->bindPartnerOrderWithVentureOrder( |
177
|
|
|
$orderNumber, |
178
|
|
|
$ventureCode, |
179
|
|
|
$ventureOrderNumber |
180
|
|
|
); |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* {@inheritdoc} |
185
|
|
|
*/ |
186
|
|
|
public function updatePriceFromVenture(array $productsData, $ventureCode) |
187
|
|
|
{ |
188
|
|
|
$configCollection = \Iris\Mapping\ConfigCollection::assign($productsData); |
189
|
|
|
return $this->getCatalogService()->updatePrice($configCollection); |
|
|
|
|
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* {@inheritdoc} |
194
|
|
|
*/ |
195
|
|
|
public function updateStockFromVenture(array $productsData, $ventureCode) |
196
|
|
|
{ |
197
|
|
|
$configCollection = \Iris\Mapping\ConfigCollection::assign($productsData); |
198
|
|
|
return $this->getStockService() |
|
|
|
|
199
|
|
|
->updateAbsoluteStock($configCollection); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* {@inheritdoc} |
204
|
|
|
*/ |
205
|
|
|
public function createProductsFromVenture(array $productsData, $ventureCode) |
206
|
|
|
{ |
207
|
|
|
$configCollection = \Iris\Mapping\ConfigCollection::assign($productsData); |
|
|
|
|
208
|
|
|
//@todo |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* {@inheritdoc} |
213
|
|
|
*/ |
214
|
|
|
public function updateProductsFromVenture(array $productsData, $ventureCode) |
215
|
|
|
{ |
216
|
|
|
$configCollection = \Iris\Mapping\ConfigCollection::assign($productsData); |
|
|
|
|
217
|
|
|
//@todo |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* {@inheritdoc} |
222
|
|
|
*/ |
223
|
|
|
public function handleImages(\Iris\Transfer\Catalog\Config $config) |
224
|
|
|
{ |
225
|
|
|
//@todo |
226
|
|
|
} |
227
|
|
|
} |
228
|
|
|
|