Exemplo n.º 1
0
function GZ_user_info($user_id)
{
    global $db, $ecs;
    $user_info = user_info($user_id);
    $collection_num = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('collect_goods') . " WHERE user_id='{$user_id}' ORDER BY add_time DESC");
    $await_pay = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'" . GZ_order_query_sql('await_pay'));
    $await_ship = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'" . GZ_order_query_sql('await_ship'));
    $shipped = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'" . GZ_order_query_sql('shipped'));
    $finished = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'" . GZ_order_query_sql('finished'));
    // include_once(ROOT_PATH .'includes/lib_clips.php');
    // $rank = get_rank_info();
    // print_r($rank);exit;
    /* 取得用户等级 */
    if ($user_info['user_rank'] == 0) {
        // 非特殊等级,根据等级积分计算用户等级(注意:不包括特殊等级)
        $sql = 'SELECT rank_id, rank_name FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE special_rank = '0' AND min_points <= " . intval($user_info['rank_points']) . ' AND max_points > ' . intval($user_info['rank_points']);
    } else {
        // 特殊等级
        $sql = 'SELECT rank_id, rank_name FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE rank_id = '{$user_info['user_rank']}'";
    }
    if ($row = $GLOBALS['db']->getRow($sql)) {
        $user_info['user_rank_name'] = $row['rank_name'];
    } else {
        $user_info['user_rank_name'] = '非特殊等级';
    }
    $sql = 'SELECT * FROM ' . $GLOBALS['ecs']->table('user_rank') . " WHERE special_rank = '0' AND min_points = '0'";
    $row = $GLOBALS['db']->getRow($sql);
    if ($user_info['user_rank_name'] == $row['rank_name']) {
        $level = 0;
    } else {
        $level = 1;
    }
    return array('id' => $user_info['user_id'], 'name' => $user_info['user_name'], 'rank_name' => $user_info['user_rank_name'], 'rank_level' => $level, 'collection_num' => $collection_num, 'email' => $user_info['email'], "order_num" => array('await_pay' => $await_pay, 'await_ship' => $await_ship, 'shipped' => $shipped, 'finished' => $finished));
}
Exemplo n.º 2
0
/**
 *  获取用户指定范围的订单列表
 *
 * @access  public
 * @param   int         $user_id        用户ID号
 * @param   int         $num            列表最大数量
 * @param   int         $start          列表起始位置
 * @return  array       $order_list     订单列表
 */
function GZ_get_user_orders($user_id, $num = 10, $start = 0, $type = 'await_pay')
{
    /* 取得订单列表 */
    $arr = array();
    $sql = "SELECT order_id, order_sn, order_status, shipping_status, pay_status, add_time, " . "(goods_amount + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee + tax - discount) AS total_fee " . " FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE user_id = '{$user_id}' " . GZ_order_query_sql($type) . " ORDER BY add_time DESC";
    // print_r($sql);exit;
    $res = $GLOBALS['db']->SelectLimit($sql, $num, $start);
    while ($row = $GLOBALS['db']->fetchRow($res)) {
        $row['shipping_status'] = $row['shipping_status'] == SS_SHIPPED_ING ? SS_PREPARING : $row['shipping_status'];
        $row['order_status'] = $GLOBALS['_LANG']['os'][$row['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$row['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$row['shipping_status']];
        $arr[] = array('order_id' => $row['order_id'], 'order_sn' => $row['order_sn'], 'order_time' => local_date($GLOBALS['_CFG']['time_format'], $row['add_time']), 'order_status' => $row['order_status'], 'total_fee' => price_format($row['total_fee'], false));
    }
    return $arr;
}