Example #1
0
    exit;
}
$is_distribor = is_distribor($_SESSION['user_id']);
if ($is_distribor != 1) {
    show_message('您还不是分销商!', '去首页', 'index.php');
    exit;
}
if (!$smarty->is_cached('v_user.dwt', $cache_id)) {
    assign_template();
    $position = assign_ur_here();
    $smarty->assign('page_title', $position['title']);
    // 页面标题
    $smarty->assign('ur_here', $position['ur_here']);
    // 当前位置
    /* meta information */
    $smarty->assign('keywords', htmlspecialchars($_CFG['shop_keywords']));
    $smarty->assign('description', htmlspecialchars($_CFG['shop_desc']));
    $user_info = get_user_info_by_user_id($_SESSION['user_id']);
    //用户信息,包括昵称和头像
    $user_money = get_user_money_by_user_id($_SESSION['user_id']);
    //用户余额
    $split_money = get_split_money_by_user_id($_SESSION['user_id']);
    //分成总金额
    $smarty->assign('user_info', $user_info);
    $smarty->assign('user_money', $user_money);
    $smarty->assign('split_money', $split_money);
    $smarty->assign('user_id', $_SESSION['user_id']);
    /* 页面中的动态内容 */
    assign_dynamic('v_user');
}
$smarty->display('v_user.dwt', $cache_id);
Example #2
0
function get_all_distrib_order_by_user_id($user_id, $is_separate, $page, $size)
{
    $call_username = $GLOBALS['_CFG']['call_username'];
    $up_uid = $user_id;
    $all_uid = '';
    //$ret[0] = array($user_id);
    for ($i = 1; $i <= 3; $i++) {
        //$j = $i-1;
        //if (count($ret[$j])>0)
        if ($up_uid) {
            //$sql = "SELECT user_id FROM " . $GLOBALS['ecs']->table('users') . " WHERE parent_id IN(".implode(',',$ret[$j]).")";
            $sql = "SELECT user_id FROM " . $GLOBALS['ecs']->table('users') . " WHERE parent_id IN({$up_uid})";
            //$ret[$i] = $GLOBALS['db']->getCol($sql);
            $query = $GLOBALS['db']->query($sql);
            $up_uid = '';
            while ($rt = $GLOBALS['db']->fetch_array($query)) {
                $up_uid .= $up_uid ? ",{$rt['user_id']}" : "{$rt['user_id']}";
            }
            if ($up_uid) {
                $all_uid .= $up_uid . ',';
            }
        }
    }
    $uids = rtrim($all_uid, ',');
    if (!empty($uids)) {
        $sql = "SELECT order_id FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE user_id in({$uids})";
        $order_list = $GLOBALS['db']->getAll($sql);
        $oids = '';
        //分销商下所有下级会员的订单id
        for ($i = 0; $i < count($order_list); $i++) {
            if ($i == 0) {
                $oids .= $order_list[$i]['order_id'];
            } else {
                $oids .= ',' . $order_list[$i]['order_id'];
            }
        }
        if (!empty($oids)) {
            $sql = "SELECT og.order_id,og.goods_id,og.goods_name,o.user_id,g.goods_thumb,u.user_name FROM " . $GLOBALS['ecs']->table('order_goods') . " as og , " . $GLOBALS['ecs']->table('order_info') . " as o , " . $GLOBALS['ecs']->table('goods') . " as g, " . $GLOBALS['ecs']->table('users') . " as u " . "WHERE og.order_id = o.order_id AND og.goods_id = g.goods_id AND o.user_id = u.user_id AND og.split_money > 0 AND og.order_id in({$oids}) AND is_separate = '{$is_separate}'";
            if (isset($size) && isset($page)) {
                $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size);
            } else {
                $res = $GLOBALS['db']->query($sql);
            }
            $arr = array();
            while ($row = $GLOBALS['db']->fetchRow($res)) {
                $arr[$row['order_id']]['goods_name'] = $row['goods_name'];
                $arr[$row['order_id']]['goods_thumb'] = $row['goods_thumb'];
                $info = get_user_info_by_user_id($row['user_id']);
                $arr[$row['order_id']]['nickname'] = $info['nickname'];
                if ($call_username == 1) {
                    $arr[$row['order_id']]['call_username'] = '******' . $row['user_id'];
                } else {
                    $arr[$row['order_id']]['call_username'] = '******' . $row['user_name'];
                }
                $arr[$row['order_id']]['user_name'] = $row['user_name'];
                $arr[$row['order_id']]['split_money'] = price_format(get_split_money_by_user_id($row['user_id']));
                $arr[$row['order_id']]['level'] = get_level_user($user_id, $row['user_id']);
            }
            if (!empty($arr)) {
                return $arr;
            }
        }
    }
    return array();
}