...
|
...
|
@@ -172,6 +172,7 @@ class Cart extends Model |
|
|
$list = $this->where('user_id',$user['id'])->where($where)->select();
|
|
|
$total_num = 0;
|
|
|
$total_price = 0;
|
|
|
$total_goods_weight = 0;
|
|
|
$cart_list = [];
|
|
|
foreach ($list as $key => $cart) {
|
|
|
// 判断商品不存在则自动删除
|
...
|
...
|
@@ -193,14 +194,21 @@ class Cart extends Model |
|
|
if ($goods['ismake'] == '0' && $cart['goods_num'] > $cart['goods_sku']['stock_num']) {
|
|
|
$this->setError('很抱歉,商品 [' . $goods['goods_name'] . '] 库存不足');
|
|
|
}
|
|
|
// 商品总数
|
|
|
$total_num += $cart['goods_num'];
|
|
|
// 商品总价
|
|
|
$total_price += $cart['goods_total_price'] = bcmul($cart['goods_price'], $cart['goods_num'], 2);
|
|
|
// 商品总重量
|
|
|
$total_goods_weight += bcmul($cart['goods_sku']['goods_weight'], $cart['goods_num'], 2);
|
|
|
// 显示商品信息
|
|
|
$cart->goods->visible(['goods_name','goods_image','category_ids','spec_type']);
|
|
|
// 显示用户尺寸信息
|
|
|
if(!$cart->user_size){
|
|
|
$cart->user_size = [];
|
|
|
}else{
|
|
|
$cart->user_size->visible(['id','name','size_text']);
|
|
|
}
|
|
|
// 显示购物车数据
|
|
|
$cart_list[] = $cart->visible([
|
|
|
'id',
|
|
|
'goods_id',
|
...
|
...
|
@@ -224,7 +232,6 @@ class Cart extends Model |
|
|
}
|
|
|
}
|
|
|
// 运费
|
|
|
$total_goods_weight = array_sum(array_column(array_column($cart_list, 'goods_sku'),'goods_weight'));
|
|
|
$express = config('site.express');
|
|
|
krsort($express);
|
|
|
$express_price = 0;
|
...
|
...
|
|