获取交易授权吗
@throws \Exception
968184
private function getAuthCode()
    {
        $err_no = [
            '1'   => '成功',
            '-11' => '錯誤的廠商 ID',
            '-12' => '廠商 ID 與當初申請之 IP 不符',
            '-13' => '此服務代碼目前無法使用',
            '-14' => '此服務代碼已超過使用期限',
            '-15' => '金額不符',
            '-16' => '金額不符',
            '-17' => '商家交易序號重複',
            '-19' => '系統發生問題',
        ];


        // 获取授权码
        $this->endpoint_auth .= '?' . http_build_query($this->parameter);
        $response = file_get_contents($this->endpoint_auth);
        $response = $this->xml2array($response);
        if ($response['ReturnMsgNo'] != 1) {
            $msg = $err_no[$response['ReturnMsgNo']];
            throw new \Exception($msg);
        }


        // 跳转URL
        if ($this->config['sandbox']) {
            $this->endpoint_login = $this->sandbox_endpoint_login;
        }

        $this->redirect = $this->endpoint_login . '?AuthCode=' . $this->auth_code;
        $this->transactionReference = $response['ReturnTradeSeq'];  // 交易ID For MyCard
        $this->auth_code = $response['ReturnAuthCode'];             // 交易授权码
    }
1091254
public function delete()
    {
        if (!$this->queueName) {
            throw new \Exception('QueueName 队列名称不存在');
        }

        if (!$this->message) {
            throw new \Exception('Message 消息不存在');
        }

        $params = [
            'queueName'     => $this->queueName,
            'receiptHandle' => $this->message->get('receiptHandle'),
        ];

        $request = new DeleteMessageRequest($params);

        try {
            $this->client->send($request);
        } catch (RequestException $e) {
            throw $e;
        } catch (ResponseException $e) {
            $message = $e->getBody();

            if (!$message->has('code')) {
                throw $e;
            } else if (!in_array($message->get('code'), ['4430', '4440'])) {    // 4430：句柄无效，4440：队列不存在
                throw $e;
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
898615
public function verify()
    {
        $data = $_POST;
        $sign = $data['sign'];
        unset($data['sign_type']);

        if (Helper::verify($data, $sign) === false) {
            throw new \Exception('支付宝异步通知验签失败');
        }

        foreach ($data as &$value) {
            $value = mb_convert_encoding($value, 'utf-8', $data['charset'] ? $data['charset'] : 'gb2312');
        }
        return $data;
    }
752723
public function updateModel(): bool
    {
        $this->getFromForm();
        if (!$this->save()) {
            throw new Exception(\Yii::t('app', 'Ошибка при обновлении в БД'));
        }
        return true;
    }
117309
public function verify()
    {
        $data = $_GET;
        $sign = $data['md5'];

        if (Helper::verify($data, $sign) === false) {
            throw new \Exception('盈华讯方异步通知验签失败');
        }
        return $data;
    }
654364
public function onWorkerStart()
    {
        if (empty($this->serverRoot))
        {
            throw new Exception('server root not set, please use WebServer::addRoot($domain, $root_path) to set server root path');
        }

        // 初始化HttpCache
        HttpCache::init();
        session_name(self::$sessionName);
        HttpCache::$sessionName = self::$sessionName;

        // 尝试执行开发者设定的onWorkerStart回调
        if ($this->_onWorkerStart)
        {
            call_user_func($this->_onWorkerStart, $this);
        }
    }
856660
final public function delete()
    {
        if (!$this->DB) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        $sql = "delete from " . $this->getTable() . " ";
        $where = $this->buildWhere();
        //条件判断
        //没有外部条件的时候查询当前对象是否有查询过的模型
        if (!$where && $this->isfind) {
            $this->where($this->pk, '=', $this->pkval);
            $where = $this->buildWhere();
        }
        if (!$where) {
            throw new \Error('删除全部数据请使用truncate方法', Exception::CODE_DATABASE_ERROR);
        }
        $sql .= $where;
        $this->sql = $sql;
        /**
         * 只获取sql
         */
        if ($this->justSql) {
            return true;
        }
        $ret = $this->DB->execute($sql);
        $this->resetCon();
        return $ret;
    }
206356
public function afterCreate()
    {
        //create company
        $company = new Companies();
        $company->name = $this->defaultCompanyName;
        $company->users_id = $this->getId();
        if (!$company->save()) {
            throw new Exception(current($company->getMessages()));
        }

        $this->default_company = $company->getId();

        if (!$this->update()) {
            throw new Exception(current($this->getMessages()));
        }
    }
413520
public function start()
    {
        $try = $this->tryStart();
        $this->log('debug', 'try start', [
            'result' => (int) $try,
        ]);

        if (!$try) {
            return false;
        }

        $this->log('info', 'Job start');

        // 把进程ID和开始时间记录到上下文中
        $this->setContext(self::KEY_PROC_ID, posix_getpid());
        $this->setContext(self::KEY_PROC_TIME, time());
        $this->saveContext();

        // 执行任务逻辑
        try {
            $this->execute();
        } catch (\Exception $ex) {
            $this->log('error', 'Job execute error', [
                'error' => $ex->getMessage(),
            ]);

            return false;
        }

        $this->stop();

        return true;
    }
65872
public function init()
    {
        $this->conf = $this->getConfiguration();
        if (!isset($this->conf)) {
            throw new Exception("Adapter configuration not set, cannot initialize");
        }
        $this->adapters = array();
        foreach ($this->conf['adapters'] as $key => $adapter) {
            $adapterConf = ArrayHelper::merge($this->conf['common'], $adapter);

            $adapterConf['paymentHandler'] = $this;
            $adapterConf['adapterTag'] = $key;
            $this->adapters[$key] = \Yii::createObject($adapterConf);
        }
    }
1082532
public function commit()
    {
        if (!$this->getIsActive()) {
            throw new Exception('Failed to commit transaction: transaction was inactive.');
        }

        $this->_level--;
        if ($this->_level === 0) {
            Log::debug('Commit transaction' . __METHOD__);
            $this->db->pdo->commit();
            $this->db->trigger(Connection::EVENT_COMMIT_TRANSACTION);
            return;
        }

        $schema = $this->db->getSchema();
        if ($schema->supportsSavepoint()) {
            Log::debug('Release savepoint ' . $this->_level . __METHOD__);
            $schema->releaseSavepoint('LEVEL' . $this->_level);
        } else {
            Log::info('Transaction not committed: nested transaction not supported' . __METHOD__);
        }
    }
1209371
public function respond()
	{
		echo "<h1>".$this->inspector->message()." <small>( ".$this->inspector->exception_name()." )</small></h1>";
		echo "<pre>".$this->inspector->exception()->getTraceAsString()."</pre>";
	}
223574
public function execAction()
    {
        //no action defined
        if(!$this->action) {
            throw new \Exception(sprintf('no action defined for subject %s', $this->name));
        }
        //exec method
        try {
            $this->checkTraitsInjections();
            $this->traitsInit();
            $this->{'exec'.$this->sanitizeAction($this->action)}();
        } catch(Exception $exception) {
        //no method defined
            throw new Exception(sprintf('no method for handling %s %s %s', AREA, $this->name, $this->action));
        }
    }
737706
final public function begin()
    {
        if (!$this->pdo) {
            throw  new Exception('您还没有连接数据库', Exception::CODE_DATABASE_ERROR);
        }
        if ($this->_begintransaction) {
            throw new Exception("已经开启了一个事务，请勿重新开启", Exception::CODE_DATABASE_ERROR);
        }
        $this->pdo->beginTransaction();
        $this->_begintransaction = true;
        return $this;
    }
575076
public function execute()
    {
        $success = false;

        try {
            $file = $this->getDirectory() . DIRECTORY_SEPARATOR . $this->getFilename();
            $phar = new PHPPhar($file, 0, $this->getFilename());
            $phar->buildFromDirectory($this->getPHPCI()->buildPath, $this->getRegExp());

            $stub = $this->getStubContent();
            if ($stub) {
                $phar->setStub($stub);
            }

            $success = true;
        } catch (Exception $e) {
            $this->getPHPCI()->log(Lang::get('phar_internal_error'));
            $this->getPHPCI()->log($e->getMessage());
        }

        return $success;
    }
533206
public function callback() {
        $xml = app('request')->input();
        if (empty($xml)) {
            throw new Exception(
                __('xml error')
            );
        }
        /**
         * 禁止引用外部xml实体
         */
        $disableLibxmlEntityLoader = libxml_disable_entity_loader(true);
        $args = Xml::specialDecode($xml);
        libxml_disable_entity_loader($disableLibxmlEntityLoader);
        Factory::log()
            ->info('WECHAT PAY CALLBACK: '.app('request')->input());
        if (!is_array($args)) {
            throw new Exception(
                __('xml error')
            );
        }
        if ($args['return_code'] != 'SUCCESS') {
            throw new Exception($args['return_msg']);
        }
        if (!$this->verify($args)) {
            throw new Exception(
                __('verify sign error')
            );
        }
        return $args;
    }
1045166
public function handle()
    {
        $tableConfigFile = $this->input->getOption('config');
        if ($tableConfigFile && ! file_exists($tableConfigFile)) {
            throw new \Exception(sprintf('The configuration file "%s" does not exist!', $tableConfigFile));
        }

        if ($tableConfigFile) {
            $tableConfig = include_once( $tableConfigFile );
        }
        if ( ! empty( $tableConfig )) {
            self::$tables = $tableConfig;
        }

        $this->createTables();
    }