diff --git a/application/api/controller/Cart.php b/application/api/controller/Cart.php index 57e8a3a..8162c22 100644 --- a/application/api/controller/Cart.php +++ b/application/api/controller/Cart.php @@ -77,6 +77,33 @@ class Cart extends Api } /** + * @ApiTitle (减少购物车数量) + * @ApiMethod (POST) + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") + * @ApiParams (name="id", type="integer", required=true, description="购物车id") + * @ApiParams (name="number", type="integer", required=true, description="减少数量") + * @ApiReturn ({ + 'code':'1', + 'msg':'SUCCESS' + }) + */ + public function subCartNumber() + { + $id = $this->request->post('id'); + $number = $this->request->post('number'); + + if (!is_numeric($id) || !is_numeric($number)) $this->error('参数不合法'); + + $model = new \app\api\model\Cart(); + if ($model->where('id',$id)->value('number') ==1){ + $this->error('购物车数量不可再减少'); + }else{ + $model->where('id',$id)->setDec('number',$number); + } + $this->success('SUCCESS'); + } + + /** * @ApiTitle (购物车列表) * @ApiMethod (POST) * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")