135 lines
2.8 KiB
PHP
135 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\PompoBundle\Util;
|
|
|
|
use Query\Operator;
|
|
|
|
class Configuration
|
|
{
|
|
public const SHOP_POMPO = 'pompo';
|
|
public const SHOP_NEJHRACKA = 'nejhracka';
|
|
|
|
private array $configuration = [];
|
|
|
|
public function setConfiguration(array $configuration): void
|
|
{
|
|
$this->configuration = $configuration;
|
|
}
|
|
|
|
public function has(string $name): bool
|
|
{
|
|
return isset($this->configuration[$name]);
|
|
}
|
|
|
|
public function get(string $name, $default = null)
|
|
{
|
|
if (!$this->has($name)) {
|
|
return $default;
|
|
}
|
|
|
|
return $this->configuration[$name];
|
|
}
|
|
|
|
public function getShop(): string
|
|
{
|
|
return $this->get('shop');
|
|
}
|
|
|
|
public function getOrderFinalStatus(): int
|
|
{
|
|
return (int) $this->get('order.final_status');
|
|
}
|
|
|
|
public function isPompo(): bool
|
|
{
|
|
return $this->getShop() === self::SHOP_POMPO;
|
|
}
|
|
|
|
public function isNejhracka(): bool
|
|
{
|
|
return $this->getShop() === self::SHOP_NEJHRACKA;
|
|
}
|
|
|
|
public function getMainStoreId(): int
|
|
{
|
|
return $this->get('store.id');
|
|
}
|
|
|
|
public function getDefaultSupplierId(): array
|
|
{
|
|
return $this->get('supplier.defaults', []);
|
|
}
|
|
|
|
public function getMarketplaceSuppliers(): array
|
|
{
|
|
if (!findModule(\Modules::PRODUCTS_SUPPLIERS)) {
|
|
return [];
|
|
}
|
|
|
|
static $suppliersCache;
|
|
|
|
if ($suppliersCache === null) {
|
|
$qb = sqlQueryBuilder()
|
|
->select('id, name, data')
|
|
->from('suppliers')
|
|
->where(Operator::not(Operator::inIntArray($this->getDefaultSupplierId(), 'id')));
|
|
|
|
$suppliersCache = [];
|
|
foreach ($qb->execute() as $item) {
|
|
$item['data'] = json_decode($item['data'] ?: '', true) ?: [];
|
|
$suppliersCache[$item['id']] = $item;
|
|
}
|
|
}
|
|
|
|
return $suppliersCache;
|
|
}
|
|
|
|
/**
|
|
* Vrátí pole [MENA => ID_CENIKU], ktere rika jaky cenik plati pro jakou menu.
|
|
*/
|
|
public function getPriceLists(): array
|
|
{
|
|
return [
|
|
'EUR' => 1,
|
|
];
|
|
}
|
|
|
|
public function getUsersPriceLists(): array
|
|
{
|
|
if ($this->isNejhracka()) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'CZK' => 2,
|
|
'EUR' => 3,
|
|
];
|
|
}
|
|
|
|
public function getDMOCPriceLists(): array
|
|
{
|
|
if ($this->isNejhracka()) {
|
|
return [
|
|
'CZK' => 2,
|
|
'EUR' => 3,
|
|
'RON' => 2,
|
|
];
|
|
}
|
|
|
|
return [
|
|
'CZK' => 5,
|
|
'EUR' => 6,
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Cenik s cenou, kde cena = nakupni cena + 5%.
|
|
*/
|
|
public function getVIPPriceListId(): int
|
|
{
|
|
return 4;
|
|
}
|
|
}
|