This commit is contained in:
2026-06-11 20:40:47 +03:30
parent b5d2b878de
commit 2636df99ad
2 changed files with 104 additions and 47 deletions
+24 -47
View File
@@ -89,59 +89,36 @@ class ReportController extends Controller
protected function buildUpDownPrices(): array
{
$feeSettings = Setting::whereIn('key', ['fee_single', 'buy_fee', 'sell_fee'])
->pluck('value', 'key');
$difference = (float) ($feeSettings->get('fee_single') ?? 0);
$diffBuy = (float) ($feeSettings->get('buy_fee') ?: $difference);
$diffSell = (float) ($feeSettings->get('sell_fee') ?: $difference);
$config = app(ConfigService::class);
$diffBuy = $config->displayBuySpreadRial();
$diffSell = $config->displaySellSpreadRial();
$upSetting = Setting::where('key', 'up_price')->first();
$downSetting = Setting::where('key', 'down_price')->first();
$extremes = $config->resolvedDailyBaseExtremes();
$up = $extremes['up'];
$down = $extremes['down'];
if ($upSetting && $downSetting) {
$down = (float) ($downSetting->value ?: 0);
$up = (float) ($upSetting->value ?: 0);
if ($down > 0 && $up > 0) {
return [
'sell' => $down - $diffSell,
'buy' => $up + $diffBuy,
];
}
if ($up > 0 && $down > 0) {
return [
'sell' => max(0, (int) ceil($down - $diffSell)),
'buy' => (int) ceil($up + $diffBuy),
];
}
$today = Carbon::now()->format("Y-m-d");
$prises = Price::where('date_at', $today)->get("price");
$minP = 0;
$maxP = 0;
foreach ($prises as $p) {
if ($minP == 0 || $p->price < $minP) {
$minP = $p->price;
}
if ($maxP == 0 || $p->price > $maxP) {
$maxP = $p->price;
}
}
if (count($prises) === 0) {
$config = app(ConfigService::class);
if (!$config->getBool('show_last_price', false)) {
return ['sell' => 0, 'buy' => 0];
}
$price = Price::orderBy('id', 'desc')->first();
$priceValue = $price ? (float) $price->price : 0.0;
if ($priceValue <= 0) {
return ['sell' => 0, 'buy' => 0];
}
return ['sell' => $priceValue - $diffSell, 'buy' => $priceValue + $diffBuy];
if (!$config->getBool('show_last_price', false)) {
return ['sell' => 0, 'buy' => 0];
}
return ['sell' => $minP - $diffSell, 'buy' => $maxP + $diffBuy];
$price = Price::orderByDesc('id')->first();
$priceValue = $price ? (float) $price->price : 0.0;
if ($priceValue <= 0) {
return ['sell' => 0, 'buy' => 0];
}
return [
'sell' => max(0, (int) ceil($priceValue - $diffSell)),
'buy' => (int) ceil($priceValue + $diffBuy),
];
}
protected function appendUpPrices(array $payload): array