...
|
...
|
@@ -59,8 +59,7 @@ class Cars extends Api |
|
|
$where = [
|
|
|
'uid'=>$this->uid,
|
|
|
'g_id'=>$data['goods_id'],
|
|
|
'style'=>$data['style'],
|
|
|
'goods_number'=>$data['goods_number']
|
|
|
'style'=>trim($data['style']),
|
|
|
];
|
|
|
$res = Common::findWhereData('car',$where,'id,g_id');
|
|
|
$carModel = new Car();
|
...
|
...
|
@@ -121,13 +120,17 @@ class Cars extends Api |
|
|
->alias('c')
|
|
|
->join('goods g','c.g_id = g.id','LEFT')
|
|
|
->where(['c.uid'=>$this->uid])
|
|
|
->field('c.id,c.g_id goods_id,c.price,c.goods_number,c.style,g.name,g.image,g.stock,g.introduce')
|
|
|
->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')
|
|
|
->useSoftDelete('g.deletetime')
|
|
|
->select();
|
|
|
$total_price = 0;
|
|
|
foreach ($res as &$value){
|
|
|
$value['image'] = $this->auth->absolutionUrlOne($value['image']);
|
|
|
$total_price += $value['price'] * $value['goods_number'];
|
|
|
if(($value['stock'] <=> $value['goods_number']) == -1){
|
|
|
//购物车数量大于库存
|
|
|
$value['goods_number'] = $value['stock'];
|
|
|
}
|
|
|
}
|
|
|
// $total_price = array_sum(array_map(function ($product_row) {
|
|
|
// return $product_row['price'] * $product_row['goods_number'];
|
...
|
...
|
|