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