403Webshell
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/cvetdv.ru/bitrix/modules/sale/lib/internals/analytics/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/cvetdv.ru/bitrix/modules/sale/lib/internals/analytics/agent.php
<?php
namespace Bitrix\Sale\Internals\Analytics;

use Bitrix\Main;
use Bitrix\Sale;

/**
 * Class Agent
 * @package Bitrix\Sale\Internals\Analytics
 * @internal
 */
class Agent
{
	/** @var Main\Type\DateTime $date */
	private static $date;

	/**
	 * Sends data
	 *
	 * @return void
	 */
	public static function send(): void
	{
		self::$date = new Main\Type\DateTime();

		foreach (self::getProviders() as $provider)
		{
			$providerCode = $provider::getCode();
			$payload = Storage::getPayloadByCode($providerCode, self::$date);

			$sender = new Sender($providerCode, $payload);
			if ($sender->send())
			{
				static::onSuccessfullySent($providerCode, self::$date);
			}
		}

		static::createAgent(static::getNextExecutionAgentDate());
	}

	/**
	 * @param Main\Type\DateTime $nextExecutionAgentDate
	 * @return void
	 */
	protected static function createAgent(Main\Type\DateTime $nextExecutionAgentDate): void
	{
		\CAgent::Add([
			'NAME' => '\\'.static::class.'::send();',
			'MODULE_ID' => 'sale',
			'ACTIVE' => 'Y',
			'AGENT_INTERVAL' => 86400,
			'IS_PERIOD' => 'Y',
			'NEXT_EXEC' => $nextExecutionAgentDate,
		]);
	}

	/**
	 * @return Main\Type\DateTime
	 */
	protected static function getNextExecutionAgentDate(): Main\Type\DateTime
	{
		$date = new \DateTime();
		$currentMonth = $date->format('n');

		$date->modify('+1 day');
		$modifiedMonth = $date->format('n');

		if ($modifiedMonth > $currentMonth)
		{
			$nextDate =
				$date
					->modify('first day of '.$date->format('F'))
					->format(Main\Type\DateTime::getFormat())
			;
		}
		else
		{
			$nextDate = $date->format(Main\Type\DateTime::getFormat());
		}

		return new Main\Type\DateTime($nextDate);
	}

	/**
	 * @return void
	 */
	protected static function onSuccessfullySent(string $providerCode, Main\Type\DateTime $dateTo): void
	{
		Storage::clean($providerCode, $dateTo);
	}

	/**
	 * @return Provider[]
	 */
	private static function getProviders(): array
	{
		return [
			Sale\PaySystem\Internals\Analytics\Provider::class,
			Sale\Delivery\Internals\Analytics\Provider::class,
			Sale\Cashbox\Internals\Analytics\Provider::class,
			Sale\Internals\Analytics\Events\Provider::class,
		];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit