...
|
...
|
@@ -110,4 +110,41 @@ class Cars extends Api |
|
|
$this->error('请求方式错误');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (购物车列表)
|
|
|
* @ApiSummary (购物车列表)
|
|
|
* @ApiMethod (GET)
|
|
|
* @ApiRoute (/api/cars/clearCar)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="id", type="string", required=true, description="购物车id(多个以逗号隔开)")
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "删除成功",
|
|
|
"time": "1555504723",
|
|
|
"data": 2
|
|
|
})
|
|
|
*/
|
|
|
public function clearCar(){
|
|
|
if($this->request->isGet()){
|
|
|
$c_id = $this->request->get('id');//购物车id,以逗号隔开字符(“1,2,3”)
|
|
|
$rule = config('site.cars');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['id'=>$c_id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$c_ids = explode(',',$c_id);
|
|
|
$data = Db::table('gc_car')
|
|
|
->whereIn('id',$c_ids)
|
|
|
->where(['uid'=>$this->user_id])
|
|
|
->delete();
|
|
|
if($data){
|
|
|
$this->success('删除成功',$data);
|
|
|
}else{
|
|
|
$this->error('删除失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->error('请求方式错误');
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|