fix(price): read last quote and daily extremes from the active provider

A stray montzar tick landed in the prices table, which stores no source, so
the database_last fallback served a ~168M quote on a shop whose Zaarbox board
was at ~217M. Last price and today's high/low now come from price_sync_logs
filtered by price_provider, the database fallback no longer counts as today's
price, and daily extremes reset when the provider changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-31 09:45:37 +03:30
co-authored by Cursor
parent 1b73305d6f
commit 142cfd7661
5 changed files with 98 additions and 37 deletions
+12 -4
View File
@@ -281,8 +281,19 @@ class ProductDisplayPriceService
return $historical;
}
/**
* آخرین قیمت پایهٔ ذخیره‌شده.
*
* اول تاریخچهٔ برچسب‌دار همین provider (price_sync_logs)؛ جدول prices منبع را
* ذخیره نمی‌کند و یک تیک اشتباه از provider دیگر «آخرین قیمت» را پرت می‌کند.
*/
public function resolveHistoricalBasePrice(): int
{
$fromProviderLog = app(ConfigService::class)->lastProviderQuotePrice();
if ($fromProviderLog > 0) {
return $fromProviderLog;
}
$last = Price::orderByDesc('id')->first();
if (!$last || (float) $last->price <= 0) {
return 0;
@@ -562,10 +573,7 @@ class ProductDisplayPriceService
}
if ($price <= 0 && $config->getBool('show_last_price', false)) {
$last = Price::orderByDesc('id')->first();
if ($last && (float) $last->price > 0) {
$price = (int) $last->price;
}
$price = $this->resolveHistoricalBasePrice();
}
$diffBuy = (int) $config->displayBuyPriceDiffRial();