正在显示
1 个修改的文件
包含
6 行增加
和
3 行删除
@@ -59,8 +59,7 @@ class Cars extends Api | @@ -59,8 +59,7 @@ class Cars extends Api | ||
59 | $where = [ | 59 | $where = [ |
60 | 'uid'=>$this->uid, | 60 | 'uid'=>$this->uid, |
61 | 'g_id'=>$data['goods_id'], | 61 | 'g_id'=>$data['goods_id'], |
62 | - 'style'=>$data['style'], | ||
63 | - 'goods_number'=>$data['goods_number'] | 62 | + 'style'=>trim($data['style']), |
64 | ]; | 63 | ]; |
65 | $res = Common::findWhereData('car',$where,'id,g_id'); | 64 | $res = Common::findWhereData('car',$where,'id,g_id'); |
66 | $carModel = new Car(); | 65 | $carModel = new Car(); |
@@ -121,13 +120,17 @@ class Cars extends Api | @@ -121,13 +120,17 @@ class Cars extends Api | ||
121 | ->alias('c') | 120 | ->alias('c') |
122 | ->join('goods g','c.g_id = g.id','LEFT') | 121 | ->join('goods g','c.g_id = g.id','LEFT') |
123 | ->where(['c.uid'=>$this->uid]) | 122 | ->where(['c.uid'=>$this->uid]) |
124 | - ->field('c.id,c.g_id goods_id,c.price,c.goods_number,c.style,g.name,g.image,g.stock,g.introduce') | 123 | + ->field('c.id,c.g_id goods_id,c.style,c.price,c.goods_number,c.style,g.name,g.image,g.stock,g.introduce') |
125 | ->useSoftDelete('g.deletetime') | 124 | ->useSoftDelete('g.deletetime') |
126 | ->select(); | 125 | ->select(); |
127 | $total_price = 0; | 126 | $total_price = 0; |
128 | foreach ($res as &$value){ | 127 | foreach ($res as &$value){ |
129 | $value['image'] = $this->auth->absolutionUrlOne($value['image']); | 128 | $value['image'] = $this->auth->absolutionUrlOne($value['image']); |
130 | $total_price += $value['price'] * $value['goods_number']; | 129 | $total_price += $value['price'] * $value['goods_number']; |
130 | + if(($value['stock'] <=> $value['goods_number']) == -1){ | ||
131 | + //购物车数量大于库存 | ||
132 | + $value['goods_number'] = $value['stock']; | ||
133 | + } | ||
131 | } | 134 | } |
132 | // $total_price = array_sum(array_map(function ($product_row) { | 135 | // $total_price = array_sum(array_map(function ($product_row) { |
133 | // return $product_row['price'] * $product_row['goods_number']; | 136 | // return $product_row['price'] * $product_row['goods_number']; |
-
请 注册 或 登录 后发表评论