header('Authentication'); $appid = request()->header('appid'); //检查用户 if ($auth) { $this->user_id = Cache::get($auth); if ($this->user_id) { $user = User::query()->firstWhere(['id' => $this->user_id, 'status' => 1]); } if (empty($user)) { $this->error('用户不存在或已被禁用' . $this->user_id); exit(); } } //检查代理商 $agent = Agent::query()->firstWhere(['appid' => $appid, 'status' => 1]); if (!$agent) { $this->error('商户不存在或已被禁用'); exit(); } $this->agent_id = $agent->id; } protected function success($data = [], $msg = 'success', $code = 0, $status = 200) { return response()->json([ 'code' => $code, 'msg' => $msg, 'data' => $data, 'status' => $status, 'debug_time' => microtime(true) - LARAVEL_START ])->send(); } protected function error($msg = 'error', $code = -1, $status = 500) { return response()->json([ 'code' => $code, 'msg' => $msg, 'data' => [], 'status' => $status, 'debug_time' => microtime(true) - LARAVEL_START ])->send(); } }