public function index() { $root = array(); $root['response_code'] = 1; $id = intval($_REQUEST['id']); $email = strim($GLOBALS['request']['email']); // 用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); // 密码 // 检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); if (!$deal_info) { app_redirect(url("index")); } $deal_info = cache_deal_extra($deal_info); init_deal_page($deal_info); $page_size = $GLOBALS['m_config']['page_size']; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); $url = url_wap("deal#show", array("id" => $id)); $root['url'] = $url; $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['image'] = get_user_avatar_root($v["user_id"], "middle"); //用户头像 //$log_list[$k]['image'] = get_abs_img_root(get_spec_image($v['image'],640,240,1)); $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; $log_list[$k]['comment_data_cache'] = null; $log_list[$k]['deal_info_cache'] = null; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $root['log_list'] = $log_list; // require APP_ROOT_PATH.'app/Lib/page.php'; // $page = new Page($log_count,$page_size); //初始化分页对象 // $p = $page->show(); // $root['pages'] = $p; $root['page'] = array("page" => $page, "page_total" => ceil($log_count / $page_size), "page_size" => intval($page_size), 'total' => intval($log_count)); output($root); }
public function fav() { $GLOBALS['tmpl']->assign("page_title", "最新动态"); if (!$GLOBALS['user_info']) { app_redirect(url("user#login")); } $GLOBALS['tmpl']->assign("page_title", "我关注的项目动态"); $cate_result = load_dynamic_cache("INDEX_CATE_LIST"); if ($cate_result === false) { $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc"); $cate_result = array(); foreach ($cate_list as $k => $v) { $cate_result[$v['id']] = $v; } set_dynamic_cache("INDEX_CATE_LIST", $cate_result); } $GLOBALS['tmpl']->assign("cate_list", $cate_result); if (app_conf("INVEST_STATUS") == 0) { $condition = " 1=1 "; } elseif (app_conf("INVEST_STATUS") == 1) { $condition = " type=0 "; } elseif (app_conf("INVEST_STATUS") == 2) { $condition = " type=1 "; } $rand_deals = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where {$condition} and is_delete = 0 and is_effect = 1 and begin_time < " . NOW_TIME . " and (end_time >" . NOW_TIME . " or end_time = 0) order by rand() limit 3"); $GLOBALS['tmpl']->assign("rand_deals", $rand_deals); $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $GLOBALS['tmpl']->assign("current_page", $page); if (app_conf("INVEST_STATUS") == 0) { $condition = " 1=1 "; } elseif (app_conf("INVEST_STATUS") == 1) { $condition = " de.type=0 "; } elseif (app_conf("INVEST_STATUS") == 2) { $condition = " de.type=1 "; } $sql = "select dl.* from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id left join " . DB_PREFIX . "deal as de on de.id=dl.deal_id where {$condition} and dfl.user_id = " . intval($GLOBALS['user_info']['id']) . " order by dl.create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id left join " . DB_PREFIX . "deal as de on de.id=dl.deal_id where {$condition} and dfl.user_id = " . intval($GLOBALS['user_info']['id']); $log_list = $GLOBALS['db']->getAll($sql); $log_count = $GLOBALS['db']->getOne($sql_count); /*(最新动态)准备虚拟数据 start*/ if ($log_count > 0) { $deal_item_ids = array(); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $log_list[$k] = cache_log_comment($log_list[$k]); $log_list[$k] = cache_log_deal($log_list[$k]); //$log_list[$k]['deal_info']['lin']=8;放进去 //得到页面项目的ID $deal_item_ids[] = $log_list[$k]['deal_info']['id']; } //获得每个项目下的所有子项目信息 $temp_deal_item_List = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_item where deal_id in(" . implode(",", $deal_item_ids) . ") order by deal_id desc"); $virtual_price_list = array(); //重新组装一个以项目ID为KEY的虚拟价格 foreach ($temp_deal_item_List as $k => $v) { $virtual_price_list[$v['deal_id']]['total_virtual_price'] += $v['price'] * $v['virtual_person']; } unset($temp_deal_item_List); //放到项目动态表里面进行统计 foreach ($log_list as $k => $v) { $log_list[$k]['deal_info']['percent'] = round(($v['deal_info']['support_amount'] + $virtual_price_list[$v['deal_id']]['total_virtual_price']) / $v['deal_info']['limit_price'] * 100, 2); $log_list[$k]['deal_info']['support_amount'] += $virtual_price_list[$v['deal_id']]['total_virtual_price']; } } /*(最新动态)准备虚拟数据 end*/ $GLOBALS['tmpl']->assign('log_list', $log_list); $pager = new Page($log_count, $page_size); //初始化分页对象 $p = $pager->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("ajaxurl", url("ajax#newsfav", array("p" => $page))); $GLOBALS['tmpl']->display("news.html"); }
public function newsfav() { $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; if (app_conf("INVEST_STATUS") == 0) { $condition = " 1=1 "; } elseif (app_conf("INVEST_STATUS") == 1) { $condition = " de.type=0 "; } elseif (app_conf("INVEST_STATUS") == 2) { $condition = " de.type=1 "; } $sql = "select dl.* from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id left join " . DB_PREFIX . "deal as de on de.id=dl.deal_id where {$condition} and dfl.user_id = " . intval($GLOBALS['user_info']['id']) . " order by dl.create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id " . DB_PREFIX . "deal as de on de.id=dl.deal_id where {$condition} and dfl.user_id = " . intval($GLOBALS['user_info']['id']); $log_list = $GLOBALS['db']->getAll($sql); $log_count = $GLOBALS['db']->getOne($sql_count); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $log_list[$k] = cache_log_comment($log_list[$k]); $log_list[$k] = cache_log_deal($log_list[$k]); } $GLOBALS['tmpl']->assign('log_list', $log_list); $data['html'] = $GLOBALS['tmpl']->fetch("inc/news_item.html"); if ($step * $step_size < $page_size) { if ($log_count <= ($page - 1) * $page_size + ($step - 1) * $step_size + $step_size) { $data['step'] = 0; ajax_return($data); } else { $data['step'] = $step + 1; ajax_return($data); } } else { $data['step'] = 0; ajax_return($data); } }
public function update() { $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']); if (!$deal_info) { app_redirect(url_wap("index")); } $deal_info = cache_deal_extra($deal_info); init_deal_page_wap($deal_info); $page_size = 15; $step_size = 5; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $GLOBALS['tmpl']->assign("current_page", $page); $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); if (!$log_list || ($page - 1) * $page_size + ($step - 1) * $step_size + count($log_list) >= $log_count) { //最后一页 $log_list[] = array("deal_id" => $deal_info['id'], "create_time" => $deal_info['begin_time'] + 1, "id" => 0); } $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $GLOBALS['tmpl']->assign("log_list", $log_list); require APP_ROOT_PATH . 'wap/app/page.php'; $page = new Page($log_count, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->display("deal_update.html"); }
public function update() { $access = get_level_access($GLOBALS['user_info'], $deal_info); $GLOBALS['tmpl']->assign("access", $access); $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']); $deal_info['login_time'] = $GLOBALS['db']->getOne("select login_time from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); $deal_info['user_icon'] = $GLOBALS['user_level'][$deal_info['user_level']]['icon']; $deal_info['is_investor'] = $GLOBALS['db']->getOne("select is_investor from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); if (!$deal_info) { app_redirect(url("index")); } if ($deal_info['type'] == 1) { //跟投人数 $gen_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where type=2 and deal_id=" . $id); $GLOBALS['tmpl']->assign('gen_num', intval($gen_num)); //询价人数 $xun_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where type=0 and deal_id=" . $id); $GLOBALS['tmpl']->assign('xun_num', intval($xun_num)); //预购总额 $yu_money = $GLOBALS['db']->getOne("select sum(money) from " . DB_PREFIX . "investment_list where deal_id={$id} "); $GLOBALS['tmpl']->assign('yu_money', intval($yu_money)); $GLOBALS['tmpl']->assign("percent_invest", round($yu_money / $deal_info['limit_price'] * 100, 2)); } $deal_info = cache_deal_extra($deal_info); $comment_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1"); $GLOBALS['tmpl']->assign('comment_count', $comment_count); $this->init_deal_page($deal_info); $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $GLOBALS['tmpl']->assign("current_page", $page); $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); if (!$log_list || ($page - 1) * $page_size + ($step - 1) * $step_size + count($log_list) >= $log_count) { //最后一页 $log_list[] = array("deal_id" => $deal_info['id'], "create_time" => $deal_info['begin_time'] + 1, "id" => 0); } $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $GLOBALS['tmpl']->assign("log_list", $log_list); require APP_ROOT_PATH . 'app/Lib/page.php'; $page = new Page($log_count, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->display("deal_update.html"); }