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
+7 -5
View File
@@ -43,7 +43,7 @@ class EtehadiePriceService
public function fetchMainGramPrice(): array
{
if (!$this->isEnabled() && $this->priceKey() === '') {
return ['price' => 0, 'raw' => null];
return ['price' => 0, 'order_price' => 0, 'raw' => null];
}
try {
@@ -53,7 +53,7 @@ class EtehadiePriceService
->json();
if (!is_array($prices)) {
return ['price' => 0, 'raw' => null];
return ['price' => 0, 'order_price' => 0, 'raw' => null];
}
$key = $this->priceKey();
@@ -63,18 +63,20 @@ class EtehadiePriceService
: $collection->first();
if (empty($row)) {
return ['price' => 0, 'raw' => null];
return ['price' => 0, 'order_price' => 0, 'raw' => null];
}
$base = (float) ($row['price'] ?? 0);
$profit = (float) ($row['profit'] ?? 0);
$gramPrice = (int) round($base / 10 + $profit);
// همان مقیاسی که سفارش/جدول prices گلد علی استفاده می‌کند (base + profit)
$orderPrice = (int) round($base + $profit);
return ['price' => $gramPrice, 'raw' => $row];
return ['price' => $gramPrice, 'order_price' => $orderPrice, 'raw' => $row];
} catch (\Throwable $e) {
Log::warning('Etehadie price fetch failed', ['message' => $e->getMessage()]);
return ['price' => 0, 'raw' => null];
return ['price' => 0, 'order_price' => 0, 'raw' => null];
}
}