added ons

This commit is contained in:
2026-07-12 20:58:34 +03:30
parent 555f09b9c7
commit 300c909b9e
6 changed files with 85 additions and 25 deletions
+4 -20
View File
@@ -167,25 +167,7 @@ class ReportController extends Controller
protected function resolveGoldOuncePayload(): ?array
{
$config = app(ConfigService::class);
if (! $config->getBool('show_gold_ounce_price', false)) {
return null;
}
$zaarbox = app(ZaarboxPriceService::class);
if (! $zaarbox->hasApiUrlConfigured()) {
return null;
}
$ounce = $zaarbox->fetchOuncePrice();
if (($ounce['price'] ?? 0) <= 0) {
return null;
}
return [
'price' => (int) $ounce['price'],
'label' => trim((string) ($ounce['name'] ?? 'انس طلا')) ?: 'انس طلا',
];
return app(ZaarboxPriceService::class)->clientGoldOuncePayload();
}
public function lastPrice(Request $request)
@@ -197,6 +179,8 @@ class ReportController extends Controller
if (! $forceRefresh) {
$cached = $cache->get();
if ($cached !== null) {
$cached['gold_ounce'] = $this->resolveGoldOuncePayload();
return $cached;
}
@@ -204,7 +188,7 @@ class ReportController extends Controller
if ($cache->hasRecentTick()) {
$dbBuilt = $cache->buildFromDatabase();
if (($dbBuilt['price'] ?? 0) > 0) {
return $cache->put($dbBuilt);
return $this->appendUpPrices($dbBuilt, false);
}
}
}