fix price force refresh
This commit is contained in:
@@ -44,6 +44,11 @@ class LivePriceCacheService
|
||||
$display = app(ProductDisplayPriceService::class);
|
||||
$last = Price::orderByDesc('id')->first();
|
||||
$base = $last ? (int) $last->price : 0;
|
||||
$provider = $config->priceProvider();
|
||||
|
||||
$montzarPrice = 0;
|
||||
$zaarboxPrice = 0;
|
||||
$mainProductPrice = 0;
|
||||
|
||||
if ($base <= 0) {
|
||||
$payload = [
|
||||
@@ -60,17 +65,33 @@ class LivePriceCacheService
|
||||
} else {
|
||||
$diffBuy = (int) $config->displayBuySpreadRial();
|
||||
$diffSell = (int) $config->displaySellSpreadRial();
|
||||
$buy = (int) ceil($base + $diffBuy);
|
||||
$sell = max(0, (int) ceil($base - $diffSell));
|
||||
$openBuy = true;
|
||||
$openSell = true;
|
||||
|
||||
if ($provider === 'montzar') {
|
||||
$montzarPrice = $config->getInt('montzar_live_price', 0) ?: $base;
|
||||
$montzarDiff = (int) $config->getInt('montzar_diff', 0);
|
||||
$diffBuy += $montzarDiff;
|
||||
$diffSell += $montzarDiff;
|
||||
$openBuy = $config->getBool('montzar_open_buy', true);
|
||||
$openSell = $config->getBool('montzar_open_sell', true);
|
||||
} elseif ($provider === 'zaarbox') {
|
||||
$zaarboxPrice = $base;
|
||||
} elseif ($provider === 'main_product') {
|
||||
$mainProductPrice = $base;
|
||||
}
|
||||
|
||||
$buy = $openBuy ? (int) ceil($base + $diffBuy) : 0;
|
||||
$sell = $openSell ? max(0, (int) ceil($base - $diffSell)) : 0;
|
||||
|
||||
$payload = [
|
||||
'sell' => $sell,
|
||||
'buy' => $buy,
|
||||
'price_last' => $buy,
|
||||
'price' => $base,
|
||||
'main_product' => 0,
|
||||
'montzar' => 0,
|
||||
'zaarbox' => 0,
|
||||
'main_product' => $mainProductPrice,
|
||||
'montzar' => $montzarPrice,
|
||||
'zaarbox' => $zaarboxPrice,
|
||||
'closed' => false,
|
||||
'time' => now(),
|
||||
];
|
||||
@@ -84,6 +105,8 @@ class LivePriceCacheService
|
||||
: ['sell' => $payload['sell'] ?? 0, 'buy' => $payload['buy'] ?? 0];
|
||||
$payload['last_historical'] = $display->resolveHistoricalBasePrice();
|
||||
|
||||
$display->cacheLivePricePayload($payload);
|
||||
|
||||
return $payload;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user