apiVerify(); } /** * @throws ApiException */ protected function apiVerify() { if ($this->noAppMode) { return; } $appID = trim(request()->input('app_id')); if (!is_numeric($appID)) { throw new ApiException('不符合标准的appID'); } $appSet = OutsideAppSetting::where('app_id', $appID)->first(); if (!$appSet) { throw new ApiException('应用不存在'); } if (!$appSet->is_open) { throw new ApiException('应用已关闭'); } $this->outsideApp = $appSet; //$this->setCurrentUniacid($appSet->uniacid); //开启签名验证,签名验证失败 if(!$appSet->sign_required && !$this->appSignVerify()) { throw new ApiException('签名验证失败'); } } protected function appSignVerify() { //过滤掉路由地址参数 $requestData = request()->except(request()->getRequestUri()); return (new NotifyService($requestData))->verifySign(); } //设置公众号 protected function setCurrentUniacid($uniacid) { \Setting::$uniqueAccountId = \YunShop::app()->uniacid = $uniacid; AccountWechats::setConfig(AccountWechats::getAccountByUniacid(\YunShop::app()->uniacid)); } }