微擎分销 计算下线

/*
     * 计算某个用户无限下级
     * 
     */
    // public function getTeamMember($id, $isFor=false)
    {
        global $_W;
        global $_GPC;
        static $arr = [];
        if ($isFor==true) $arr = array();
        // $isFor 用于释放内存
        
        //查询uid用户的直接下级
        $tempmerbers = pdo_fetchall('select id from ' . tablename('wx_shop_member') . ' where agentid=:agentid and uniacid=:uniacid ', array(':agentid' => $id, ':uniacid' => $_W['uniacid']));
        $arr = array_merge($arr, $tempmerbers);

        if (count($tempmerbers) > 0) {
        //再将上面查询到的直接下级递归查询下级
            foreach ($tempmerbers as $k => $value) {
              
                    $this->getTeamMember($value['id'],false);

            }
        }

        return $arr;
    }

猜你喜欢

转载自blog.csdn.net/weixin_42637737/article/details/83927040