关闭支付宝进行中的订单
@param array|string $options
@return array|boolean
@throws InvalidResponseException
@throws \WeChat\Exceptions\LocalCacheException
559961
public function close($options)
    {
        if (!is_array($options)) $options = ['out_trade_no' => $options];
        $this->options->set('method', 'alipay.trade.close');
        return $this->getResult($options);
    }
5529
public function buildSelectSql($options=array()) {
        if(isset($options['page'])) {
            // 根据页数计算limit
            list($page,$listRows)   =   $options['page'];
            $page    =  $page>0 ? $page : 1;
            $listRows=  $listRows>0 ? $listRows : (is_numeric($options['limit'])?$options['limit']:20);
            $offset  =  $listRows*($page-1);
            $options['limit'] =  $offset.','.$listRows;
        }
        $sql  =   $this->parseSql($this->selectSql,$options);
        return $sql;
    }
871427
public function convert($options = array()){
		if(!is_array($options)){
			$options = array();
		}
		$this->convert_options = $options;

		$html = $this->html_original;

		// DOCTYPE を書き換える
		$html = preg_replace('/^(?:\s*\<!DOCTYPE.*?>)?/is', '<!DOCTYPE html>', $html);

		set_time_limit(60);

		// body要素をAMP変換する
		$html = $this->convert_body_to_amp($html);

		set_time_limit(60);

		// head要素をAMP変換する
		$html = $this->convert_head_to_amp($html);

		set_time_limit(60);

		// script要素をAMP変換する
		$html = $this->convert_script_to_amp($html);

		set_time_limit(60);

		// style要素をAMP変換する
		$html = $this->convert_style_to_amp($html);

		set_time_limit(60);

		// 条件付きコメントを削除する
		$html = $this->remove_conditional_comment($html);

		set_time_limit(60);

		// HTML要素に `amp` 属性を付加
		$simple_html_dom = $this->utils->create_simple_html_dom($html);
		$ret = $simple_html_dom->find('html');
		foreach( $ret as $retRow ){
			$retRow->amp = true;
		}
		$html = $simple_html_dom->outertext;

		set_time_limit(30);
		return $html;
	}
1146287
public function select($options=array()) {
        $this->model  =   $options['model'];
        $this->parseBind(!empty($options['bind'])?$options['bind']:array());
        $sql    = $this->buildSelectSql($options);
        $result   = $this->query($sql,!empty($options['fetch_sql']) ? true : false);
        return $result;
    }
1104106
private function _parseOptions($options=null)
    {
        if (!$options) return [];
        
        // 如果配置为多组式配置，取出其中一组
        $item = current($options);
        if (!isset($options['adapter']) && is_array($item) && isset($item['username'])) {
            $item = ArrayHelper::getItemArray($options);
            $options = array_values($item)[0];
        }
        
        // first check if dsn
        if (isset($options['dsn'])) {
            $options = static::parseDsn($options['dsn']);
        }
        
        // type is alias of adapter
        if (isset($options['type'])) {
            $options['adapter'] = $options['type'];
        }
        if (isset($options['adapter'])) {
            $options['adapter'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $options['adapter']);
            $options['adapter'] = StringHelper::toCamelCase($options['adapter']);
            if ($options['adapter'] == 'Mysqli') {
                $options['adapter'] = 'Mysql';
            }
        }
        
        // dbname is alias of database
        if (isset($options['dbname'])) {
            $options['database'] = $options['dbname'];
            unset($options['dbname']);
        }
        
        // check database
        if (isset($options['database'])) {
            $options['database'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $options['database']);
        }
        
        return $options;
    }
787340
public function insert(array $data, $options = [])
    {
        // 分析并处理数据
        $data = $this->parseData($data, $options);
        $bulk = new BulkWrite;
        if ($insertId = $bulk->insert($data)) {
            $this->insertId = $insertId;
        }
        $this->log('insert', $data, $options);
        return $bulk;
    }
598268
protected function assertRequiredOptions($key, array $options)
    {
        $missing = array_diff_key(array_flip($this->getRequiredOptions($key)), $options);
        if (!empty($missing)) {
            throw new \InvalidArgumentException(
                '参数不完整，请指定'.$key.'参数: '.implode(', ', array_keys($missing))
            );
        }
    }
817027
protected function executeCurl(array $options)
    {
        curl_setopt_array($this->curl, $options);

        $result = curl_exec($this->curl);
        self::curlValidate($this->curl, $result);
        if ($result === false) {
            throw new HttpException(curl_error($this->curl), curl_errno($this->curl));
        }

        return $result;
    }
788690
public function command($command=array(), $options=array()) {
        $cache  =  isset($options['cache'])?$options['cache']:false;
        if($cache) { // 查询缓存检测
            $key =  is_string($cache['key'])?$cache['key']:md5(serialize($command));
            $value   =  S($key,'','',$cache['type']);
            if(false !== $value) {
                return $value;
            }
        }
        N('db_write',1); // 兼容代码
        $this->executeTimes++;
        try{
            if($this->config['debug']) {
                $this->queryStr   =  $this->_dbName.'.'.$this->_collectionName.'.runCommand(';
                $this->queryStr  .=  json_encode($command);
                $this->queryStr  .=  ')';
            }
            $this->debug(true);
            $result   = $this->_mongo->command($command);
            $this->debug(false);
            
            if($cache && $result['ok']) { // 查询缓存写入
                S($key,$result,$cache['expire'],$cache['type']);
            }
            return $result;
        } catch (\MongoCursorException $e) {
            E($e->getMessage());
        }
    }
