Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
transferprovider.php
1<?php
2
4
8
9
14{
15
23 private function callProviderMethod($methodName, array $products = array())
24 {
27 if (!method_exists($providerClass, $methodName))
28 {
29 throw new Main\ArgumentOutOfRangeException('methodName');
30 }
31 return $providerClass->$methodName($products);
32 }
33
40 public function tryShip(array $products)
41 {
42 return $this->callProviderMethod('tryShip', $products);
43 }
44
51 public function isNeedShip(array $products)
52 {
53 return $this->callProviderMethod('isNeedShip', $products);
54 }
55
62 public function ship(array $products)
63 {
64 return $this->callProviderMethod('ship', $products);
65 }
66
73 public function checkBarcode(array $items)
74 {
75 return $this->callProviderMethod('checkBarcode', $items);
76 }
77
78
85 public function reserve(array $products)
86 {
87 return $this->callProviderMethod('reserve', $products);
88 }
89
96 public function deliver(array $products)
97 {
98 return $this->callProviderMethod('deliver', $products);
99 }
100
107 public function viewProduct(array $products)
108 {
109 return $this->callProviderMethod('viewProduct', $products);
110 }
111
118 public function recurring(array $products)
119 {
120 return $this->callProviderMethod('recurring', $products);
121 }
122
129 public function getProductListStores(array $products)
130 {
131 return $this->callProviderMethod('getProductListStores', $products);
132 }
133
142 public function setItemsResultAfterTryShip(PoolQuantity $pool, array $products, array $productTryList)
143 {
144 return static::setItemsResultAfterTryShipByCoefficient($pool, $products, $productTryList, 1);
145 }
146
155 public function setItemsResultAfterTryUnship(PoolQuantity $pool, array $products, array $productTryList)
156 {
157 return static::setItemsResultAfterTryShipByCoefficient($pool, $products, $productTryList, -1);
158 }
159
169 private function setItemsResultAfterTryShipByCoefficient(PoolQuantity $pool, array $products, array $productTryList, $coefficient)
170 {
171 foreach ($products as $productId => $productData)
172 {
173 if (!isset($productTryList[$productId]))
174 {
175 continue;
176 }
177
178 if (empty($productData['SHIPMENT_ITEM_DATA_LIST']))
179 continue;
180
185 foreach ($productData['SHIPMENT_ITEM_DATA_LIST'] as $shipmentItemIndex => $shipmentItemQuantity)
186 {
187 $quantity = $coefficient * $shipmentItemQuantity;
188 $pool->add(PoolQuantity::POOL_QUANTITY_TYPE, $productId, $quantity);
189 }
190 }
191
192 return new Sale\Result();
193 }
194
202 public function setItemsResultAfterGetData(array $products, Sale\Result $reserveResult)
203 {
204 return new Sale\Result();
205 }
206
213 public function getAvailableQuantity(array $products)
214 {
215 $result = $this->callProviderMethod('getAvailableQuantity', $products);
216
217 $resultData = $result->getData();
218 if (!array_key_exists('AVAILABLE_QUANTITY_LIST', $resultData))
219 {
220 return $result;
221 }
222
223 return $result->setData(['AVAILABLE_QUANTITY_LIST' => $resultData['AVAILABLE_QUANTITY_LIST']]);
224 }
225
232 public function getAvailableQuantityByStore(array $products)
233 {
234 $result = $this->callProviderMethod('getAvailableQuantityByStore', $products);
235
236 $resultData = $result->getData();
237 if (!array_key_exists('AVAILABLE_QUANTITY_LIST_BY_STORE', $resultData))
238 {
239 return $result;
240 }
241
242 return $result->setData(['AVAILABLE_QUANTITY_LIST_BY_STORE' => $resultData['AVAILABLE_QUANTITY_LIST_BY_STORE']]);
243 }
244
251 public function getAvailableQuantityAndPrice(array $products)
252 {
253 $result = $this->callProviderMethod('getAvailableQuantityAndPrice', $products);
254
255 $resultData = $result->getData();
256
257 return $result->setData([
258 'PRODUCT_DATA_LIST' => [
259 'PRICE_LIST' => $resultData['PRODUCT_DATA_LIST']['PRICE_LIST'],
260 'AVAILABLE_QUANTITY_LIST' => $resultData['PRODUCT_DATA_LIST']['AVAILABLE_QUANTITY_LIST']
261 ]
262 ]);
263 }
264
270 public function getProductData(array $products)
271 {
272 return $this->callProviderMethod('getProductData', $products);
273 }
274
280 public function getBundleItems(array $products)
281 {
282 return $this->callProviderMethod('getBundleItems', $products);
283 }
284
288 public function getStoresCount()
289 {
290 return $this->callProviderMethod('getStoresCount');
291 }
292
296 public function writeOffProductBatches(array $products): Sale\Result
297 {
298 return $this->callProviderMethod('writeOffProductBatches', $products);
299 }
300
304 public function returnProductBatches(array $products): Sale\Result
305 {
306 return $this->callProviderMethod('returnProductBatches', $products);
307 }
308}
setItemsResultAfterTryUnship(PoolQuantity $pool, array $products, array $productTryList)
setItemsResultAfterGetData(array $products, Sale\Result $reserveResult)
setItemsResultAfterTryShip(PoolQuantity $pool, array $products, array $productTryList)