创建支付后领取立减金活动
@param array $data
@return array
@throws Exceptions\InvalidResponseException
@throws Exceptions\LocalCacheException
484588
public function addActivity(array $data)
    {
        $url = "https://api.weixin.qq.com/card/mkt/activity/create?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
1040810
public function sendMessage(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MESSAGE_SEND_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result : $this->dump([self::WECHAT_BASE_URL . self::WECHAT_MESSAGE_SEND_PREFIX, $this->getAccessToken(), $data, $result]);
    }
97870
public function updateNewsMaterial(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MATERIAL_DELETE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && !$result['errcode'];
    }
1051736
public function uploadImg($data){
		if (!$this->access_token && !$this->checkAuth()) return false;
		//原先的上传多媒体文件接口使用 self::UPLOAD_MEDIA_URL 前缀
		$result = $this->http_post(self::API_URL_PREFIX.self::MEDIA_UPLOADIMG_URL.'access_token='.$this->access_token,$data,true);
		if ($result)
		{
			$json = json_decode($result,true);
			if (!$json || !empty($json['errcode'])) {
				$this->errCode = $json['errcode'];
				$this->errMsg = $json['errmsg'];
				return false;
			}
			return $json;
		}
		return false;
	}
726392
protected function buildTree(array $data)
    {
        $children                             = [];
        $properties                           = [];
        $properties[$this->_config['pk']]     = $this->_config['rootid'];
        $properties[$this->_config['parent']] = null;
        // 创建跟节点
        $this->nodes[$this->_config['rootid']] = $this->createNode($properties);

        foreach ($data as $row) {
            if (is_object($row)) {
                $row = $row->toArray();
            }
            $this->nodes[$row[$this->_config['pk']]] = $this->createNode($row);
            if (empty($children[$row[$this->_config['parent']]])) {
                $children[$row[$this->_config['parent']]] = [$row[$this->_config['pk']]];
            } else {
                $children[$row[$this->_config['parent']]][] = $row[$this->_config['pk']];
            }
        }

        foreach ($children as $pid => $childids) {
            foreach ($childids as $id) {
                if ((string) $pid === (string) $id) {
                    throw new InvalidParentException(
                        "节点ID引用了自己的ID作为父ID"
                    );
                }
                if (isset($this->nodes[$pid])) {
                    $this->nodes[$pid]->addChild($this->nodes[$id]);
                } else {
                    throw new InvalidParentException(
                        "节点ID{$id}使用不存在的父级ID{$pid}"
                    );
                }
            }
        }
    }
1346134
public function send(array $data)
    {
        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
140171
public function register(array $data)
    {
        $url = "https://api.weixin.qq.com/shakearound/account/register?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }
857027
private function _parseDataGroup($data, $item_callback)
    {   
        // 不要定义为 static, 否则最后多次调用会重复值
        $groups = array();
        if (is_array($data)) {              // 数组形式
            foreach ($data as $key => $value) {
                // 进行元素分析，元素的键为数字而值为数组，且其值的元素键为数字值为数组的进行递归
                if (is_numeric($key) && is_array($value)) {
                    // 方式一：分解数组为子项
                    //$temp = $this->_parseDataGroup($value, $item_callback); // 先临时存之
                    //$groups = array_merge($groups, $temp);
                    
                    // 方式二：不分解，在解析子项时处理数组格式
                    $groups[]   = call_user_func(array($this, $item_callback), $value);
                } elseif (!is_numeric($key) || !empty($value)) {    // 值不为空或键不是数字
                    $groups[]   = call_user_func(array($this, $item_callback), array($key => $value));
                }
            }
        } else {                            // 标量类型/null/其他，直接作为一个解析组
            $groups[]   = call_user_func(array($this, $item_callback), $data);
        }
        
        return $groups;
    }
1123272
public function delete($data = null)
    {
        // 分析查询表达式
        $options = $this->parseExpress();
        $pk      = $this->getPk();
        if (!is_null($data) && true !== $data) {
            if (!is_array($data)) {
                // 缓存标识
                $key = 'mongo:' . $options['table'] . '|' . $data;
            }
            // AR模式分析主键条件
            $this->parsePkWhere($data, $options);
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['$and'][$pk])) {
            $key = $this->getCacheKey($options['where']['$and'][$pk], $options);
        }

        if (true !== $data && empty($options['where'])) {
            // 如果不是强制删除且条件为空 不进行删除操作
            throw new Exception('delete without condition');
        }

        // 生成bulkWrite对象
        $bulk         = $this->builder->delete($options);
        $writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : null;
        // 执行操作
        $writeResult = $this->execute($options['table'], $bulk, $writeConcern);

        $result = $writeResult->getDeletedCount();
        if ($result) {
            if (!is_array($data) && is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $item[$pk]     = $val;
                $data          = $item;
            }
            $options['data'] = $data;
            $this->trigger('after_delete', $options);
        }
        return $result;
    }
893033
public function getUserShakeInfo(array $data)
    {
        $result = $this->wechat->httpPost(self::WECHAT_USER_SHAKE_INFO_GET_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errcode']) && !$result['errcode'] ? $result['data'] : false;
    }
77750
public function createCard(array $data)
    {
        $result = $this->wechat->httpRaw(self::WECHAT_CARD_CREATE_PREFIX, $data, [
            'access_token' => $this->wechat->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] === 'ok' ? $result['card_id'] : false;
    }
562020
private function format($data)
    {
        $_data = [];
        foreach ($data as $fields => $value) {
            $fields = array_map('trim', explode(',', $fields)); //拆分多个字段一个值，形如['field1,field2'=>value]
            foreach ($fields as $field) {
                $_data[$field] = $value;
            }
        }
        return $_data;
    }
1256075
public function createUser(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_USER_CREATE_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errcode']) && ($result['errcode'] ? $this->dump([$data,$result,$this->getAccessToken()]) : !$result['errcode']);
    }
1187522
protected function fieldSet(array $data)
    {
        if (!$this->tableSchema['field']) {
            throw new Exception('请在' . get_class($this) . '构造函数中调用父类的构造函数');
        }
        return \wf\db\QueryBuilder::buildSqlSet($data, $this->tableSchema['field'], $this->lockedFields);
    }
971851
public function updateIndexOne(array $data)
    {
        if (!is_array($data)) {
            throw new \Exception('你的索引参数不是一个数组');
        }

        if (count($data) == count($data, 1)) {
            // 一维数组
            $this->getIndex()->update(new \XSDocument($data));
        }

        //索引是否立即生效
        if ($this->flush_index) {
            $this->getIndex()->flushIndex();
        }

        return $this->getIndex();
    }
798777
public function update(array $data)
    {
        $this->compileData($data);
        $arguments      = $this->arguments;
        $sql            = 'UPDATE '.$this->getFrom().' SET '.$this->setString;
        //设置了条件
        if ($this->condition->count() > 0) {
            $whereStr       = (string)$this->condition->compile();
            $whereArguments = $this->condition->arguments();
            $sql            = $sql.' where '.$whereStr;
            $arguments      = ArrayLib::array_add($arguments, $whereArguments);
        }
        return $this->connection->executeUpdate($sql, $arguments);
    }
205654
public function queryPage(array $data)
    {
        $url = "https://api.weixin.qq.com/shakearound/relation/search?access_token=ACCESS_TOKEN";
        $this->registerApi($url, __FUNCTION__, func_get_args());
        return $this->httpPostForJson($url, $data);
    }