post(); $pageSize = request()->post('pageSize', 0); $datas = GoodsService::make()->getDataList($params, $pageSize,'', $this->userId); return message(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_goods_index", ['trace'=>$exception->getTrace()], 7200); return message(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 列表 * @return array */ public function list() { try { $params = request()->post(); $pageSize = request()->post('pageSize', 0); $datas = GoodsService::make()->getDataList($params, $pageSize,'lev_a.*,lev_c.name as merch_name', $this->userId); return message(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_goods_index", ['trace'=>$exception->getTrace()], 7200); return message(1018, false, ['error'=>env('APP_DEBUG')? $exception->getTrace() : '']); } } /** * 分类 * @return array */ public function category() { $params = request()->post(); $pageSize = request()->post('pageSize', 99); $datas = GoodsCategoryService::make()->getDataList($params, $pageSize); return message(1010, true, $datas); } /** * 详情 * @return array */ public function info() { $id = request()->post('id', 0); $info = GoodsService::make()->getInfo($id, $this->userId); return message(1010, true, $info); } /** * 推荐 * @return array */ public function recommend() { try { $params = request()->post(); $pageSize = request()->post('pageSize', 0); $lng = isset($params['lng'])? $params['lng'] : ''; $lat = isset($params['lat'])? $params['lat'] : ''; $params = [ 'lat'=> $lat? $lat : (isset($this->userInfo['lat'])? $this->userInfo['lat'] : ''), 'lng'=> $lng? $lng : (isset($this->userInfo['lng'])? $this->userInfo['lng'] : ''), 'sort_type'=> 1, 'is_recommend'=> 1, 'type'=> isset($params['type'])? intval($params['type']) : 2, 'status'=> 2, ]; $datas = GoodsService::make()->getDataList($params, $pageSize); return message(1010, true, $datas); } catch (\Exception $exception){ RedisService::set("caches:request:error_goods_recommend", ['trace'=>$exception->getTrace()], 7200); return message(1018, false, ['error'=>env('APP_DEBUG')? $exception->getMessage() : '']); } } /** * 发布 * @param GoodsValidator $validator * @return array */ public function submit(GoodsValidator $validator) { $params = request()->all(); $params = $validator->check($params, 'submit'); if (!is_array($params)) { return message($params, false); } if(!$result = GoodsService::make()->submit($this->userId, $params)){ return message(GoodsService::make()->getError(), false); }else{ return message(GoodsService::make()->getError(), true, $result); } } /** * 状态/上下架 * @return array|mixed */ public function status() { if(!$result = GoodsService::make()->status()){ return message(GoodsService::make()->getError(), false); }else{ return message(GoodsService::make()->getError(), true, $result); } } /** * 删除 * @return array|mixed */ public function delete() { return GoodsService::make()->delete(); } }