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
+9
View File
@@ -33,6 +33,10 @@ class PriceBroadcastService
$lastPayload = $cache->get() ?? $cache->buildFromDatabase();
}
if (is_array($lastPayload) && $lastPayload !== []) {
$lastPayload = app(ZaarboxPriceService::class)->attachGoldOunceToPayload($lastPayload);
}
if ($force) {
if (is_array($lastPayload) && $lastPayload !== []) {
$stream->publish('last', $lastPayload);
@@ -63,6 +67,8 @@ class PriceBroadcastService
*/
public static function lastPriceIdentity(array $payload): array
{
$goldOunce = is_array($payload['gold_ounce'] ?? null) ? $payload['gold_ounce'] : null;
return [
'sell' => (int) ($payload['sell'] ?? 0),
'buy' => (int) ($payload['buy'] ?? 0),
@@ -72,6 +78,7 @@ class PriceBroadcastService
'main_product' => (int) ($payload['main_product'] ?? 0),
'montzar' => (int) ($payload['montzar'] ?? 0),
'zaarbox' => (int) ($payload['zaarbox'] ?? 0),
'gold_ounce_price' => round((float) ($goldOunce['price'] ?? 0), 2),
];
}
@@ -86,6 +93,8 @@ class PriceBroadcastService
return;
}
$lastPayload = app(ZaarboxPriceService::class)->attachGoldOunceToPayload($lastPayload);
if (! $this->rememberHashIfChanged(self::LAST_HASH_KEY, self::lastPriceIdentity($lastPayload))) {
return;
}