6
0
Fork 0

调整购物车下单

release
vine_liutk 2022-04-24 11:24:49 +08:00
parent 729f89181d
commit 64fbcb102b
1 changed files with 5 additions and 2 deletions

View File

@ -93,17 +93,20 @@ class OrderController extends Controller
$shoppingCartItems->load('product'); $shoppingCartItems->load('product');
$totalQty = $shoppingCartItems->sum('quantity'); $totalQty = $shoppingCartItems->sum('quantity');
$data = []; $data = [];
$totalAmount = 0;
foreach ($shoppingCartItems as $item) { foreach ($shoppingCartItems as $item) {
$dealerPrice = $orderService->getSalePrice($user, $item->product, $totalQty);
$data[] = [ $data[] = [
'id' => $item->id, 'id' => $item->id,
'name' => $item->name, 'name' => $item->name,
'cover' => $item->cover, 'cover' => $item->cover,
'sell_price' => $item->sell_price, 'sell_price' => $item->sell_price,
'dealer_price' => $orderService->getSalePrice($user, $item->product, $totalQty), 'dealer_price' => $dealerPrice,
'quantity' => $item->quantity, 'quantity' => $item->quantity,
]; ];
$totalAmount += $dealerPrice;
} }
return response()->json(['data'=>$data]); return response()->json(['data'=>$data, 'to_lvl'=>$orderService->willBecome($user, $totalAmount)]);
} }
/** /**