khanegi setting and prices records
This commit is contained in:
@@ -21,6 +21,7 @@ use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use App\Services\ConfigService;
|
||||
use App\Services\LivePriceCacheService;
|
||||
use App\Services\ProductDisplayPriceService;
|
||||
|
||||
|
||||
@@ -127,15 +128,37 @@ class ReportController extends Controller
|
||||
$payload['last_historical'] = app(ProductDisplayPriceService::class)->resolveHistoricalBasePrice();
|
||||
app(ProductDisplayPriceService::class)->cacheLivePricePayload($payload);
|
||||
|
||||
if (request()->boolean('force_refresh')) {
|
||||
return app(LivePriceCacheService::class)->put($payload);
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
public function lastPrice()
|
||||
public function lastPrice(Request $request)
|
||||
{
|
||||
$config = app(ConfigService::class);
|
||||
$cache = app(LivePriceCacheService::class);
|
||||
|
||||
if (! $request->boolean('force_refresh')) {
|
||||
$cached = $cache->get();
|
||||
if ($cached !== null) {
|
||||
return $cached;
|
||||
}
|
||||
|
||||
$dbBuilt = $cache->buildFromDatabase();
|
||||
if (($dbBuilt['price'] ?? 0) > 0) {
|
||||
return $dbBuilt;
|
||||
}
|
||||
}
|
||||
|
||||
if ($config->isStore()) {
|
||||
return $this->storeLastPrice($config);
|
||||
return $this->appendUpPrices(array_merge([
|
||||
'closed' => false,
|
||||
'time' => now(),
|
||||
'main_product' => 0,
|
||||
'zaarbox' => 0,
|
||||
], $this->storeLastPrice($config)));
|
||||
}
|
||||
|
||||
$closed = false;
|
||||
@@ -361,24 +384,14 @@ class ReportController extends Controller
|
||||
}
|
||||
|
||||
if ($priceValue <= 0) {
|
||||
if (!$show_last_price) {
|
||||
return $this->appendUpPrices([
|
||||
'sell' => 0,
|
||||
'buy' => 0,
|
||||
'price_last' => 0,
|
||||
'price' => 0,
|
||||
'main_product' => $pr_price ?? 0,
|
||||
'montzar' => $montzar_price ?? 0,
|
||||
'zaarbox' => $zaarbox_price ?? 0,
|
||||
'closed' => true,
|
||||
'time' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
$lastPrice = Price::latest()->first();
|
||||
$storedPrice = $lastPrice ? (float) $lastPrice->price : 0.0;
|
||||
$useFallback = $request->boolean('force_refresh') || $show_last_price;
|
||||
|
||||
if ($storedPrice <= 0) {
|
||||
if ($storedPrice > 30_000_000 && $useFallback) {
|
||||
$priceValue = $storedPrice;
|
||||
$priceSource = 'database_last';
|
||||
} else {
|
||||
return $this->appendUpPrices([
|
||||
'sell' => 0,
|
||||
'buy' => 0,
|
||||
@@ -391,9 +404,6 @@ class ReportController extends Controller
|
||||
'time' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
$priceValue = $storedPrice;
|
||||
$priceSource = 'database_last';
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -406,9 +416,9 @@ class ReportController extends Controller
|
||||
$lastPrice = Price::latest()->first();
|
||||
|
||||
if (
|
||||
!$closed &&
|
||||
(!$lastPrice || (float) $lastPrice->price != (float) $priceToStore) &&
|
||||
$priceToStore > 1000000
|
||||
! $closed &&
|
||||
(! $lastPrice || (float) $lastPrice->price != (float) $priceToStore) &&
|
||||
$priceToStore > 30_000_000
|
||||
) {
|
||||
$price = new Price();
|
||||
$price->price = $priceToStore;
|
||||
|
||||
Reference in New Issue
Block a user