作者 李忠强

更新

... ... @@ -71,6 +71,10 @@ class Activity extends Api
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id',$item['goods_id'])
->find();
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
});
... ...
... ... @@ -41,10 +41,15 @@ class Cart extends Api
'user_id' => $this->auth->id,
'sku_id' => $sku_id,
'goods_id' => $goods_id,
'number' => $number,
];
$model = new \app\api\model\Cart();
$model->save($data);
$cart = $model->where($data)->find();
if ($cart){
$cart->setInc('number',$number);
}else{
$data['number'] = $number;
$model->isUpdate(false)->save($data);
}
$this->success('SUCCESS');
}
... ...
... ... @@ -17,7 +17,7 @@ use think\Db;
*/
class Classification extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedLogin = ['sort'];
protected $noNeedRight = ['*'];
/**
... ... @@ -99,6 +99,10 @@ class Classification extends Api
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id',$item['goods_id'])
->find();
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
});
... ... @@ -110,6 +114,10 @@ class Classification extends Api
$goods_spec = Db::name('litestore_goods_spec')
->where('goods_id',$item['goods_id'])
->find();
$item['cart_number'] = Db::name('cart')
->where('user_id',$this->auth->id)
->where('goods_id',$item['goods_id'])
->sum('number');
$item['price'] = $goods_spec['goods_price'];
$item['line_price'] = $goods_spec['line_price'];
});
... ...