success('', CartLogic::lists($this->userId)); } public function add() { $post = $this->request->post(); // $check = $this->validate($post, 'app\api\validate\CartValidate.add'); // if (true !== $check) { // return $this->fail($check); // } $res = CartLogic::add($post['item_id'], $post['goods_num'], $this->userId); if ($res === true) { return $this->success('加入成功'); } return $this->fail($res); } public function change() { $post = $this->request->post(); $check = $this->validate($post, 'app\api\validate\CartValidate.change'); if ($check !== true) { return $this->fail($check); } $res = CartLogic::change($post['cart_id'], $post['goods_num']); if ($res === true) { return $this->success(); } return $this->fail($res); } public function del() { $post = $this->request->post(); // $check = $this->validate($post, 'app\api\validate\Cart.del'); // if (true !== $check) { // return $this->fail($check); // } if (CartLogic::del($post['cart_id'], $this->userId)) { return $this->success('删除成功'); } return $this->fail('删除失败'); } public function selected() { $post = $this->request->post(); $check = $this->validate($post, 'app\api\validate\Cart.selected'); if (true !== $check) { return $this->fail($check); } CartLogic::selected($post, $this->userId); return $this->success(); } public function num() { return $this->success('',CartLogic::cartNum($this->userId)); } }