/** * 获得用户所在时区指定的时间戳 * * @param $timestamp integer 该时间戳必须是一个服务器本地的时间戳 * * @return array */ function local_gettime($timestamp = NULL) { $tmp = local_getdate($timestamp); return $tmp[0]; }
$goods['promote'] = $db->GetOne('SELECT COUNT(*) FROM ' . $ecs->table('goods') . ' WHERE is_delete = 0 AND promote_price>0' . " AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' AND is_real = 1"); $virtual_card['promote'] = $db->GetOne('SELECT COUNT(*) FROM ' . $ecs->table('goods') . ' WHERE is_delete = 0 AND promote_price>0' . " AND promote_start_date <= '{$time}' AND promote_end_date >= '{$time}' AND is_real=0 AND extension_code='virtual_card'"); /* 缺货商品 */ if ($_CFG['use_storage']) { $sql = 'SELECT COUNT(*) FROM ' . $ecs->table('goods') . ' WHERE is_delete = 0 AND goods_number <= warn_number AND is_real = 1'; $goods['warn'] = $db->GetOne($sql); $sql = 'SELECT COUNT(*) FROM ' . $ecs->table('goods') . ' WHERE is_delete = 0 AND goods_number <= warn_number AND is_real=0 AND extension_code=\'virtual_card\''; $virtual_card['warn'] = $db->GetOne($sql); } else { $goods['warn'] = 0; $virtual_card['warn'] = 0; } $smarty->assign('goods', $goods); $smarty->assign('virtual_card', $virtual_card); /* 访问统计信息 */ $today = local_getdate(); $sql = 'SELECT COUNT(*) FROM ' . $ecs->table('stats') . ' WHERE access_time > ' . (mktime(0, 0, 0, $today['mon'], $today['mday'], $today['year']) - date('Z')); $today_visit = $db->GetOne($sql); $smarty->assign('today_visit', $today_visit); $online_users = $sess->get_users_count(); $smarty->assign('online_users', $online_users); /* 最近反馈 */ $sql = "SELECT COUNT(f.msg_id) " . "FROM " . $ecs->table('feedback') . " AS f " . "LEFT JOIN " . $ecs->table('feedback') . " AS r ON r.parent_id=f.msg_id " . 'WHERE f.parent_id=0 AND ISNULL(r.msg_id) '; $smarty->assign('feedback_number', $db->GetOne($sql)); /* 未审核评论 */ $smarty->assign('comment_number', $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('comment') . ' WHERE status = 0 AND parent_id = 0')); $mysql_ver = $db->version(); // 获得 MySQL 版本 /* 系统信息 */ $sys_info['os'] = PHP_OS; $sys_info['ip'] = $_SERVER['SERVER_ADDR'];
/** * 获取我的债券列表 * * @access public * @param int $user_id 用户ID * @param int $num 列表最大数量 * @param int $start 列表起始位置 * @param int $type 债券的类型 * * @return array $booking */ function get_booking_list($user_id, $num, $start, $catstatus, $type) { $booking = array(); $pay_status = PS_PAYED; $sql = "SELECT o.invest_price,o.market_price,g.goods_number,g.goods_weight,g.add_time,g.shop_price,g.surplus_price,g.goods_sn,g.good_status " . "FROM " . $GLOBALS['ecs']->table('goods') . " AS g, " . $GLOBALS['ecs']->table('order_goods') . " AS o, " . $GLOBALS['ecs']->table('category') . " AS c " . "WHERE g.goods_id = o.goods_id AND c.cat_id = g.cat_id AND o.pay_status = " . $pay_status . " AND g.good_status = " . $type . " AND" . " o.user_id = '{$user_id}' AND c.is_standalone =" . $catstatus . " order by o.rec_id desc"; $res = $GLOBALS['db']->SelectLimit($sql, $num, $start); while ($row = $GLOBALS['db']->fetchRow($res)) { if (empty($row['dispose_note'])) { $row['dispose_note'] = 'N/A'; } if ($type == GD_INVING) { $booking[] = array('invest_price' => $row['invest_price'], 'market_price' => $row['market_price'] . '%', 'surprice' => round(100 * (($row['shop_price'] - $row['surplus_price']) / $row['shop_price']), 2) . '%', 'limit_time' => ceil(($row['goods_number'] - $row['add_time']) / (60 * 60 * 24)), 'overplus_time' => ceil(($row['goods_number'] - gmtime()) / (60 * 60 * 24)), 'good_id' => $row['goods_sn']); } if ($type == GD_FULL) { $monthnum = ceil(($row['goods_number'] - $row['goods_weight']) / 3600 * 24 * 30) - ceil(($row['goods_number'] - $row['goods_weight']) / 3600 * 24 * 30 / ((gmtime() - $row['goods_weight']) / 3600 * 24 * 30)); $nextmonth = local_date('Y-m-d', $row['goods_weight'] + 3600 * 24 * 30 * $monthnum); if ($nextmonth - gmtime() > 0) { $orstatus = '未付款'; } else { $orstatus = '已付款'; } $booking[] = array('invest_price' => $row['invest_price'], 'market_price' => $row['market_price'], 'collect_interest' => $row['shop_price'] * $row['market_price'] / 365 * (($row['goods_number'] - $row['add_time']) / 60 * 60 * 24), 'month_interest' => $row['shop_price'] * $row['market_price'] / 365 * date('t', gmtime()), 'overplus_time' => $nextmonth, 'over_status' => $orstatus, 'good_id' => $row['goods_sn']); } if ($type == GD_OVER) { $booking[] = array('invest_price' => $row['invest_price'], 'market_price' => $row['market_price'], 'shop_price' => ($row['shop_price'] - $row['surplus_price']) / $row['shop_price'], 'limit_time' => ($row['goods_number'] - $row['add_time']) / (60 * 60 * 24), 'overplus_time' => local_getdate($row['goods_number']), 'over_style' => ($row['goods_number'] - gmtime()) / 60 * 60 * 24, 'good_id' => $row['goods_sn']); } } return $booking; }