解析返回的结果
@param array $result
@return bool|array
355665
protected function _parseResult($result)
    {
        if (empty($result)) {
            $this->errCode = 'result error';
            $this->errMsg = '解析返回结果失败';
            return false;
        }
        if ($result['return_code'] !== 'SUCCESS') {
            $this->errCode = $result['return_code'];
            $this->errMsg = $result['return_msg'];
            return false;
        }
        if (isset($result['err_code']) && $result['err_code'] !== 'SUCCESS') {
            $this->errMsg = $result['err_code_des'];
            $this->errCode = $result['err_code'];
            return false;
        }
        return $result;
    }
614075
public function write(&$result)
    {
        $container = $this->accessor->getPropertyValue($result, $this->definition->container());
        if (empty($container)) {
            $conditions = [];
            foreach ($this->definition->keys() as $local => $foreign) {
                $conditions[$foreign][] = $this->accessor->getPropertyValue($result, $local);
            }

            $this->cleanup($this->definition->entity(), [], $conditions);
            return $result;
        }

        $this->assertArrayAccess($container);

        foreach ($container as $relEntity) {
            foreach ($this->definition->keys() as $local => $foreign) {
                $this->accessor->setPropertyValue($relEntity, $foreign, $this->accessor->getPropertyValue($result, $local));
            }

            $this->storage->write($relEntity, $this->definition->entity())->execute();
        }

        $this->accessor->setPropertyValue($result, $this->definition->container(), $container);

        $conditions = [];
        foreach ($this->definition->keys() as $local => $foreign) {
            $conditions[$foreign] = $this->accessor->getPropertyValue($result, $local);
        }

        $this->cleanup($this->definition->entity(), $container, $conditions);

        return $result;
    }
458590
public function equals(Result $result): bool
    {
        if (null !== $this->score xor null !== $result->score) {
            return false;
        }

        if (null !== $this->score && !$this->score->equals($result->score)) {
            return false;
        }

        if ($this->success !== $result->success) {
            return false;
        }

        if ($this->completion !== $result->completion) {
            return false;
        }

        if ($this->response !== $result->response) {
            return false;
        }

        if ($this->duration !== $result->duration) {
            return false;
        }

        if (null !== $this->extensions xor null !== $result->extensions) {
            return false;
        }

        if (null !== $this->extensions && null !== $result->extensions && !$this->extensions->equals($result->extensions)) {
            return false;
        }

        return true;
    }
1331717
public function getResponse($result)
    {
        $content = $result->getContent();

        if ($result->headers->get('content-type') == 'application/json'){
            $content = json_decode($result->getContent(),true);
        }

        return array(
          'type' => 'rpc',
          'tid' => $this->tid,
          'action' => $this->action,
          'method' => $this->method,
          'result' => $content
        );
    }
171687
private function processResult(array $result)
    {
        $this->checkResponseStatus($result['http_code']);

        // Get decoded response data
        $responseArr = json_decode($result['response'], true);

        $this->checkJsonError();

        return $responseArr;
    }
492559
public function parseResult($results)
    {
        $simpleDataTable = $results->getDataTable()->toSimpleObject();

        foreach ($simpleDataTable->cols as $col) {
            $cols[] = $col['label'];
        }

        foreach ($simpleDataTable->rows as $row) {
            foreach ($row['c'] as $key => $value) {
                $rowData[$cols[$key]] = $value['v'];
            }

            $rows[] = $rowData;

            unset($rowData);
        }

        return [
            'cols' => $cols,
            'rows' => $rows,
        ];
    }
