Новая реализация курсов валют.

This commit is contained in:
2023-08-10 17:04:23 +03:00
parent f4a66a1147
commit deac9203bd
7 changed files with 421 additions and 509 deletions
+9 -5
View File
@@ -4,19 +4,18 @@ namespace Core;
class Config
{
const EKR_RUB_PRICE = 30;
const KR_TO_EKR_EXCHANGE = 500;
const EKR_TO_KR_EXCHANGE = 200;
private static self $instance;
private static string $hostname = 'new-combats.tech';
private static string $gamename = 'Бойцовский Клуб';
private function __construct()
{
//singleton
}
private static function subdomain(string $name): string
{
return DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $name . '.' . self::$hostname;
}
/** Самый распространённый субдомен
* //img.{siteName}.
* @return string
@@ -26,6 +25,11 @@ class Config
return self::subdomain('img');
}
private static function subdomain(string $name): string
{
return DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $name . '.' . self::$hostname;
}
public static function get(?string $key = null)
{
$c['ver'] = '1.8.3.7';
@@ -0,0 +1,37 @@
<?php
namespace Model;
use Core\Db;
class EkrExchangeRates
{
/**
* @var array|false
*/
private $today;
public function __construct()
{
$this->today = Db::getRow('select RUB, USD, from_unixtime(id, ?) as date from ekr_exchange_rates order by id desc limit 1', ['%d.%m.%Y']);
if (empty($this->today)) {
$this->today = ['RUB' => 0, 'USD' => 0, 'date' => '00.00.0000'];
}
}
public function oneEkrInUSD(): float
{
return round($this->today['RUB'] / $this->today['USD'], 2);
}
public function oneEkrInRUB(): float
{
return $this->today['RUB'];
}
public function date(): string
{
return $this->today['date'];
}
}