- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/deal/shipmentsrepository.php
- Класс: Bitrix\Crm\Deal\ShipmentsRepository
- Вызов: ShipmentsRepository::loadShipmentStages
protected function loadShipmentStages(array $dealIds) : array
{
$result = [];
$dbRes = Order\ShipmentCollection::getList([
'select' => ['DEDUCTED', 'DEAL_ID' => 'DEAL_BINDING.OWNER_ID'],
'filter' => [
'!SYSTEM' => 'Y',
'!DELIVERY_ID' => Delivery\Services\EmptyDeliveryService::getEmptyDeliveryServiceId(),
'@DEAL_ID' => $dealIds,
],
'order' => ['ORDER_ID' => 'desc', 'ID' => 'desc'],
'runtime' => [
new Entity\ReferenceField(
'DEAL_BINDING',
Binding\OrderEntityTable::class,
[
'=this.ORDER_ID' => 'ref.ORDER_ID',
'=ref.OWNER_TYPE_ID' => new DB\SqlExpression(\CCrmOwnerType::Deal)
],
['join_type' => 'inner']
)
]
]);
while ($shipment = $dbRes->fetch())
{
if (isset($result[$shipment['DEAL_ID']]))
{
continue;
}
$result[$shipment['DEAL_ID']] = ($shipment['DEDUCTED'] === 'Y')
? Order\DeliveryStage::SHIPPED
: Order\DeliveryStage::NO_SHIPPED;
}
return $result;
}