423324
protected function request($options = [])
    {
        try {
            $params = array_filter($this->params);
            $response = $this->getClient()
                ->get($this->getUrl(), ['query' => $params], $options);

            return trim($this->format) === 'json'
                ? json_decode($response->getBody(), true)
                : simplexml_load_string($response->getBody());
        } catch (RequestException $e) {
            return null;
        }
    }
161395
public function deleteByQuery($options = [])
    {
        if (!isset($this->queryParts['query'])) {
            throw new InvalidCallException('Can not call deleteByQuery when no query is given.');
        }
        $query = [
            'query' => $this->queryParts['query'],
        ];
        if (isset($this->queryParts['filter'])) {
            $query['filter'] = $this->queryParts['filter'];
        }
        $query = Json::encode($query);
        $url = [$this->index !== null ? $this->index : '_all'];
        if ($this->type !== null) {
            $url[] = $this->type;
        }
        $url[] = '_query';

        return $this->db->delete($url, array_merge($this->options, $options), $query);
    }
194010
public function request($url, $method = self::GET, $params = array(), $options = array(), $retry = 1)
    {
        if ($this->token) {
            $url = preg_replace('/[\?&]access_token=.*?/i', '', $url);
            $url .= (stripos($url, '?') ? '&' : '?').'access_token='. $this->token->getToken();
        }

        $method = strtoupper($method);

        if ($this->json) {
            $options['json'] = true;
        }

        $response = parent::request($url, $method, $params, $options);

        $this->json = false;

        if (empty($response['data'])) {
            throw new Exception('服务器无响应');
        }

        if (!preg_match('/^[\[\{]\"/', $response['data'])) {
            return $response['data'];
        }

        $contents = json_decode($response['data'], true);

        // while the response is an invalid JSON structure, returned the source data
        if (JSON_ERROR_NONE !== json_last_error()) {
            return $response['data'];
        }

        if (isset($contents['errcode']) && 0 !== $contents['errcode']) {
            if (empty($contents['errmsg'])) {
                $contents['errmsg'] = 'Unknown';
            }

            // access token 超时重试处理
            if ($this->token && in_array($contents['errcode'], array('40001', '42001')) && $retry > 0) {
                // force refresh
                $this->token->getToken(true);

                return $this->request($url, $method, $params, $options, --$retry);
            }

            throw new Exception("[{$contents['errcode']}] ".$contents['errmsg'], $contents['errcode']);
        }

        if ($contents === array('errcode' => '0', 'errmsg' => 'ok')) {
            return true;
        }

        return $contents;
    }
1293031
public function open(array $options = [])
    {
        // Set the HTML5 role.
        $options['role'] = 'form';

        // Set the class for the form type.
        if (!array_key_exists('class', $options)) {
            $options['class'] = $this->getType();
        }

        if (array_key_exists('left_column_class', $options)) {
            $this->setLeftColumnClass($options['left_column_class']);
        }

        if (array_key_exists('left_column_offset_class', $options)) {
            $this->setLeftColumnOffsetClass($options['left_column_offset_class']);
        }

        if (array_key_exists('right_column_class', $options)) {
            $this->setRightColumnClass($options['right_column_class']);
        }

        array_forget($options, [
            'left_column_class',
            'left_column_offset_class',
            'right_column_class'
        ]);

        if (array_key_exists('model', $options)) {
            return $this->model($options);
        }

        if (array_key_exists('error_bag', $options)) {
            $this->setErrorBag($options['error_bag']);
        }

        return $this->form->open($options);
    }
148071
protected function exec(array $options = [])
    {
        // cURL init and options
        $curl = curl_init();

        // we avoid curl_setopt_array($curl, $options) because extrange Windows behaviour (issue #8)
        foreach($options as $option => $value)
        {
            curl_setopt($curl, $option, $value);
        }

        // make the request
        if(is_null($this->callback))
        {
            $this->response = curl_exec($curl);
        }
        else
        {
            $this->response = '';
            curl_exec($curl);
        }

        // exception if cURL fails
        if(curl_errno($curl))
        {
            throw new Exception(curl_error($curl), curl_errno($curl));
        }

        // return the response and the status code
        return [trim($this->response), curl_getinfo($curl, CURLINFO_HTTP_CODE)];
    }
238593
public static function createTables($options) {

        //创建数据表
        if ( !$options['xmlpath'] ) {
            return tprintError("Please specified the --xmlpath option");
        }
        $options['xmlpath'] = self::getXmlFilename($options['xmlpath']);
        if ( !file_exists($options['xmlpath']) ) {
            return tprintError("File not found '{$options['xmlpath']}'");
        }
        $xml = new SimpleHtmlDom(file_get_contents($options['xmlpath']));
        DBFactory::createTables($xml);
    }
1072409
protected function callHttp(array $options)
    {
        $options += [
            'method' => 'post',
            'dataType' => 'json',
            'throwException' => false,
        ];
        $options['url'] = $this->baseUrl . $options['url'];
        $options['data'] = json_encode($options['data'], JSON_UNESCAPED_UNICODE);

        $http = $this->http($options);

        return $this->parseResponse($http, $options);
    }
1099970
public function execute($options = [])
    {
        if (! is_array($options) && ! $options instanceof Option) throw new \InvalidArgumentException('invalid option');

        $option = $this->getOption();
        if (is_array($options)) {
            $option->importFromArray($options);
        } else {
            $option->import($options);
        }
        $option->validate();

        $this->method->invoke($this->list, $option);
    }