data(CartLogic::getCartLists($this->userId)); } /** * @notes 添加 * @return \think\response\Json * @author 段誉 * @date 2021/7/19 19:10 */ public function add() { $params = (new CartValidate())->post()->gocheck('add', ['user_id' => $this->userId]); $result = CartLogic::addCart($params, $this->userId); if (true !== $result) { return $this->fail($result); } return $this->success('加入成功'); } /** * @notes 删除 * @return \think\response\Json * @author 段誉 * @date 2021/7/19 19:10 */ public function del() { $params = (new CartValidate())->post()->goCheck('del', ['user_id' => $this->userId]); CartLogic::del($params['cart_id'], $params['user_id']); return $this->success('删除成功'); } /** * @notes 批量删除 * @return \think\response\Json * @author lbzy * @datetime 2023-07-17 18:01:35 */ function del_ids() { $params = (new CartValidate())->post()->goCheck('delIds', [ 'user_id' => $this->userId ]); CartLogic::del_ids($params['cart_ids'], $params['user_id']); return $this->success('删除成功'); } /** * @notes 更改 商品item * @return \think\response\Json * @author lbzy * @datetime 2023-07-18 10:53:11 */ function edit_goods_item() { $params = (new CartValidate())->post()->goCheck('editSku', [ 'user_id' => $this->userId ]); CartLogic::edit_goods_item($params); return $this->success('成功'); } /** * @notes 变更购物车数量 * @return \think\response\Json * @author 段誉 * @date 2021/7/19 19:10 */ public function change() { $params = (new CartValidate())->post()->goCheck('change', ['user_id' => $this->userId]); $result = CartLogic::changeCartNum($params); if (true !== $result) { return $this->fail($result); } return $this->success(); } /** * @notes 选中状态 * @return \think\response\Json * @author 段誉 * @date 2021/7/19 19:10 */ public function selected() { $params = (new CartValidate())->post()->goCheck('selected', ['user_id' => $this->userId]); CartLogic::selected($params); return $this->success(); } /** * @notes 购物车数量 * @return \think\response\Json * @author 段誉 * @date 2021/7/19 19:11 */ public function num() { return $this->data(CartLogic::getCartNum($this->userId)); } }