ghatre changes 2
This commit is contained in:
@@ -344,11 +344,6 @@ class CartController extends Controller
|
||||
$priceRow = Price::latest()->first();
|
||||
$goldPrice = $priceRow ? (float) $priceRow->price : 0;
|
||||
|
||||
$requestLines = collect($payload)
|
||||
->filter(fn ($row) => is_array($row) && isset($row['product_id']))
|
||||
->groupBy('product_id')
|
||||
->map(fn ($group) => $group->last());
|
||||
|
||||
$wallet_interface = new WalletInterface($customerId, auth('customer')->user()->type);
|
||||
|
||||
$total_price = 0;
|
||||
@@ -366,13 +361,10 @@ class CartController extends Controller
|
||||
|
||||
app(ConfigService::class)->assertProductTradingOpen($product);
|
||||
|
||||
$line = $requestLines->get($item->product_id);
|
||||
$qty = (int) $item->quantity;
|
||||
|
||||
$unitPrice = (float) ($line['price'] ?? 0);
|
||||
if ($unitPrice <= 0) {
|
||||
$unitPrice = (float) (($product->price ?? 0) + ($product->price_profit ?? 0));
|
||||
}
|
||||
// قیمت واحد از DB — نه قیمت ارسالی کلاینت (در فروشگاه قیمت نقدی هر عدد است، نه هر گرم)
|
||||
$unitPrice = (float) (($product->price ?? 0) + ($product->price_profit ?? 0));
|
||||
if ($unitPrice <= 0 && (float) $product->amount > 0 && $goldPrice > 0) {
|
||||
$unitPrice = (float) $product->amount * $goldPrice;
|
||||
}
|
||||
@@ -395,8 +387,10 @@ class CartController extends Controller
|
||||
|
||||
$orderData = [
|
||||
'customer_id' => $customerId,
|
||||
'cart_id' => (int) $cart->id,
|
||||
'price_id' => $priceRow?->id,
|
||||
'price' => $total_amount > 0 ? (int) round($total_price / $total_amount) : 0,
|
||||
// مظنهٔ مرجع (ریال/گرم) — نه total_price/amount که برای سبد فروشگاهی overflow میدهد
|
||||
'price' => $goldPrice > 0 ? (int) round($goldPrice) : 0,
|
||||
'price_original' => $goldPrice,
|
||||
'amount' => $total_amount,
|
||||
'service_charge_percentage' => 0,
|
||||
|
||||
Reference in New Issue
Block a user