937227
protected function getRelation(&$result,$name='',$return=false) {
        if(!empty($this->_link)) {
            foreach($this->_link as $key=>$val) {
                    $mappingName =  !empty($val['mapping_name'])?$val['mapping_name']:$key; // 映射名称
                    if(empty($name) || true === $name || $mappingName == $name || (is_array($name) && in_array($mappingName,$name))) {
                        $mappingType = !empty($val['mapping_type'])?$val['mapping_type']:$val;  //  关联类型
                        $mappingClass  = !empty($val['class_name'])?$val['class_name']:$key;            //  关联类名
                        $mappingFields = !empty($val['mapping_fields'])?$val['mapping_fields']:'*';     // 映射字段
                        $mappingCondition = !empty($val['condition'])?$val['condition']:'1=1';          // 关联条件
                        $mappingKey =!empty($val['mapping_key'])? $val['mapping_key'] : $this->getPk(); // 关联键名
                        if(strtoupper($mappingClass)==strtoupper($this->name)) {
                            // 自引用关联 获取父键名
                            $mappingFk   =   !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
                        }else{
                            $mappingFk   =   !empty($val['foreign_key'])?$val['foreign_key']:strtolower($this->name).'_id';     //  关联外键
                        }
                        // 获取关联模型对象
                        $model = D($mappingClass);
                        switch($mappingType) {
                            case self::HAS_ONE:
                                $pk   =  $result[$mappingKey];
                                $mappingCondition .= " AND {$mappingFk}='{$pk}'";
                                $relationData   =  $model->where($mappingCondition)->field($mappingFields)->find();
                                if (!empty($val['relation_deep'])){
                                    $model->getRelation($relationData,$val['relation_deep']);
                                }                                
                                break;
                            case self::BELONGS_TO:
                                if(strtoupper($mappingClass)==strtoupper($this->name)) {
                                    // 自引用关联 获取父键名
                                    $mappingFk   =   !empty($val['parent_key'])? $val['parent_key'] : 'parent_id';
                                }else{
                                    $mappingFk   =   !empty($val['foreign_key'])?$val['foreign_key']:strtolower($model->getModelName()).'_id';     //  关联外键
                                }
                                $fk   =  $result[$mappingFk];
                                $mappingCondition .= " AND {$model->getPk()}='{$fk}'";
                                $relationData   =  $model->where($mappingCondition)->field($mappingFields)->find();
                                if (!empty($val['relation_deep'])){
                                    $model->getRelation($relationData,$val['relation_deep']);
                                }                                
                                break;
                            case self::HAS_MANY:
                                $pk   =  $result[$mappingKey];
                                $mappingCondition .= " AND {$mappingFk}='{$pk}'";
                                $mappingOrder =  !empty($val['mapping_order'])?$val['mapping_order']:'';
                                $mappingLimit =  !empty($val['mapping_limit'])?$val['mapping_limit']:'';
                                // 延时获取关联记录
                                $relationData   =  $model->where($mappingCondition)->field($mappingFields)->order($mappingOrder)->limit($mappingLimit)->select();
                                if (!empty($val['relation_deep'])){
                                    foreach($relationData as $key=>$data){                                    
                                        $model->getRelation($data,$val['relation_deep']);
                                        $relationData[$key]     =   $data;
                                    }                                      
                                }
                                break;
                            case self::MANY_TO_MANY:
                                $pk     =   $result[$mappingKey];
                                $prefix =   $this->tablePrefix;
                                $mappingCondition = " {$mappingFk}='{$pk}'";
                                $mappingOrder =  $val['mapping_order'];
                                $mappingLimit =  $val['mapping_limit'];
                                $mappingRelationFk = $val['relation_foreign_key']?$val['relation_foreign_key']:$model->getModelName().'_id';
                                if(isset($val['relation_table'])){
                                    $mappingRelationTable   =   preg_replace_callback("/__([A-Z_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $val['relation_table']);
                                }else{
                                    $mappingRelationTable   =   $this->getRelationTableName($model);
                                }
                                $sql = "SELECT b.{$mappingFields} FROM {$mappingRelationTable} AS a, ".$model->getTableName()." AS b WHERE a.{$mappingRelationFk} = b.{$model->getPk()} AND a.{$mappingCondition}";
                                if(!empty($val['condition'])) {
                                    $sql   .= ' AND '.$val['condition'];
                                }
                                if(!empty($mappingOrder)) {
                                    $sql .= ' ORDER BY '.$mappingOrder;
                                }
                                if(!empty($mappingLimit)) {
                                    $sql .= ' LIMIT '.$mappingLimit;
                                }
                                $relationData   =   $this->query($sql);
                                if (!empty($val['relation_deep'])){
                                    foreach($relationData as $key=>$data){                                    
                                        $model->getRelation($data,$val['relation_deep']);
                                        $relationData[$key]     =   $data;
                                    }                                      
                                }                                
                                break;
                        }
                        if(!$return){
                            if(isset($val['as_fields']) && in_array($mappingType,array(self::HAS_ONE,self::BELONGS_TO)) ) {
                                // 支持直接把关联的字段值映射成数据对象中的某个字段
                                // 仅仅支持HAS_ONE BELONGS_TO
                                $fields =   explode(',',$val['as_fields']);
                                foreach ($fields as $field){
                                    if(strpos($field,':')) {
                                        list($relationName,$nick) = explode(':',$field);
                                        $result[$nick]  =  $relationData[$relationName];
                                    }else{
                                        $result[$field]  =  $relationData[$field];
                                    }
                                }
                            }else{
                                $result[$mappingName] = $relationData;
                            }
                            unset($relationData);
                        }else{
                            return $relationData;
                        }
                    }
            }
        }
        return $result;
    }
842746
protected function _makeResult(array $result) {
        return Result::make($result, $this->getClient())->setModelClass($this->_fullModelClassNamePattern());
    }
1239954
public static function legalArrayResult($result)
    {

        if (isset($result['info']) && isset($result['status']) && $result['status'] && is_array($result['info']) && count($result['info']) > 0) {
            return true;
        }

        return false;
    }
967027
protected function wrapAll(array $result): array
    {
        $modelName = $this->getModelName();

        foreach ($result as &$entity) {
            $entity = $this->createModel($modelName, $entity);
        }

        return $result;
    }
295430
public function fetchAssoc($result = null)
    {
        $result = $result ? $result : $this->getResult();

        $rows = [];

        if ($result->rowCount() > 0) {
            $results = $result->fetchAll(\PDO::FETCH_ASSOC);
            foreach ($results as $key => $value) {
                $rows[$key] = $value;
            }
        }

        return $rows;
    }
1174500
protected function filterModelEventResults($result)
    {
        if (is_array($result)) {
            $result = array_filter($result, function ($response) {
                return ! is_null($response);
            });
        }

        return $result;
    }
1194021
public function parserResult($result)
    {
        if ($this->presenter instanceof PresenterInterface) {
            if ($result instanceof Collection || $result instanceof LengthAwarePaginator) {
                $result->each(function ($model) {
                    if ($model instanceof Presentable) {
                        $model->setPresenter($this->presenter);
                    }

                    return $model;
                });
            } elseif ($result instanceof Presentable) {
                $result = $result->setPresenter($this->presenter);
            }

            if (!$this->skipPresenter) {
                return $this->presenter->present($result);
            }
        }

        return $result;
    }
809838
protected function filterResult(Result $result)
    {
        $request = $result->getData('request') ?: array();
        foreach (array('AccountNumber', 'RoutingNumber') as $key) {
            if (array_key_exists($key, $request)) {
                $request[$key] = '[filtered]';
            }
        }

        $result->setData('request', $request);

        return $result;
    }
298754
final public static function adapter($result)
    {
        if (is_array($result)) {
            $arr = [];
            foreach ($result as $key => $value) {
                $arr[$key] = self::makeObject($value);
            }
            return $arr;
        }

        return self::makeObject($result);
    }
1083439
public function delete(&$result)
    {
        $entity = $this->accessor->getPropertyValue($result, $this->definition->container());
        if (empty($entity)) {
            return $result;
        }

        $mediator = [];

        foreach ($this->definition->localKeys() as $entityField => $mediatorField) {
            $mediator[$mediatorField] = $this->accessor->getPropertyValue($result, $entityField);
        }

        foreach ($this->definition->foreignKeys() as $mediatorField => $entityField) {
            $mediator[$mediatorField] = $this->accessor->getPropertyValue($entity, $entityField);
        }

        $this->storage->delete($mediator, $this->definition->mediator())->execute();
        $this->accessor->setPropertyValue($result, $this->definition->container(), $entity);

        return $result;
    }
990616
private static function unwrap(array $result): array
    {
        array_walk_recursive($result, function (&$value) {
            if ($value instanceof Image) {
                $value = $value->image;
            }
        });

        return $result;
    }