Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/lib/handlers/ |
Upload File : |
<? namespace Lpost\Delivery\Handlers; use Bitrix\Main\Context; use \Bitrix\Main\Localization\Loc; use Bitrix\Sale\Delivery\Services\Base; use Bitrix\Sale\Delivery\Services\Manager; use Bitrix\Sale\Shipment; use Lpost\Delivery\Main\City; use Lpost\Delivery\Order\HandlerCalculateOrder\HandlerOrderCalculate; use Lpost\Delivery\Order\OrderManager; use Lpost\Delivery\Repository\RepositoryPvz; use Lpost\Delivery\Settings; Loc::loadMessages(__FILE__); class Pvz extends Base { use \Lpost\Delivery\Base; const TYPE = "pvz"; protected static $isProfile = true; protected static $parent = null; protected static $arResCompatible = []; public function __construct(array $initParams) { parent::__construct($initParams); $this->parent = Manager::getObjectById($this->parentId); } public static function getClassTitle() { return Loc::getMessage("lpost.handler_profile_pvz_name"); } public static function getClassDescription() { return Loc::getMessage("lpost.handler_profile_pvz_description"); } public function getParentService() { return $this->parent; } public function isCalculatePriceImmediately() { return $this->getParentService()->isCalculatePriceImmediately(); } public static function isProfile() { return self::$isProfile; } /** * @throws \Bitrix\Main\NotSupportedException * @throws \Bitrix\Main\ObjectPropertyException * @throws \Bitrix\Main\NotImplementedException * @throws \Bitrix\Main\ArgumentNullException * @throws \Bitrix\Main\ArgumentOutOfRangeException * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\SystemException * @throws \ErrorException */ protected function calculateConcrete(Shipment $shipment) { $orderManager = new OrderManager($shipment->getOrder()); $deliveryId = $this->getId() ?: $shipment->getDeliveryId(); if(!$orderManager->isLpostDeliveryId($deliveryId)) { return false; } //$this->setDebug('Pvz calculateConcrete getDeliveryId', $shipment->getDeliveryId()); $handlerCalculate = new HandlerOrderCalculate( $orderManager, Context::getCurrent()->getRequest() ); //$this->setDebug('Pvz calculateConcrete handlerCalculate', print_r($handlerCalculate,1)); return $handlerCalculate->execute(); } public function getConfigStructure() { $config = $this->parent->getConfigStructure(); $config['MAIN']['TITLE'] = Loc::getMessage("lpost.handler_pvz_name"); $config['MAIN']['DESCRIPTION'] = Loc::getMessage("lpost.handler_pvz_description"); return $config; } public function isCompatible(Shipment $shipment) { if (!\Sale\Handlers\Delivery\lpost_deliveryHandler::isTokenReady()) { return false; } $weight = $shipment->getWeight(); if ($weight > 150000) { return false; } $order = $shipment->getCollection()->getOrder(); $props = $order->getPropertyCollection(); $deliveryLocation = $props->getDeliveryLocation(); if (!$deliveryLocation) { return false; } if(!$locationCode = $deliveryLocation->getValue()) { return false; } $res = true; if(isset(self::$arResCompatible[$locationCode])){ $res = self::$arResCompatible[$locationCode]; } else{ $cityData = City::getCityData($locationCode); $repositoryPvz = new RepositoryPvz(); $resPvz = $repositoryPvz->getListForMap($cityData['name']); if(Settings::getInstance()->getOption('show_pickup_points_only_for_selected_location') != 'Y' && empty($resPvz)){ if(!empty($cityData['arCityData']['MAIN_CITY_REGION'])) $resPvz = $repositoryPvz->getListForMap($cityData['arCityData']['MAIN_CITY_REGION']); } //$this->setDebug('Pvz isCompatible calculateConcrete cityData', $cityData); if(empty($resPvz)) { $res = false; } $calcResult = self::calculateConcrete($shipment); self::$arResCompatible[$locationCode] = $res; } return $res; } } ?>