checkApp($params['app_id'] ?? null); $this->checkSign($params); $data = json_decode($params['data'], true); foreach ($this->defaults() as $key => $value) { if (isset($data[$key])) { if (empty($value) && empty($data[$key])) { $data[$key] = $value; } } else { $data[$key] = $value; } } $this->_data = $data; } protected function checkSign($params) { if (!Signer::verify($params, $this->app->app_key)) { throw new BusinessException('验签错误'); } if ($params['timestamp'] < time() - 6000) { throw new BusinessException('请求已过期'); } } protected function checkApp($appId) { if (is_null($appId)) { throw new BusinessException('[app_id]错误'); } $app = App::query()->where('app_id', $appId)->first(); if (is_null($app)) { throw new BusinessException('APP错误'); } $this->app = $app; } public function getApp() { return $this->app; } }