post(); $pageSize = request()->post('pageSize', 0); $datas = GoodsService::make()->getDataList($params, $pageSize,'', $this->userId); return showJson(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_goods_index", ['trace'=>$exception->getTrace()], 7200); return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 购买列表 * @return array */ public function buyList() { try { $params = request()->post(); $datas = GoodsService::make()->getBuyList($this->userId, $params); return showJson(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_goods_buy", ['trace'=>$exception->getTrace()], 7200); return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 分类 * @return array */ public function category() { $params = request()->post(); $pageSize = request()->post('pageSize', 99); $datas = GoodsCategoryService::make()->getDataList($params, $pageSize); return showJson(1010, true, $datas); } /** * 详情 * @return array */ public function info() { $id = request()->post('goods_id', 0); $info = GoodsService::make()->getInfo($id); return showJson(1010, true, $info); } /** * 运费 * @return array */ public function freight() { $addressId = request()->post('address_id', 0); $skuList = request()->post('sku_list', []); if($addressId<=0 || empty($skuList)){ return showJson(1009, false); } $info = GoodsService::make()->getFreight($this->userId, $addressId, $skuList); if($info){ return showJson(1010, true, $info); }else{ return showJson(GoodsService::make()->getError(), false); } } /** * 更新购物车 * @return array */ public function updateCart() { $params = request()->post(); $goodsId = request()->post('goods_id', 0); if(!$result = GoodsService::make()->updateCart($this->userId, $goodsId, $params)){ return showJson(GoodsService::make()->getError(), false); }else{ return showJson(1002, true, $result); } } /** * 购物车列表 * @return array */ public function cartList() { try { $pageSize = request()->post('pageSize', 30); $datas = GoodsService::make()->getCartList($this->userId, $pageSize); return showJson(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_cart_index", ['trace'=>$exception->getTrace()], 7200); return showJson(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 删除购物车商品 * @return array */ public function deleteCart() { $params = request()->post(); if(!$result = GoodsService::make()->deleteCart($this->userId, $params)){ return showJson(GoodsService::make()->getError(), false); }else{ return showJson(1002, true, $result); } } /** * 删除购物车商品 * @return array */ public function count() { $params = request()->post(); if(!$result = GoodsService::make()->count($this->userId, $params)){ return showJson(GoodsService::make()->getError(), false); }else{ return showJson(1002, true, $result); } } }