fix table bug
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user