43 $providerName = $reflect->getName();
66 $transferProvider =
new static();
72 $transferProvider->context =
$context;
74 return $transferProvider;
90 abstract public function tryShip(array $products);
105 abstract public function ship(array $products);
112 abstract public function reserve(array $products);
120 abstract public function deliver(array $products);
155 public function setItemsResultAfterShip(array $products,
Sale\
Result $resultAfterShip)
159 $needReverse =
false;
160 $shippedProductList = array();
161 $resultData = $resultAfterShip->getData();
162 if (!empty($resultData[
'SHIPPED_PRODUCTS_LIST']))
164 $shippedProductList = $resultData[
'SHIPPED_PRODUCTS_LIST'];
166 foreach ($shippedProductList as $isShipped)
168 if ($isShipped ===
false)
176 $shipmentList = array();
177 $productIndex = array();
179 foreach ($products as $productId => $itemData)
181 if (!empty($itemData[
'SHIPMENT_ITEM_LIST']))
184 foreach ($itemData[
'SHIPMENT_ITEM_LIST'] as $shipmentItemIndex => $shipmentItem)
186 $basketItem = $shipmentItem->getBasketItem();
187 $shipment = $shipmentItem->getCollection()->getShipment();
189 if (isset($itemData[
'NEED_RESERVE_BY_STORE_LIST'][$shipmentItemIndex]))
191 $needReverseByStore = $itemData[
'NEED_RESERVE_BY_STORE_LIST'][$shipmentItemIndex];
192 foreach ($needReverseByStore as $storeId => $isNeeded)
195 $reserveQuantityCollection = $basketItem->getReserveQuantityCollection();
199 && $reserveQuantityCollection
200 && $shipment->needShip() !== Catalog\Provider::SALE_TRANSFER_PROVIDER_SHIPMENT_NEED_NOT_SHIP)
203 foreach ($reserveQuantityCollection as $reserve)
205 if ($reserve->getStoreId() !== $storeId)
210 if (isset($itemData[
'STORE_DATA_LIST'][$shipmentItemIndex][$storeId]))
212 $reserveQuantity = $itemData[
'STORE_DATA_LIST'][$shipmentItemIndex][$storeId][
'RESERVED_QUANTITY'];
216 $reserveQuantity = $shipmentItem->getQuantity();
219 if ($reserve->getQuantity() > $reserveQuantity)
221 $reserve->setFieldNoDemand(
'QUANTITY', $reserve->getQuantity() - $reserveQuantity);
225 $reserve->deleteNoDemand();
231 if ($shipment->needShip() !== Catalog\Provider::SALE_TRANSFER_PROVIDER_SHIPMENT_NEED_NOT_SHIP)
233 $shipmentItem->getFields()->set(
'RESERVED_QUANTITY', 0);
237 $shipmentIndex = $shipment->getInternalIndex();
238 if (!array_key_exists($shipmentIndex, $shipmentList))
240 $shipmentList[$shipmentIndex] = $shipment;
244 !isset($productIndex[$shipmentIndex][$shipmentItemIndex])
245 || !in_array($productId, $productIndex[$shipmentIndex][$shipmentItemIndex])
248 $productIndex[$shipmentIndex][$shipmentItemIndex] =
$productId;
254 $reverseProducts = array();
255 if ($needReverse && !empty($productIndex))
257 foreach ($productIndex as $productList)
259 foreach ($productList as $productId)
261 $isExistsProduct = array_key_exists($productId, $shippedProductList);
265 && $shippedProductList[$productId] ===
true
266 && empty($reverseProducts[$productId])
270 $reverseProducts[
$productId][
'QUANTITY'] *= -1;
276 if ($needReverse && !empty($reverseProducts))
278 $r = $this->
ship($reverseProducts);