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/wbs24.ozonapinew/lib/ |
Upload File : |
<?php namespace Wbs24\Ozonapinew; use Bitrix\Main\SystemException; use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; use Wbs24\Ozonapinew\Api\Controller; class StatusChange { use Exception; // trait use Accounts; // trait use OrdersHelper; // trait protected const XML_ID_PREFIX = 'OZON'; protected $needStatuses = [ 'delivering', 'last-mile', 'delivered' ]; public function __construct($objects = []) { try { $this->wrappers = new Wrappers($objects); $this->main = $objects['Main'] ?? new Main(); $this->moduleId = $this->main->getModuleId(); $this->OrdersState = $objects['OrdersState'] ?? new OrdersState(); } catch (SystemException $exception) { $this->exceptionHandler($exception); } } public static function OnSaleStatusOrderChangeHandler(\Bitrix\Main\Event $event) { $order = $event->getParameter("ENTITY"); $currentBitrixStatus = $event->getParameter("VALUE"); $StatusChangeObject = new StatusChange(); $StatusChangeObject->run($order->getId(), $currentBitrixStatus); } protected function run($orderId, $currentBitrixStatus) { if ($this->checkIsOrderFromTraidingPlatform($orderId)) { $externalId = $this->getExternalId($orderId); if (!$this->checkIsOrderRfbs($externalId)) return; $allowRfbsStatusSend = ($this->wrappers->Option->get($this->moduleId, 'allowRfbsStatusSend') == 'Y'); if ($allowRfbsStatusSend) { $data = [ 'posting_number' => $externalId, 'account_index' => $this->accountIndex, ]; foreach ($this->needStatuses as $needStatus) { $bitrixStatus = $this->wrappers->Option->get($this->moduleId, $needStatus); if ($currentBitrixStatus == $bitrixStatus) { $data['action'] = 'status_' . $needStatus; $Object = new Controller(); $result = $Object->action($data); } } } } } protected function checkIsOrderRfbs($externalId) { $result = true; $this->OrdersState->setAccountIndex($this->accountIndex); $orderInfo = $this->OrdersState->getOrdersInformation($externalId); $tplIntegrationType = $orderInfo['tpl_integration_type'] ?? ''; if ( $tplIntegrationType == '' || $tplIntegrationType == 'ozon' ) { $result = false; } return $result; } }