fix table bug

This commit is contained in:
2026-06-04 13:48:37 +03:30
parent 62d2e15270
commit a643ba58b7
9 changed files with 238 additions and 31 deletions
+36 -12
View File
@@ -232,9 +232,11 @@ class ReportController extends Controller
| اتحادیه (گلد علی / refPricer) — فقط وقتی price_provider=etehadie
|--------------------------------------------------------------------------
*/
$etehadie_order_price = 0;
if ($priceProvider === 'etehadie' && !$closed) {
$etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice();
$etehadie_teh = (int) ($etehadie['price'] ?? 0);
$etehadie_order_price = (int) ($etehadie['order_price'] ?? 0);
}
/*
@@ -422,15 +424,20 @@ class ReportController extends Controller
| ذخیره قیمت
|--------------------------------------------------------------------------
*/
$priceToStore = $priceValue;
if ($priceProvider === 'etehadie' && $etehadie_order_price > 0) {
$priceToStore = $etehadie_order_price;
}
$lastPrice = Price::latest()->first();
if (
!$closed &&
(!$lastPrice || (float) $lastPrice->price != (float) $priceValue) &&
$priceValue > 30000000
(!$lastPrice || (float) $lastPrice->price != (float) $priceToStore) &&
$priceToStore > 30000000
) {
$price = new Price();
$price->price = $priceValue;
$price->price = $priceToStore;
$price->time_at = Carbon::now()->toTimeString();
$price->date_at = Carbon::now()->toDateString();
$price->save();
@@ -440,24 +447,26 @@ class ReportController extends Controller
$candle = PriceCandle::whereDate('date_at', date("Y-m-d"))->first();
if (!is_null($candle)) {
$candle->end = $priceValue;
$candle->end = $priceToStore;
if ($priceValue < $candle->low) {
$candle->low = $priceValue;
} elseif ($priceValue > $candle->high) {
$candle->high = $priceValue;
if ($priceToStore < $candle->low) {
$candle->low = $priceToStore;
} elseif ($priceToStore > $candle->high) {
$candle->high = $priceToStore;
}
$candle->save();
} else {
PriceCandle::create([
'start' => $priceValue,
'end' => $priceValue,
'high' => $priceValue,
'low' => $priceValue,
'start' => $priceToStore,
'end' => $priceToStore,
'high' => $priceToStore,
'low' => $priceToStore,
'date_at' => date('Y-m-d'),
]);
}
$lastPrice = $price;
}
/*
@@ -492,6 +501,21 @@ class ReportController extends Controller
$priceLast = ceil($priceValue + $difference);
}
/*
| گلد علی (etehadie): سفارش از Price::latest() می‌خواند؛
| buy/sell/price_last هم از همان ردیف (مثل goldAliii قبل از مرج).
| etehadie_teh فقط در فیلد price / etehadie_teh می‌ماند.
*/
if ($priceProvider === 'etehadie' && !$closed) {
$storedPrice = $lastPrice ?? Price::latest()->first();
if ($storedPrice && (float) $storedPrice->price > 0) {
$base = (float) $storedPrice->price;
$sell = $open_sell ? (int) ceil($base - $difference) : 0;
$buy = $open_buy ? (int) ceil($base + $difference) : 0;
$priceLast = (int) ceil($base + $difference);
}
}
if (!$closed && $priceValue > 0) {
$config->trackDailyPriceExtreme((float) $priceValue);
}