middleware('auth.api'); // $this->user = \Auth::guard('api')->user(); // $this->uid = \Auth::guard('api')->id(); $this->user = User::find(824); $this->uid = 824; } public function index() { // if ($this->user->identity->identity_id == 0) { // return $this->failed('请开通VIP后继续操作'); // } $sellers = Seller::with(['storage'])->get(); return SellerListResource::collection($sellers)->additional([ 'status' => 'SUCCESS', 'status_code' => 200, ]); } public function show(Seller $seller) { // if ($this->user->identity->identity_id == 0) { // return $this->failed('请开通VIP后继续操作'); // } $hotGoods = Goods::with(['storage']) ->where('status', 1) ->where('seller_id', $seller->id) ->where('status', 1) ->whereHas('params', function ($query) { return $query->where('stock', '>', 0)->where('status', 1)->where('score', '>', 0)->whereRaw('price > score'); }) ->select('id', 'title', 'description', 'storage_id', 'score') ->orderBy('created_at', 'desc') ->limit(500) ->get(); $hotGoodsScore = Goods::with(['storage']) ->where('status', 1) ->where('seller_id', $seller->id) ->where('status', 1) ->whereHas('params', function ($query) { return $query->where('stock', '>', 0)->where('status', 1)->where('score', '>', 0)->whereRaw('price = score'); }) ->select('id', 'title', 'description', 'storage_id', 'score') ->orderBy('created_at', 'desc') ->limit(500) ->get(); $hotGoodsCash = Goods::with(['storage']) ->where('status', 1) ->where('seller_id', $seller->id) ->where('status', 1) ->whereHas('params', function ($query) { return $query->where('stock', '>', 0)->where('status', 1)->where('score', 0); }) ->select('id', 'title', 'description', 'storage_id', 'score') ->orderBy('created_at', 'desc') ->limit(500) ->get(); return [ 'data' => [ 'seller_info' => new SellerListResource($seller), 'hotGoods' => GoodsParamsListResource::collection($hotGoods), 'hotGoodsScore' => GoodsParamsListResource::collection($hotGoodsScore), 'hotGoodsCash' => GoodsParamsListResource::collection($hotGoodsCash), ], 'status' => 'SUCCESS', 'status_code' => 200, ]; } }