function get_user_rank_prices($goods_id, $shop_price)
{
$sql = "SELECT rank_id,max_points, INULLmp.user_price, r.discount * $shop_price / 100) AS price, r.rank_name, r.discount " .
'FROM ' . $GLOBALS['ecs']->table('user_rank') . ' AS r ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = '$goods_id' AND mp.user_rank = r.rank_id " .
"WHERE r.show_price = 1 OR r.rank_id = '$_SESSION[user_rank]'";
$res = $GLOBALS['db']->getAll($sql);
$user_points = get_fine_user_points($_SESSION['user_id']); //
$arr = array();
foreach($res as $row)
{
$arr[$row['rank_id']]['rank_name'] = htmlspecialchars($row['rank_name']);
$arr[$row['rank_id']]['max_points'] = $row['max_points'];
$user_rank = get_fine_user_rank($user_points,$row['max_points']);
$arr[$row['rank_id']]['user_rank_maxPoints'] = $user_rank['max_points_level']; //
$arr[$row['rank_id']]['price'] = price_format($row['price']);
}
return $arr;
}
|