public function index() { //require APP_ROOT_PATH.'app/Lib/page.php'; $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $keywords = trim(htmlspecialchars($GLOBALS['request']['keywords'])); $level = intval($GLOBALS['request']['level']); $interest = intval($GLOBALS['request']['interest']); $months = intval($GLOBALS['request']['months']); $lefttime = intval($GLOBALS['request']['lefttime']); $deal_status = intval($GLOBALS['request']['deal_status']); $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $level_list = load_auto_cache("level"); $cate_id = intval($GLOBALS['request']['cid']); $n_cate_id = 0; $condition = " publish_wait = 0 "; $orderby = ""; if ($cate_id > 0) { $n_cate_id = $cate_id; //$condition .= "AND deal_status in(0,1)"; $orderby = "update_time DESC ,sort DESC,id DESC"; } else { $n_cate_id = 0; $orderby = "update_time DESC , sort DESC , id DESC"; } if ($keywords) { $kw_unicode = str_to_unicode_string($keywords); $condition .= " and (match(name_match,deal_cate_match,tag_match,type_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } if ($level > 0) { $point = $level_list['point'][$level]; $condition .= " AND user_id in(SELECT u.id FROM " . DB_PREFIX . "user u LEFT JOIN " . DB_PREFIX . "user_level ul ON ul.id=u.level_id WHERE ul.point >= {$point})"; } if ($interest > 0) { $condition .= " AND rate >= " . $interest; } if ($months > 0) { if ($months == 12) { $condition .= " AND repay_time <= " . $months; } elseif ($months == 18) { $condition .= " AND repay_time >= " . $months; } } if ($lefttime > 0) { $condition .= " AND (start_time + enddate*24*3600 - " . TIME_UTC . ") <= " . $lefttime * 24 * 3600; } if ($deal_status > 0) { $condition .= " AND deal_status = " . $deal_status; } $result = get_deal_list($limit, $n_cate_id, $condition, $orderby); $root = array(); $root['response_code'] = 1; $root['item'] = $result['list']; //$root['DEAL_PAGE_SIZE'] = app_conf("DEAL_PAGE_SIZE"); //$root['count'] = $result['count']; $root['page'] = array("page" => $page, "page_total" => ceil($result['count'] / app_conf("DEAL_PAGE_SIZE"))); output($root); }
public function load($param) { $param = array("cid" => $param['cid']); $key = $this->build_key(__CLASS__, $param); $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/"); $key_result = $GLOBALS['cache']->get($key); if ($key_result === false) { $param['cid'] = intval($GLOBALS['db']->getOne("select id from " . DB_PREFIX . "shop_cate where id = " . intval($param['cid']))); $key = $this->build_key(__CLASS__, $param); $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/"); $key_result = $GLOBALS['cache']->get($key); if ($key_result !== false) { return $key_result; } $cate_id = $param['cid']; require_once APP_ROOT_PATH . "system/utils/child.php"; $ids_util = new child("shop_cate"); $ids = $ids_util->getChildIds($cate_id); $ids[] = $cate_id; $deal_cate = $GLOBALS['db']->getAll("select name from " . DB_PREFIX . "shop_cate where id in (" . implode(",", $ids) . ") and is_effect = 1 and is_delete = 0"); foreach ($deal_cate as $k => $item) { $name_words = div_str($item['name']); foreach ($name_words as $kk => $vv) { $kw[] = str_to_unicode_string($vv); } } $key_result = implode(" ", $kw); $GLOBALS['cache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/"); $GLOBALS['cache']->set($key, $key_result); } return $key_result; }
public function index() { //输出团购城市 $city_list = M("DealCity")->where('is_delete = 0')->findAll(); $city_list = D("DealCity")->toFormatTree($city_list, 'name'); $this->assign("city_list", $city_list); //分类 $cate_tree = M("DealCate")->where('is_delete = 0')->findAll(); $cate_tree = D("DealCate")->toFormatTree($cate_tree, 'name'); $this->assign("cate_tree", $cate_tree); //开始加载搜索条件 if (intval($_REQUEST['id']) > 0) { $map['id'] = intval($_REQUEST['id']); } $map['is_delete'] = 0; if (strim($_REQUEST['name']) != '') { $map['name'] = array('like', '%' . strim($_REQUEST['name']) . '%'); } if (intval($_REQUEST['city_id']) > 0) { require_once APP_ROOT_PATH . "system/utils/child.php"; $child = new Child("deal_city"); $city_ids = $child->getChildIds(intval($_REQUEST['city_id'])); $city_ids[] = intval($_REQUEST['city_id']); $map['city_id'] = array("in", $city_ids); } if (intval($_REQUEST['cate_id']) > 0) { require_once APP_ROOT_PATH . "system/utils/child.php"; $child = new Child("deal_cate"); $cate_ids = $child->getChildIds(intval($_REQUEST['cate_id'])); $cate_ids[] = intval($_REQUEST['cate_id']); $map['cate_id'] = array("in", $cate_ids); } if (strim($_REQUEST['supplier_name']) != '') { if (intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier")) < 50000) { $sql = "select group_concat(id) from " . DB_PREFIX . "supplier where name like '%" . strim($_REQUEST['supplier_name']) . "%'"; } else { $kws_div = div_str(trim($_REQUEST['supplier_name'])); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $kw_unicode = implode(" ", $kw); $sql = "select group_concat(id) from " . DB_PREFIX . "supplier where (match(name_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } $ids = $GLOBALS['db']->getOne($sql); $map['supplier_id'] = array("in", $ids); } $map['publish_wait'] = 0; $map['is_shop'] = 0; if (method_exists($this, '_filter')) { $this->_filter($map); } $name = $this->getActionName(); $model = D($name); if (!empty($model)) { $this->_list($model, $map); } $this->display(); return; }
public function index() { $page_idx = intval($_REQUEST['p']) == 0 ? 1 : intval($_REQUEST['p']); $page_size = C('PAGE_LISTROWS'); $limit = ($page_idx - 1) * $page_size . "," . $page_size; if (isset($_REQUEST['_order'])) { $order = $_REQUEST['_order']; } //排序方式默认按照倒序排列 //接受 sost参数 0 表示倒序 非0都 表示正序 if (isset($_REQUEST['_sort'])) { $sort = $_REQUEST['_sort'] ? 'asc' : 'desc'; } else { $sort = 'desc'; } if (isset($order)) { $orderby = "order by " . $order . " " . $sort; } else { $orderby = ""; } if (trim($_REQUEST['name']) != '') { $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier"); if ($total < 50000) { $list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "supplier where name like '%" . trim($_REQUEST['name']) . "%' {$orderby} limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier where name like '%" . trim($_REQUEST['name']) . "%'"); } else { $kws_div = div_str(trim($_REQUEST['name'])); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $kw_unicode = implode(" ", $kw); $list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "supplier where match(`name_match`) against('" . $kw_unicode . "' IN BOOLEAN MODE) {$orderby} limit " . $limit); $total = $GLOBALS['db']->getOne("select * from " . DB_PREFIX . "supplier where match(`name_match`) against('" . $kw_unicode . "' IN BOOLEAN MODE)"); } } else { $list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "supplier {$orderby} limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier"); } $p = new Page($total, ''); $page = $p->show(); $sortImg = $sort; //排序图标 $sortAlt = $sort == 'desc' ? l("ASC_SORT") : l("DESC_SORT"); //排序提示 $sort = $sort == 'desc' ? 1 : 0; //排序方式 //模板赋值显示 $this->assign('sort', $sort); $this->assign('order', $order); $this->assign('sortImg', $sortImg); $this->assign('sortType', $sortAlt); $this->assign('list', $list); $this->assign("page", $page); $this->assign("nowPage", $p->nowPage); $this->display(); return; }
public function index() { $root = array(); $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $keywords = trim(htmlspecialchars($GLOBALS['request']['keywords'])); $level = intval($GLOBALS['request']['level']); $interest = intval($GLOBALS['request']['interest']); $months = intval($GLOBALS['request']['months']); $lefttime = intval($GLOBALS['request']['lefttime']); $cate_id = intval($GLOBALS['request']['cid']); $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $level_list = load_auto_cache("level"); $page_args = array(); $condition = ""; if ($cate_id > 0) { $condition .= "AND d.deal_status >=4 and cate_id=" . $cate_id; $orderby = "d.update_time DESC ,d.sort DESC,d.id DESC"; } elseif ($cate_id == 0) { $orderby = " d.create_time DESC , dlt.id DESC"; } if ($keywords) { $kw_unicode = str_to_unicode_string($keywords); $condition .= " and (match(d.name_match,d.deal_cate_match,d.tag_match,d.type_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } if ($level > 0) { $point = $level_list['point'][$level]; $condition .= " AND d.user_id in(SELECT u.id FROM " . DB_PREFIX . "user u LEFT JOIN " . DB_PREFIX . "user_level ul ON ul.id=u.level_id WHERE ul.point >= {$point})"; } if ($interest > 0) { $condition .= " AND d.rate >= " . $interest; } if ($months > 0) { if ($months == 12) { $condition .= " AND d.repay_time <= " . $months; } elseif ($months == 18) { $condition .= " AND d.repay_time >= " . $months; } } if ($lefttime > 0) { $condition .= " AND (d.next_repay_time + 24*3600 - 1 - " . TIME_UTC . ") <= " . $lefttime * 24 * 3600; } $extfield = ""; $union_sql = ""; $result = get_transfer_list($limit, $condition, $extfield, $union_sql, $orderby); $root = array(); $root['response_code'] = 1; $root['item'] = $result['list']; //$root['DEAL_PAGE_SIZE'] = app_conf("DEAL_PAGE_SIZE"); //$root['count'] = $result['count']; $root['page'] = array("page" => $page, "page_total" => ceil($result['rs_count'] / app_conf("DEAL_PAGE_SIZE")), "page_size" => app_conf("DEAL_PAGE_SIZE")); $root['program_title'] = "债权转让"; output($root); }
public function index() { require_once APP_ROOT_PATH . 'app/Lib/shop_lib.php'; $catalog_id = intval($GLOBALS['request']['catalog_id']); //商品分类ID $city_id = intval($GLOBALS['request']['city_id']); //城市分类ID $page = intval($GLOBALS['request']['page']); //分页 $keyword = strim($GLOBALS['request']['keyword']); $page = $page == 0 ? 1 : $page; $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; $condition = " deal_type = 0 "; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(tag_match,name_match,locate_match,shop_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%')"; } $merchant_id = intval($GLOBALS['request']['merchant_id']); if ($merchant_id > 0) { $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_location_link where location_id = " . $merchant_id); if ($deal_ids) { $condition .= " and id in (" . $deal_ids . ") "; } } $deals = get_goods_list($limit, $catalog_id, $condition, "sort desc,id desc", false, $city_id); $list = $deals['list']; $count = $deals['count']; $page_total = ceil($count / $page_size); $root = array(); $root['return'] = 1; $goodses = array(); foreach ($list as $item) { //$goods = array(); $goods = getGoodsArray($item); $goodses[] = $goods; } $root['item'] = $goodses; $root['page'] = array("page" => $page, "page_total" => $page_total); output($root); }
public function index() { require_once APP_ROOT_PATH . "system/libs/user.php"; $email = strim($GLOBALS['request']['email']); $pwd = strim($GLOBALS['request']['pwd']); $result = do_login_user($email, $pwd); $user_data = es_session::get('user_info'); $uid = intval($user_data['id']); if ($uid == 0) { $root['info'] = "请先登陆"; output($root); } $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $user_info['uid'] = $user_data['id']; $user_info['email'] = $user_data['email']; $user_info['user_name'] = $user_data['user_name']; $user_info['user_avatar'] = get_abs_img_root(get_muser_avatar($user_data['id'], "big")); $root['home_user'] = $root['user'] = $user_info; $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; $user_name = $user_data['user_name']; $user_name_unicode = str_to_unicode_string($user_name); $condition = " match(user_name_match) against('" . $user_name_unicode . "' IN BOOLEAN MODE) "; $topic_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition . " order by create_time desc limit " . $limit); $total = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and " . $condition); foreach ($topic_list as $k => $v) { $topic_list[$k] = m_get_topic_item($v); if ($v['fav_id'] > 0 || $v['relay_id'] > 0) { $relay_share = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "topic where is_effect = 1 and is_delete = 0 and id = " . $v['origin_id']); } if ($relay_share) { $topic_list[$k]['relay_share'] = m_get_topic_item($relay_share); } } $root = array(); $root['return'] = 1; $root['item'] = $topic_list; $root['page'] = array("page" => $page, "page_total" => ceil($total / PAGE_SIZE)); output($root); }
public function index() { $catalog_id = intval($GLOBALS['request']['catalog_id']); //商品分类ID $city_id = intval($GLOBALS['request']['city_id']); //城市分类ID $page = intval($GLOBALS['request']['page']); //分页 $keyword = strim($GLOBALS['request']['keyword']); $page = $page == 0 ? 1 : $page; $quan_id = intval($GLOBALS['request']['quan_id']); //商圈id $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition = " (match(tag_match,name_match,locate_match,deal_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') and "; } $condition .= " buy_type<>1 and is_lottery = 0 "; if ($xpoint > 0) { $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance "; if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) { if ($condition != "") { $condition .= " and "; } $condition .= " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} "; } $order = " distance asc,id desc "; } else { $field_append = ""; $order = "sort desc,id desc "; } //根据传入的商圈ID来搜索该商圈下的商品 if ($quan_id > 0) { $sql_q = "select name from " . DB_PREFIX . "area where id = " . intval($quan_id); $q_name = $GLOBALS['db']->getOne($sql_q); $q_name_unicode = str_to_unicode_string($q_name); $condition .= " and (match(locate_match) against('" . $q_name_unicode . "' IN BOOLEAN MODE))"; } $deals = m_get_deal_list($limit, $catalog_id, $city_id, array(DEAL_ONLINE), $condition, $order, 0, $field_append); $list = $deals['list']; $count = $deals['count']; $page_total = ceil($count / $page_size); $root = array(); $root['return'] = 1; $goodses = array(); foreach ($list as $item) { //$goods = array(); $goods = getGoodsArray($item); $goods['distance'] = round($goods['distance']); $goodses[] = $goods; } $root['item'] = $goodses; $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size); output($root); }
public function search_supplier() { if (intval($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "supplier")) < 50000) { $sql = "select * from " . DB_PREFIX . "supplier where name like '%" . trim($_REQUEST['key']) . "%' limit 30"; } else { $kws_div = div_str(trim($_REQUEST['key'])); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $kw_unicode = implode(" ", $kw); $sql = "select * from " . DB_PREFIX . "supplier where (match(name_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) limit 30"; } $supplier_list = $GLOBALS['db']->getAll($sql); $this->assign("supplier_list", $supplier_list); $this->display(); }
function insert_load_filter_goods_list() { convert_req($_REQUEST); //获取当前页的团购商品列表 //分页 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $id = intval($_REQUEST['id']); if ($id == 0) { $uname = addslashes(trim($_REQUEST['id'])); } $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "shop_cate where id = " . $id . " or (uname = '" . $uname . "' and uname <> '')"); $condition = " d.buy_type<>1 "; //条件 $url_param = array("id" => addslashes(trim($_REQUEST['id'])), "b" => intval($_REQUEST['b']), "min_price" => doubleval($_REQUEST['min_price']), "max_price" => doubleval($_REQUEST['max_price'])); $filter_req = $_REQUEST['f']; //筛选数组 if (count($filter_req) > 0) { foreach ($filter_req as $k => $v) { $url_param['f[' . $k . ']'] = $v; } } if (intval($_REQUEST['is_redirect']) == 1) { app_redirect(url("shop", "cate", $url_param)); } $GLOBALS['tmpl']->assign("url_param", $url_param); //将变量输出到模板 $ids = load_auto_cache("shop_sub_parent_cate_ids", array("cate_id" => intval($cate_item['id']))); $add_title = ""; //输出品牌 $brand_id = intval($_REQUEST['b']); if ($brand_id > 0) { $condition .= " and d.brand_id = " . $brand_id; $add_title .= $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "brand where id = " . $brand_id); } $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "brand where shop_cate_id in (" . implode(",", $ids) . ")"); $brand_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0); foreach ($brand_list as $k => $v) { if ($brand_id == $v['id']) { $brand_list[$k]['act'] = 1; } $tmp_url_param = $url_param; $tmp_url_param['b'] = $v['id']; $brand_list[$k]['url'] = url("shop", "cate#index", $tmp_url_param); } $GLOBALS['tmpl']->assign("brand_list", $brand_list); //输出属性筛选 $join_str = ""; $unicode_tags = array(); if ($filter_req) { foreach ($filter_req as $k => $v) { $k = intval($k); $filter_req[$k] = trim(addslashes(urldecode($v))); if ($filter_req[$k] != '' && $filter_req[$k] != 'all') { if ($add_title != '') { $add_title .= " - "; } $add_title .= $filter_req[$k]; $unicode_tags[] = "+" . str_to_unicode_string($filter_req[$k]); } } } if (count($unicode_tags) > 0) { $kw_unicode = implode(" ", $unicode_tags); //有筛选 $condition .= " and (match(d.tag_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } $filter_group = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "filter_group where is_effect = 1 and cate_id in (" . implode(",", $ids) . ") order by sort desc"); foreach ($filter_group as $k => $v) { $filter_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "filter where filter_group_id = " . $v['id'] . " limit 20"); $filter_list[] = array("name" => $GLOBALS['lang']['ALL'], "id" => 0); foreach ($filter_list as $kk => $vv) { if ($filter_req[$v['id']] == $vv['name']) { $filter_list[$kk]['act'] = 1; } if ($vv['id'] == 0) { $url_name = 'all'; } else { $url_name = $vv['name']; } if (($filter_req[$v['id']] == 'all' || $filter_req[$v['id']] == '') && $url_name == 'all') { $filter_list[$kk]['act'] = 1; } $tmp_url_param = $url_param; $tmp_url_param["f[" . $v['id'] . "]"] = $url_name; $filter_list[$kk]['url'] = url("shop", "cate#index", $tmp_url_param); } $filter_group[$k]['filter_list'] = $filter_list; } $GLOBALS['tmpl']->assign("filter_group", $filter_group); //输出价格区间 $min_price = doubleval($_REQUEST['min_price']); $max_price = doubleval($_REQUEST['max_price']); $GLOBALS['tmpl']->assign("min_price", $min_price); $GLOBALS['tmpl']->assign("max_price", $max_price); if ($min_price > 0) { $condition .= " and d.current_price >= " . $min_price; } if ($max_price > 0) { $condition .= " and d.current_price <= " . $max_price; } $sort_field = es_cookie::get("shop_sort_field") ? es_cookie::get("shop_sort_field") : "sort"; $sort_type = es_cookie::get("shop_sort_type") ? es_cookie::get("shop_sort_type") : "desc"; $GLOBALS['tmpl']->assign('sort_field', $sort_field); $GLOBALS['tmpl']->assign('sort_type', $sort_type); $result = search_goods_list($limit, intval($cate_item['id']), $condition, "d." . $sort_field . " " . $sort_type, false, $join_str); $GLOBALS['tmpl']->assign("list", $result['list']); $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("cate_id", $cate_item['id']); if (es_cookie::get("list_type") === null) { $list_type = app_conf("LIST_TYPE"); } else { $list_type = intval(es_cookie::get("list_type")); } $GLOBALS['tmpl']->assign("list_type", $list_type); return $GLOBALS['tmpl']->fetch("inc/insert/load_filter_goods_list.html"); }
public function index() { $root = array(); $root['return'] = 1; $email = addslashes($GLOBALS['request']['email']); //用户名或邮箱 $pwd = addslashes($GLOBALS['request']['pwd']); //密码 //检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); $city_id = intval($GLOBALS['request']['city_id']); $quan_id = intval($GLOBALS['request']['quan_id']); $cate_id = intval($GLOBALS['request']['cate_id']); $brand_id = intval($GLOBALS['request']['brand_id']); $keyword = strim($GLOBALS['request']['keyword']); $page = intval($GLOBALS['request']['page']); //分页 $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint $page = $page == 0 ? 1 : $page; $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; if ($xpoint > 0) { $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance "; if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) { $condition = " and ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} "; } $orderby = " order by distance asc "; } else { $field_append = ""; $orderby = " "; } $sql_count = "select count(*) from " . DB_PREFIX . "supplier_location" . " as a"; $sql = "select a.supplier_id as id,a.name,a.mobile_brief as brief,a.tel,a.preview as logo,a.dp_count as comment_count,a.xpoint,a.ypoint,a.address as api_address, 0 as is_dy {$field_append} from " . DB_PREFIX . "supplier_location as a "; $where = "1 = 1 "; if ($city_id > 0) { $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id)); if ($ids) { $where .= " and city_id in (" . implode(",", $ids) . ")"; } } if ($quan_id > 0) { $sql_q = "select name from " . DB_PREFIX . "area where id = " . intval($quan_id); $q_name = $GLOBALS['db']->getOne($sql_q); $q_name_unicode = str_to_unicode_string($q_name); $where .= " and (match(a.locate_match) against('" . $q_name_unicode . "' IN BOOLEAN MODE))"; //$where .= " and a.locate_match = $quan_id"; } if ($cate_id > 0) { $where .= " and a.deal_cate_id = {$cate_id}"; } if ($brand_id > 0) { $where .= " and a.supplier_id = {$brand_id}"; } if ($keyword) { $GLOBALS['tmpl']->assign("keyword", $keyword); $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $kw_unicode = implode(" ", $kw); //有筛选 $where .= " and (match(a.name_match,a.locate_match,a.deal_cate_match,a.tags_match) against('" . $kw_unicode . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%')"; } $where .= $condition; $sql_count .= " where " . $where; $sql .= " where " . $where; $sql .= $orderby; $sql .= " limit " . $limit; $total = $GLOBALS['db']->getOne($sql_count); $page_total = ceil($total / $page_size); $list = $GLOBALS['db']->getAll($sql); $merchant_list = array(); foreach ($list as $item) { $item = m_merchantItem($item); $merchant_list[] = $item; } $root['item'] = $merchant_list; $root['page'] = array("page" => $page, "page_total" => $page_total); output($root); }
public function index() { $GLOBALS['tmpl']->caching = true; $GLOBALS['tmpl']->cache_lifetime = 60; //首页缓存10分钟 $field = es_cookie::get("shop_sort_field"); $field_sort = es_cookie::get("shop_sort_type"); $cache_id = md5(MODULE_NAME . ACTION_NAME . implode(",", $_REQUEST) . $field . $field_sort); if (!$GLOBALS['tmpl']->is_cached("page/deals.html", $cache_id)) { require APP_ROOT_PATH . 'app/Lib/page.php'; $level_list = load_auto_cache("level"); $GLOBALS['tmpl']->assign("level_list", $level_list['list']); if (trim($_REQUEST['cid']) == "last") { $cate_id = "-1"; $page_title = $GLOBALS['lang']['LAST_SUCCESS_DEALS'] . " - "; } else { $cate_id = intval($_REQUEST['cid']); } if ($cate_id == 0) { $page_title = $GLOBALS['lang']['ALL_DEALS'] . " - "; } $keywords = trim(htmlspecialchars($_REQUEST['keywords'])); $GLOBALS['tmpl']->assign("keywords", $keywords); $level = intval($_REQUEST['level']); $GLOBALS['tmpl']->assign("level", $level); $interest = intval($_REQUEST['interest']); $GLOBALS['tmpl']->assign("interest", $interest); $months = intval($_REQUEST['months']); $GLOBALS['tmpl']->assign("months", $months); $lefttime = intval($_REQUEST['lefttime']); $GLOBALS['tmpl']->assign("lefttime", $lefttime); $months_type = intval($_REQUEST['months_type']); $GLOBALS['tmpl']->assign("months_type", $months_type); $deal_status = intval($_REQUEST['deal_status']); $GLOBALS['tmpl']->assign("deal_status", $deal_status); $cates = intval($_REQUEST['cates']); $GLOBALS['tmpl']->assign("cates", $cates); $city = intval($_REQUEST['city']); $GLOBALS['tmpl']->assign("city_id", $city); $scity = intval($_REQUEST['scity']); $GLOBALS['tmpl']->assign("scity_id", $scity); //输出分类 $deal_cates_db = load_auto_cache("cache_deal_cate"); $deal_cates = array(); foreach ($deal_cates_db as $k => $v) { if ($cate_id == $v['id']) { $v['current'] = 1; $page_title = $v['name'] . " - "; } $v['url'] = url("index", "deals", array("cid" => $v['id'])); $deal_cates[] = $v; } unset($deal_cates_db); //输出投标列表 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $n_cate_id = 0; $condition = " publish_wait = 0 and is_hidden = 0 "; $orderby = ""; if ($cate_id > 0) { $n_cate_id = $cate_id; if ($field && $field_sort) { $orderby = "{$field} {$field_sort} ,deal_status desc , sort DESC,id DESC"; } else { $orderby = "sort DESC,id DESC"; } $total_money = $GLOBALS['db']->getOne("SELECT sum(borrow_amount) FROM " . DB_PREFIX . "deal WHERE cate_id={$cate_id} AND deal_status in(4,5) AND is_effect = 1 and is_delete = 0 "); } elseif ($cate_id == 0) { $n_cate_id = 0; if ($field && $field_sort) { $orderby = "{$field} {$field_sort} ,sort DESC,id DESC"; } else { $orderby = "sort DESC , id DESC"; } $total_money = $GLOBALS['db']->getOne("SELECT sum(borrow_amount) FROM " . DB_PREFIX . "deal WHERE deal_status in(4,5) AND is_effect = 1 and is_delete = 0"); } elseif ($cate_id == "-1") { $n_cate_id = 0; $condition .= "AND deal_status in(2,4,5) "; $orderby = "deal_status ASC,success_time DESC,sort DESC,id DESC"; } if ($keywords) { $kw_unicode = str_to_unicode_string($keywords); $condition .= " and (match(name_match,deal_cate_match,tag_match,type_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } if ($level > 0) { $point = $level_list['point'][$level]; $condition .= " AND user_id in(SELECT u.id FROM " . DB_PREFIX . "user u LEFT JOIN " . DB_PREFIX . "user_level ul ON ul.id=u.level_id WHERE ul.point >= {$point})"; } if ($interest > 0) { $condition .= " AND rate >= " . $interest; } if ($months > 0) { if ($months == 12) { $condition .= " AND repay_time <= " . $months; } elseif ($months == 18) { $condition .= " AND repay_time >= " . $months; } } if ($lefttime > 0) { $condition .= " AND (start_time + enddate*24*3600 - " . TIME_UTC . ") <= " . $lefttime * 24 * 3600; } if ($deal_status == 19) { $condition .= " AND deal_status = 1 AND start_time > " . TIME_UTC . " "; } elseif ($deal_status > 0) { $condition .= " AND deal_status = " . $deal_status . " AND start_time <= " . TIME_UTC . " "; } if ($months_type > 0) { if ($months_type == 1) { $condition .= " AND ((repay_time < 3 and repay_time_type = 1) or repay_time_type = 0) "; } else { if ($months_type == 2) { $condition .= " AND repay_time in (3,4,5) and repay_time_type = 1 "; } else { if ($months_type == 3) { $condition .= " AND repay_time in (6,7,8) and repay_time_type = 1 "; } else { if ($months_type == 4) { $condition .= " AND repay_time in (9,10,11) and repay_time_type = 1 "; } else { $condition .= " AND repay_time >= 12 and repay_time_type = 1 "; } } } } } if ($city > 0) { if ($scity > 0) { $dealid_list = $GLOBALS['db']->getAll("SELECT deal_id FROM " . DB_PREFIX . "deal_city_link where city_id = " . $scity); } else { $dealid_list = $GLOBALS['db']->getAll("SELECT deal_id FROM " . DB_PREFIX . "deal_city_link where city_id = " . $city); } $flatmap = array_map("array_pop", $dealid_list); $s2 = implode(',', $flatmap); $condition .= " AND id in (" . $s2 . ") "; } //使用技巧 $use_tech_list = get_article_list(4, 6); $GLOBALS['tmpl']->assign("use_tech_list", $use_tech_list); $result = get_deal_list($limit, $n_cate_id, $condition, $orderby); $GLOBALS['tmpl']->assign("deal_list", $result['list']); $GLOBALS['tmpl']->assign("total_money", $total_money); //输出公告 $notice_list = get_notice(3); $GLOBALS['tmpl']->assign("notice_list", $notice_list); $page_args['cid'] = $cate_id; $page_args['keywords'] = $keywords; $page_args['level'] = $level; $page_args['interest'] = $interest; $page_args['months'] = $months; $page_args['lefttime'] = $lefttime; $page_args['months_type'] = $months_type; $page_args['deal_status'] = $deal_status; $page_args['city'] = $city; //分类 $cate_list_url = array(); $tmp_args = $page_args; $tmp_args['cid'] = 0; $cate_list_url[0]['url'] = url("index", "deals#index", $tmp_args); $cate_list_url[0]['name'] = "不限"; $cate_list_url[0]['id'] = 0; foreach ($deal_cates as $k => $v) { $cate_list_url[$k + 1] = $v; $tmp_args = $page_args; $tmp_args['cid'] = $v['id']; $cate_list_url[$k + 1]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('cate_list_url', $cate_list_url); //利率 $interest_url = array(array("interest" => 0, "name" => "不限"), array("interest" => 10, "name" => "10%"), array("interest" => 12, "name" => "12%"), array("interest" => 15, "name" => "15%"), array("interest" => 18, "name" => "18")); foreach ($interest_url as $k => $v) { $tmp_args = $page_args; $tmp_args['interest'] = $v['interest']; $interest_url[$k]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('interest_url', $interest_url); //几天内 $lefttime_url = array(array("lefttime" => 0, "name" => "不限"), array("lefttime" => 1, "name" => "1天"), array("lefttime" => 3, "name" => "3天"), array("lefttime" => 6, "name" => "6天"), array("lefttime" => 9, "name" => "9天"), array("lefttime" => 12, "name" => "12天")); foreach ($lefttime_url as $k => $v) { $tmp_args = $page_args; $tmp_args['lefttime'] = $v['lefttime']; $lefttime_url[$k]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('lefttime_url', $lefttime_url); //借款期限 $months_type_url = array(array("name" => "不限"), array("name" => "3 个月以下"), array("name" => "3-6 个月"), array("name" => "6-9 个月"), array("name" => "9-12 个月"), array("name" => "12 个月以上")); foreach ($months_type_url as $k => $v) { $tmp_args = $page_args; $tmp_args['months_type'] = $k; $months_type_url[$k]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('months_type_url', $months_type_url); //标状态 $deal_status_url = array(array("key" => 0, "name" => "不限"), array("key" => 19, "name" => "未开始"), array("key" => 1, "name" => "进行中"), array("key" => 2, "name" => "满标"), array("key" => 3, "name" => "流标"), array("key" => 4, "name" => "还款中"), array("key" => 5, "name" => "已还清")); foreach ($deal_status_url as $k => $v) { $tmp_args = $page_args; $tmp_args['deal_status'] = $v['key']; $deal_status_url[$k]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('deal_status_url', $deal_status_url); //会员等级 $level_list_url = array(); $tmp_args = $page_args; $tmp_args['level'] = 0; $level_list_url[0]['url'] = url("index", "deals#index", $tmp_args); $level_list_url[0]['name'] = "不限"; foreach ($level_list['list'] as $k => $v) { $tmp_args = $page_args; $tmp_args['level'] = $v['id']; $level_list_url[$k + 1] = $v; $level_list_url[$k + 1]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('level_list_url', $level_list_url); //城市 $temp_city_urls = load_auto_cache("deal_city"); $city_urls[0]['id'] = 0; $city_urls[0]['name'] = "全部"; if (count($temp_city_urls) == 1) { $temp_city_urls = $temp_city_urls[key($temp_city_urls)]['child']; } $temp_city_urls = array_merge($city_urls, $temp_city_urls); $city_urls = array(); foreach ($temp_city_urls as $k => $v) { $city_urls[$v['id']] = $v; $tmp_args = $page_args; $tmp_args['city'] = $v['id']; $city_urls[$v['id']]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('city_urls', $city_urls); $sub_citys = $city_urls[$city]['child']; foreach ($sub_citys as $k => $v) { $tmp_args = $page_args; $tmp_args['city'] = $v['pid']; $tmp_args['scity'] = $v['id']; $sub_citys[$k]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('sub_citys', $sub_citys); $page_pram = ""; foreach ($page_args as $k => $v) { $page_pram .= "&" . $k . "=" . $v; } $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE"), $page_pram); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("page_title", $page_title . $GLOBALS['lang']['FINANCIAL_MANAGEMENT']); $GLOBALS['tmpl']->assign("cate_id", $cate_id); $GLOBALS['tmpl']->assign("cid", strim($_REQUEST['cid'])); $GLOBALS['tmpl']->assign("keywords", $keywords); $GLOBALS['tmpl']->assign("deal_cate_list", $deal_cates); $GLOBALS['tmpl']->assign("page_args", $page_args); $GLOBALS['tmpl']->assign("field", $field); $GLOBALS['tmpl']->assign("field_sort", $field_sort); } $GLOBALS['tmpl']->display("page/deals.html", $cache_id); }
public function deals() { $r = strim($_REQUEST['r']); //推荐类型 $param['r'] = $r ? $r : ''; $id = intval($_REQUEST['id']); //分类id $param['id'] = $id; $loc = strim($_REQUEST['loc']); //地区 $param['loc'] = $loc; $tag = strim($_REQUEST['tag']); //标签 $param['tag'] = $tag; $type = intval($_REQUEST['type']); //类型 $param['type'] = $type; $kw = strim($_REQUEST['k']); //关键词 $param['tag'] = $tag; $state = intval($_REQUEST['state']); //状态 $param['state'] = $state; $step = intval($_REQUEST['step']); $param['step'] = $step; //融资金额 $price = intval($_REQUEST['price']); if ($price > 0) { $param['price'] = $price; //$GLOBALS['tmpl']->assign("price",$price); } //关注数 $focus = intval($_REQUEST['focus']); if ($focus > 0) { $param['focus'] = $focus; //$GLOBALS['tmpl']->assign("focus",$focus); } //剩余时间 $time = intval($_REQUEST['time']); if ($time > 0) { $param['time'] = $time; //$GLOBALS['tmpl']->assign("time",$time); } //完成比例 $cp = intval($_REQUEST['cp']); if ($cp > 0) { $param['cp'] = $cp; //$GLOBALS['tmpl']->assign("cp",$cp); } $page_size = DEAL_PAGE_SIZE; $step_size = DEAL_STEP_SIZE; 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; $condition = " d.is_delete = 0 and d.is_effect = 1 "; if ($r != "") { if ($r == "new") { $condition .= " and " . NOW_TIME . " - d.begin_time < " . 7 * 24 * 3600 . " and " . NOW_TIME . " - d.begin_time > 0 "; //上线不超过一天 } elseif ($r == "rec") { $condition .= " and d.is_recommend = 1 "; } elseif ($r == "yure") { $condition .= " and " . NOW_TIME . " < d.begin_time "; } elseif ($r == "nend") { $condition .= " and d.end_time - " . NOW_TIME . " < " . 7 * 24 * 3600 . " and d.end_time - " . NOW_TIME . " > 0 "; //三天就要结束 } elseif ($r == "classic") { $condition .= " and d.is_classic = 1 "; } elseif ($r == "limit_price") { $condition .= " and max(d.limit_price) "; } } switch ($state) { //筹资成功 case 1: $condition .= " and d.is_success=1 and d.end_time < " . NOW_TIME; $GLOBALS['tmpl']->assign("page_title", "筹资成功"); break; //筹资失败 //筹资失败 case 2: $condition .= " and d.end_time < " . NOW_TIME . " and d.end_time!=0 and d.is_success=0 "; $GLOBALS['tmpl']->assign("page_title", "筹资失败"); break; //筹资中 //筹资中 case 3: $condition .= " and (d.end_time > " . NOW_TIME . " or d.end_time=0 ) and d.begin_time < " . NOW_TIME . " "; $GLOBALS['tmpl']->assign("page_title", "筹资中"); break; } $cate_list = load_dynamic_cache("INDEX_CATE_LIST"); if (!$cate_list) { $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc"); set_dynamic_cache("INDEX_CATE_LIST", $cate_list); } $cate_result = array(); $kk = 0; foreach ($cate_list as $k => $v) { if ($v['pid'] == 0) { $temp_param = $param; $cate_result[$k + 1]['id'] = $v['id']; $cate_result[$k + 1]['name'] = $v['name']; $temp_param['id'] = $v['id']; $cate_result[$k + 1]['url'] = url("deals", $temp_param); $kk++; } } $GLOBALS['tmpl']->assign("cate_list", $cate_result); $pid = 0; //获取父类id if ($cate_list) { foreach ($cate_list as $k => $v) { if ($v['id'] == $id) { if ($v['pid'] > 0) { $pid = $v['pid']; } else { $pid = $id; } } } } /*子分类 start*/ $cate_ids = array(); $is_has_child = false; $temp_cate_ids = array(); if ($cate_list) { $child_cate_result = array(); foreach ($cate_list as $k => $v) { if ($v['pid'] == $pid) { if ($v['pid'] > 0) { $temp_param = $param; $child_cate_result[$v['id']]['id'] = $v['id']; $child_cate_result[$v['id']]['name'] = $v['name']; $temp_param['id'] = $v['id']; $child_cate_result[$v['id']]['url'] = url("deals", $temp_param); if ($v['id'] == $id) { $is_has_child = true; } } } if ($v['pid'] == $pid || $pid == 0) { $temp_cate_ids[] = $v['id']; } } } //假如选择了子类 那么使用子类ID 否则使用 父类和其子类 if ($is_has_child) { $cate_ids[] = $id; } else { $cate_ids[] = $pid; $cate_ids = array_merge($cate_ids, $temp_cate_ids); } if (count($cate_ids) > 0) { $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ")"; } if ($loc != "") { $condition .= " and (d.province = '" . $loc . "' or d.city = '" . $loc . "') "; } if ($tag != "") { $unicode_tag = str_to_unicode_string($tag); $condition .= " and match(d.tags_match) against('" . $unicode_tag . "' IN BOOLEAN MODE) "; } if ($kw != "") { $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(d.name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or match(d.tags_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $kw . "%') "; } $condition .= " and d.type={$type} "; // if($r=="new") // { // $orderby =" d.begin_time desc "; // } // elseif($r=="rec") // { // $orderby.=" d.begin_time desc "; // } // else // { // $orderby =" sort asc "; // } //======== if ($price > 0) { if ($price == 1) { if ($type == 1) { $orderby .= " d.invote_money desc"; } else { $orderby .= " (d.support_amount+d.virtual_price) desc"; } $param_new['price'] = 2; } elseif ($price == 2) { if ($type == 1) { $orderby .= " d.invote_money asc"; } else { $orderby .= " (d.support_amount+d.virtual_price) asc"; } $param_new['price'] = 1; } $url_list['price_url'] = url("deals", $param_new); } elseif ($focus > 0) { if ($focus == 1) { $orderby .= " d.focus_count desc"; } elseif ($focus == 2) { $orderby .= " d.focus_count asc"; } } elseif ($time > 0) { if ($time == 1) { $orderby .= " d.end_time desc"; } elseif ($time == 2) { $orderby .= " d.end_time asc"; } } elseif ($cp > 0) { if ($cp == 1) { if ($type == 1) { $orderby .= " d.invote_money/d.limit_price desc"; } else { $orderby .= " (d.support_amount+d.virtual_price)/d.limit_price desc"; } $param_new['cp'] = 2; } else { if ($type == 1) { $orderby .= " d.invote_money/d.limit_price asc"; } else { $orderby .= " (d.support_amount+d.virtual_price)/d.limit_price asc"; } $param_new['cp'] = 1; } $url_list['cp_url'] = url("deals", $param_new); } else { $orderby = " d.begin_time desc "; } // var_dump($limit); // var_dump($condition); // var_dump($orderby); $result = get_deal_list($limit, $condition, $orderby); $GLOBALS['tmpl']->assign("deal_list", $result['list']); $data['html'] = $GLOBALS['tmpl']->fetch("inc/deal_list.html"); if ($step * $step_size < $page_size) { if ($result['rs_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 index() { $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $cate_id = intval($GLOBALS['request']['cate_id']); $city_id = intval($GLOBALS['request']['city_id']); $city_name = strim($GLOBALS['request']['city_name']); //城市名称 $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint if ($GLOBALS['request']['from'] == "wap") { /*输出分类*/ $bigcate_list = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "event_cate where is_effect=1 order by sort"); /*输出商圈*/ $all_quan_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "area where city_id=" . $city_id . ""); $quan_list = array(); $quan_sub_list = array(); $quan_list[0]['id'] = 0; $quan_list[0]['name'] = '全城'; $quan_list[0]['quan_sub'][0]['id'] = 0; $quan_list[0]['quan_sub'][0]['pid'] = 0; $quan_list[0]['quan_sub'][0]['name'] = '全城'; foreach ($all_quan_list as $k => $v) { if ($v['pid'] == 0) { $quan_list[] = $v; } if ($v['pid'] > 0) { $quan_sub_list[$v['pid']][] = $v; } } foreach ($quan_list as $k => $v) { if ($v['name'] != "全城") { if ($quan_sub_list[$v['id']] == null || $quan_sub_list[$v['id']] == '') { $quan_list[$k]['quan_sub'] = array(); } else { $quan_list[$k]['quan_sub'] = $quan_sub_list[$v['id']]; } } } $root[quan_list] = $quan_list; } $keyword = strim($GLOBALS['request']['keyword']); if ($xpoint > 0) { $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance "; if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) { $where = " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} "; } $order = " distance asc,is_recommend desc,sort desc,id desc"; } else { $field_append = $where = $order = ""; } $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kw); $where .= " (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') "; } $res = m_search_event_list($limit, $cate_id, $city_id, $where, $order, $field_append); $pattern = "/<img([^>]*)\\/>/i"; $replacement = "<img width=300 \$1 />"; foreach ($res['list'] as $k => $v) { if ($v['ypoint'] == '') { $res['list'][$k]['ypoint'] = 0; } if ($v['xpoint'] == '') { $res['list'][$k]['xpoint'] = 0; } $res['list'][$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 140, 85, 0)); $res['list'][$k]['distance'] = round($v['distance']); $res['list'][$k]['date_time'] = pass_date($v['submit_begin_time']); $res['list'][$k]['event_begin_time'] = to_date($v['event_begin_time'], 'Y-m-d'); $res['list'][$k]['event_end_time'] = to_date($v['event_end_time'], 'Y-m-d'); $res['list'][$k]['submit_end_time'] = to_date($v['submit_end_time'], 'Y-m-d'); $res['list'][$k]['submit_begin_time'] = to_date($v['submit_begin_time'], 'Y-m-d'); $res['list'][$k]['content'] = preg_replace($pattern, $replacement, get_abs_img_root($v['content'])); } $root = array(); $root['bigcate_list'] = $bigcate_list; $root['return'] = 1; $root['item'] = $res['list']; $root['page'] = array("page" => $page, "page_total" => ceil($res['count'] / PAGE_SIZE), "page_size" => PAGE_SIZE); $root['page_title'] = "活动列表"; $root['city_name'] = $city_name; output($root); }
public function index() { convert_req($_REQUEST); $_REQUEST['cid'] = intval($_REQUEST['cid']); $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword']))); $GLOBALS['tmpl']->assign("keyword", $keyword); $url_param = array("cid" => $_REQUEST['cid'], "aid" => intval($_REQUEST['aid']), "tid" => intval($_REQUEST['tid']), "qid" => intval($_REQUEST['qid']), "keyword" => $keyword); if (intval($_REQUEST['is_redirect']) == 1) { app_redirect(url("youhui", "fcate", $url_param)); } $quan_id = intval($_REQUEST['qid']); // $city_id = intval($GLOBALS['deal_city']['id']); //分页 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $cid = intval($_REQUEST['cid']); if ($cid == 0) { $uname = addslashes(trim($_REQUEST['cid'])); } $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $cid . " or (uname = '" . $uname . "' and uname <> '')"); $free_youhui_list = get_free_youhui_list(5, intval($cate_item['id']), " is_recommend = 1 ", ""); $GLOBALS['tmpl']->assign("free_youhui_list", $free_youhui_list['list']); $condition = " 1=1 "; //条件 unset($url_param['keyword']); $sub_nav[] = array("name" => $GLOBALS['lang']['FREE_YOUHUI'], "url" => url("youhui", "fcate", $url_param), "current" => 1); $sub_nav[] = array("name" => $GLOBALS['lang']['NEED_BUY_YOUHUI'], "url" => url("youhui", "ycate", $url_param), "current" => 0); $sub_nav[] = array("name" => $GLOBALS['lang']['TUAN'], "url" => url("youhui", "tuan", $url_param), "current" => 0); $GLOBALS['tmpl']->assign("sub_nav", $sub_nav); $GLOBALS['tmpl']->assign("url_param", $url_param); //将变量输出到模板 $seo_title = $GLOBALS['lang']['FREE_YOUHUI']; $seo_keyword = $GLOBALS['lang']['FREE_YOUHUI']; $seo_description = $GLOBALS['lang']['FREE_YOUHUI']; $cache_param = array("city_id" => $city_id, "cid" => $cate_item['id'], "tid" => $url_param['tid'], "aid" => $url_param['aid'], "qid" => $url_param['qid']); $result = load_auto_cache("fyouhui_filter_nav_cache", $cache_param); //输出行政区 $append_seo = ""; $area_id = intval($_REQUEST['aid']); if ($area_id > 0) { $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $area_id); $append_seo = $area_name; if ($quan_id > 0) { $kw_unicode = str_to_unicode_string($area_name); //有筛选 $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) "; } else { $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id)); $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")"); $unicode_quans = array(); foreach ($quan_list as $k => $v) { $unicode_quans[] = str_to_unicode_string($v['name']); } $kw_unicode = implode(" ", $unicode_quans); $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } } $GLOBALS['tmpl']->assign("area_list", $result['area_list']); if ($area_id > 0) { //输出商圈 if ($quan_id > 0) { $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $quan_id); $kw_unicode = str_to_unicode_string($area_name); //有筛选 $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) "; $append_seo = $append_seo . $area_name; } $GLOBALS['tmpl']->assign("quan_list", $result['quan_list']); } //输出分类 $cate_id = $cate_item['id']; $GLOBALS['tmpl']->assign("cate_list", $result['cate_list']); //输出小分类 $deal_type_id = intval($_REQUEST['tid']); $deal_cate_id = $cate_id; if ($deal_cate_id > 0) { $GLOBALS['tmpl']->assign("scate_list", $result['scate_list']); if ($append_seo != "") { $append_seo .= " - "; } $append_seo .= $cate_item['name']; } if ($deal_type_id > 0) { $deal_type_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate_type where id = " . $deal_type_id); $deal_type_name_unicode = str_to_unicode_string($deal_type_name); $condition .= " and (match(deal_cate_match) against('" . $deal_type_name_unicode . "' IN BOOLEAN MODE)) "; $append_seo .= $deal_type_name; } $seo_title = $append_seo . $seo_title; $seo_keyword = $append_seo . $seo_keyword; $seo_description = $append_seo . $seo_keyword; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kw); $condition .= " and (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') "; $seo_title = $keyword . " - " . $seo_title; } $result = get_free_youhui_list($limit, $cate_id, $condition, ""); $GLOBALS['tmpl']->assign("list", $result['list']); $page = new Page($result['count'], app_conf("DEAL_PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); // $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index")); $site_nav[] = array('name' => $GLOBALS['lang']['FREE_YOUHUI'], 'url' => url("youhui", "fcate")); if ($_GET['model'] == "app") { echo json_encode(array('ret' => 1)); } else { $GLOBALS['tmpl']->assign("site_nav", $site_nav); $GLOBALS['tmpl']->assign("page_title", $seo_title); $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ","); $GLOBALS['tmpl']->assign("page_description", $seo_description . ","); $GLOBALS['tmpl']->display("youhui_fcate.html"); } }
/** * 组装借款搜索条件 */ function build_deal_filter_condition($param, $is_store = false) { $cate_id = intval($param['cid']); $deal_type_id = intval($param['tid']); $city_id = intval($GLOBALS['deal_city']['id']); if ($is_store) { $deal_type = intval($param['deal_type']); $condition = " and deal_type = {$deal_type} "; } else { $condition = ""; } if ($city_id > 0) { $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id)); if ($ids) { $condition .= " and city_id in (" . implode(",", $ids) . ")"; } } if ($cate_id > 0) { $cate_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id = " . $cate_id); $cate_name_unicode = str_to_unicode_string($cate_name); if ($deal_type_id > 0) { $deal_type_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate_type where id = " . $deal_type_id); $deal_type_name_unicode = str_to_unicode_string($deal_type_name); $condition .= " and (match(deal_cate_match) against('+" . $cate_name_unicode . " +" . $deal_type_name_unicode . "' IN BOOLEAN MODE)) "; } else { $condition .= " and (match(deal_cate_match) against('" . $cate_name_unicode . "' IN BOOLEAN MODE)) "; } } return $condition; }
/** * 获得商品的查询条件,根据输入的参数 * cid:分类ID, bid:品牌ID, fid_x: ID为x的分组筛选的关键词,city_id:城市ID */ function build_goods_filter_condition($filter_param, $tname = "") { $condition = " "; //禁用商城的城市传入 // $city_id = intval($filter_param['city_id']); // if($city_id>0) // { // $ids = load_auto_cache("deal_city_belone_ids",array("city_id"=>$city_id)); // if($ids) // { // if($tname) // $condition .= " and ".$tname.".city_id in (".implode(",",$ids).")"; // else // $condition .= " and city_id in (".implode(",",$ids).")"; // } // } //分类 if ($filter_param['cid'] > 0) { $cate_cache = load_auto_cache("cache_shop_cate"); $cate_info = $cate_cache[$filter_param['cid']]; $cate_name_unicode = ""; while ($cate_info) { $cate_name_unicode .= " +" . str_to_unicode_string($cate_info['name']) . " "; $cate_info = $cate_cache[$cate_info['pid']]; } if ($cate_name_unicode) { $condition .= " and (match(" . $tname . ".shop_cate_match) against('" . $cate_name_unicode . "' IN BOOLEAN MODE))"; } } //品牌 if ($filter_param['bid'] > 0) { $condition .= " and " . $tname . ".brand_id = " . $filter_param['bid']; } //标签 foreach ($filter_param as $k => $v) { if (preg_match("/fid_(\\d+)/i", $k, $matches)) { if ($v != "") { $unicode_tags[] = "+" . str_to_unicode_string($v); } } } if (count($unicode_tags) > 0) { $kw_unicode = implode(" ", $unicode_tags); //有筛选 $condition .= " and (match(" . $tname . ".tag_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } return $condition; }
public function index() { $page = intval($GLOBALS['request']['page']); if ($page == 0) { $page = 1; } $cate_id = intval($GLOBALS['request']['cate_id']); $city_id = intval($GLOBALS['request']['city_id']); $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint $keyword = strim($GLOBALS['request']['keyword']); if ($xpoint > 0) { $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance "; if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) { $where = " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} "; } $order = " distance asc "; } else { $field_append = $where = $order = ""; } $limit = ($page - 1) * PAGE_SIZE . "," . PAGE_SIZE; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kw); $where .= " (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') "; } $res = m_search_event_list($limit, $cate_id, $city_id, $where, $order, $field_append); $pattern = "/<img([^>]*)\\/>/i"; $replacement = "<img width=300 \$1 />"; foreach ($res['list'] as $k => $v) { if ($v['ypoint'] == '') { $res['list'][$k]['ypoint'] = 0; } if ($v['xpoint'] == '') { $res['list'][$k]['xpoint'] = 0; } $res['list'][$k]['icon'] = get_abs_img_root($v['icon']); $res['list'][$k]['distance'] = round($v['distance']); $res['list'][$k]['date_time'] = pass_date($v['submit_begin_time']); $res['list'][$k]['content'] = preg_replace($pattern, $replacement, get_abs_img_root($v['content'])); } $root = array(); $root['return'] = 1; $root['item'] = $res['list']; $root['page'] = array("page" => $page, "page_total" => ceil($res['count'] / PAGE_SIZE)); output($root); }
public function index() { $root = array(); $root['return'] = 1; $catalog_id = intval($GLOBALS['request']['cate_id']); //商品分类ID $cata_type_id = intval($GLOBALS['request']['cata_type_id']); //商品二级分类 $city_id = intval($GLOBALS['request']['city_id']); $quan_id = intval($GLOBALS['request']['quan_id']); $cate_id = intval($GLOBALS['request']['cate_id']); $keyword = strim($GLOBALS['request']['keyword']); $city_name = strim($GLOBALS['request']['city_name']); //城市名称 $order_type = $GLOBALS['request']['order_type']; $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $m_distance = doubleval($GLOBALS['request']['m_distance']); //范围(米) $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint /*输出分类*/ $bcate_list = getCateList(); $url_param['quan_id'] = $quan_id; $url_param['catalog_id'] = $catalog_id; $url_param['cata_type_id'] = $cata_type_id; foreach ($bcate_list as $k => $v) { $tmp_url_param = $url_param; unset($tmp_url_param['catalog_id']); $tmp_url_param['catalog_id'] = $v['id']; $tmp_url_param['catename'] = $v['name']; if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["url"] = $url; foreach ($v['bcate_type'] as $kk => $vv) { $tmp_url_param = $url_param; unset($tmp_url_param['cata_type_id']); $tmp_url_param['cata_type_id'] = $vv["id"]; $tmp_url_param['catename'] = $vv['name']; $tmp_url_param['catalog_id'] = $vv['cate_id']; if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["bcate_type"][$kk]["url"] = $url; } } /*输出分类 $bcate_list = getCateList(); $url_param['quan_id'] = $quan_id; $url_param['cate_id'] = $cate_id; $catalog_id = $cate_id; foreach($bcate_list as $k=>$v) { if($catalog_id==$v['id']) { $bcate_list['bcate_type'][$k]['act'] = 1; } $tmp_url_param = $url_param; unset($tmp_url_param['cate_id']); $tmp_url_param['cate_id']=$v['id']; $tmp_url_param['catename']=$v['name']; if($quan_id>0){ $quanname=$GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id=".$quan_id); $tmp_url_param['quanname']=$quanname; }else{ $tmp_url_param['quanname']="全城"; } $turl = url("index","youhuilist",$tmp_url_param); $url=str_replace('sjmapi','wap', $turl); $bcate_list[$k]["url"]=$url; foreach($v['bcate_type'] as $kk=>$vv){ if($catalog_id==$vv['id']) { $bcate_list['bcate_type'][$kk]['act'] = 1; } $tmp_url_param = $url_param; unset($tmp_url_param['cate_id']); $tmp_url_param['cate_id']=$vv['id']; $tmp_url_param['catename']=$vv['name']; if($quan_id>0){ $quanname=$GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id=".$quan_id); $tmp_url_param['quanname']=$quanname; }else{ $tmp_url_param['quanname']="全城"; } $turl = url("index","youhuilist",$tmp_url_param); $url=str_replace('sjmapi','wap', $turl); $bcate_list[$k]["bcate_type"][$kk]["url"]=$url; } } */ /*输出商圈*/ $quan_list = getQuanList($city_id); foreach ($quan_list as $k => $v) { /* if($catalog_id==$v['id']) { $quan_list['bcate_type'][$k]['act'] = 1; } */ $tmp_url_param = $url_param; unset($tmp_url_param['quan_id']); $tmp_url_param['quan_id'] = $v['id']; $tmp_url_param['quanname'] = $v['name']; if ($catalog_id > 0) { $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $catalog_id); $tmp_url_param['catename'] = $catename; } else { $tmp_url_param['catename'] = "全部分类"; } $turl = url("index", "youhuilist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $quan_list[$k]["url"] = $url; foreach ($v['quan_sub'] as $kk => $vv) { /* if($catalog_id==$vv['id']) { $quan_list['quan_sub'][$kk]['act'] = 1; } */ $tmp_url_param = $url_param; unset($tmp_url_param['quan_id']); $tmp_url_param['quan_id'] = $vv['id']; $tmp_url_param['quanname'] = $vv['name']; if ($catalog_id > 0) { $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $catalog_id); $tmp_url_param['catename'] = $catename; } else { $tmp_url_param['catename'] = "全部分类"; } $turl = url("index", "youhuilist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $quan_list[$k]["quan_sub"][$kk]["url"] = $url; } } $page = intval($GLOBALS['request']['page']); //分页 $page = $page == 0 ? 1 : $page; $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $sql_count = "select count(*) from " . DB_PREFIX . "youhui "; $sql = "select id,supplier_id as merchant_id,begin_time,youhui_type,total_num,end_time,name as title,list_brief as content,icon as merchant_logo,create_time,xpoint,ypoint,address as api_address,icon as image_1,\n\t\t\t\t (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance \n\t\t\t\tfrom " . DB_PREFIX . "youhui "; $now = get_gmtime(); $where = "1 = 1 and is_effect = 1 and begin_time<" . $now . " and (end_time = 0 or end_time > " . $now . ")"; if ($city_id > 0) { $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id)); if ($ids) { $where .= " and city_id in (" . implode(",", $ids) . ")"; } } if ($quan_id > 0) { $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $quan_id)); $quan_list2 = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")"); $unicode_quans = array(); foreach ($quan_list2 as $k => $v) { $unicode_quans[] = str_to_unicode_string($v['name']); } $kw_unicode = implode(" ", $unicode_quans); $where .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) "; } if ($cate_id > 0) { $where .= " and deal_cate_id = {$cate_id}"; } if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kw[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kw); $where .= " and match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%' "; } $merchant_id = intval($GLOBALS['request']['merchant_id']); if ($merchant_id > 0) { $youhui_ids = $GLOBALS['db']->getOne("select group_concat(youhui_id) from " . DB_PREFIX . "youhui_location_link where location_id = " . $merchant_id); if ($youhui_ids) { $where .= " and id in (" . $youhui_ids . ") "; } else { $where .= " and id = 0 "; } } $sql_count .= " where " . $where; $sql .= " where " . $where; if ($xpoint > 0) { $orderby = " order by distance asc "; } else { $orderby = " order by sort desc,id desc"; } /*排序*/ if ($order_type == 'avg_point') { $orderby = " order by avg_point desc,id desc "; } elseif ($order_type == 'newest') { $orderby = " order by create_time desc,id desc "; } elseif ($order_type == 'buy_count') { $orderby = " order by view_count desc,id desc "; } $sql .= $orderby . " limit " . $limit; //echo $sql; exit; $total = $GLOBALS['db']->getOne($sql_count); $page_total = ceil($total / $page_size); $list = $GLOBALS['db']->getAll($sql); $youhui_list = array(); foreach ($list as $item) { $youhui_list[] = m_youhuiItem($item); } foreach ($youhui_list as $k => $v) { $youhui_list[$k]['logo'] = get_abs_img_root(get_spec_image($v['logo'], 140, 85, 0)); } /*输出分类*/ //$bcate_list = getCateList(); /*输出商圈*/ //$quan_list=getQuanList($city_id); //print_r($quan_list);exit; if ($bcate_list === false) { $root['bcate_list'] = array(); } else { $root['bcate_list'] = $bcate_list; } if ($quan_list === false) { $root['quan_list'] = array(); } else { $root['quan_list'] = $quan_list; } $root['item'] = $youhui_list; $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size); $root['page_title'] = "优惠券列表"; //fwb 2014-08-27 $root['city_name'] = $city_name; output($root); }
public function malllist() { $condition = " is_effect = 1 and is_delete = 0 and d.buy_type<>1 and supplier_id<>0 "; //条件 $join_str = ""; $sort_field = "current_price"; $sort_type = intval($_POST['price_sort']) === 1 ? "ASC" : "desc"; if ($_POST['cate_id']) { $cate_id = $_POST['cate_id']; $shop_cate_grade = $GLOBALS['db']->getOne("select grade from " . DB_PREFIX . "shop_cate where id =" . $cate_id); switch ($shop_cate_grade) { case "0": // 一级分类 $condition .= " and ( shop_cate_id=" . $cate_id . " or p_shop_cate_id=" . $cate_id . ")"; break; case "1": // 二级分类 $condition .= " and ( shop_cate_id=" . $cate_id . " or shop_cate_id in (select id from " . DB_PREFIX . "shop_cate where pid=" . $cate_id . "))"; break; default: $condition .= " and shop_cate_id=" . $cate_id; } } if (isset($_POST['city_id']) && $_POST['city_id'] > 1) { $condition .= " and city_id=" . $_POST['city_id']; } $distance = !empty($_POST['distance']) ? $_POST['distance'] : 10000000; //$distance = 10000000; $lng = '119.025595'; $lat = '33.596043'; if (!empty($_POST['lng']) && $_POST['lng'] != "" && !empty($_POST['lat']) && $_POST['lat'] != "") { $lng = $_POST['lng']; $lat = $_POST['lat']; $condition .= " and id in ( select deal_id from " . DB_PREFIX . "deal_location_link where location_id in (select id from " . DB_PREFIX . "supplier_location where " . search_where_radius($distance, $lng, $lat, "location") . "))"; } $num = empty($_POST['num']) ? 30 : $_POST['num']; // page size $prepage = empty($_POST['prepage']) ? 0 : $_POST['prepage']; $start = $prepage * $num + 0; $limit = $start . "," . $num; $kw = addslashes(htmlspecialchars(trim($_REQUEST['keyword']))); if ($kw != '') { $GLOBALS['tmpl']->assign('keyword', $kw); if ($add_title != '') { $add_title .= "-"; } $add_title .= $kw; $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(d.tag_match,d.name_match,d.locate_match,d.shop_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE))"; //$condition.=" and (d.name like '%".$kw."%' or d.sub_name like '%".$kw."%' or d.brief like '%".$kw."%' or d.description like '%".$kw."%')"; } // file_put_contents("/tmp/mall.log", "\n".json_encode($_POST)."\n",FILE_APPEND); // file_put_contents("/tmp/mall.log", "\n condition:$condition\n",FILE_APPEND); $result = search_goods_list($limit, intval($cate_id), $condition, "d." . $sort_field . " " . $sort_type, false, $join_str); if ($result === FALSE) { $result = array('ret' => '102'); } else { $result['ret'] = '0'; $result['goodslist'] = array(); foreach ($result['list'] as $index => $val) { $result['goodslist'][$index]['brand_name'] = $GLOBALS['db']->getOne("select name from tb_brand where id =" . $val['brand_id']); $sql = "select xpoint as lng,ypoint as lat,ROUND(SQRT(POW(ABS(X(location)-" . $lng . ")/0.001024*100,2)+POW(ABS(Y(location)-" . $lat . ")/0.000886*100,2))) AS `dis` from " . DB_PREFIX . "supplier_location where id in (select location_id from " . DB_PREFIX . "deal_location_link where deal_id=" . $val['id'] . ") order by dis desc limit 1"; $location = $GLOBALS['db']->getAll($sql); $result['goodslist'][$index]['xpoint'] = '119.025595'; $result['goodslist'][$index]['ypoint'] = '33.596043'; if (!$location) { $result['goodslist'][$index]['location_list'] = array(); } else { $result['goodslist'][$index]['location_list'] = $location; $result['goodslist'][$index]['xpoint'] = $location[0]['lng']; $result['goodslist'][$index]['ypoint'] = $location[0]['lat']; $result['goodslist'][$index]['dis'] = $location[0]['dis']; } $result['goodslist'][$index]['id'] = $val['id']; $result['goodslist'][$index]['name'] = $val['name']; $result['goodslist'][$index]['sub_name'] = $val['sub_name']; $result['goodslist'][$index]['cate_id'] = $val['cate_id']; $result['goodslist'][$index]['img'] = $val['img']; //$result['goodslist'][$index]['description'] = $val['description']; $result['goodslist'][$index]['origin_price'] = $val['origin_price']; $result['goodslist'][$index]['current_price'] = $val['current_price']; $result['goodslist'][$index]['city_id'] = $val['city_id']; $result['goodslist'][$index]['icon'] = $val['icon']; $result['goodslist'][$index]['create_time'] = $val['create_time']; $result['goodslist'][$index]['brand_id'] = $val['brand_id']; $result['goodslist'][$index]['url'] = $val['url']; $result['goodslist'][$index]['is_delivery'] = $val['is_delivery']; $result['goodslist'][$index]['is_can_buy'] = is_can_buy($val['shop_cate_id']) ? '1' : '0'; $result['goodslist'][$index]['is_cash_pay'] = $val['is_cash_pay']; } $result['num'] = strval($num); $result['page'] = strval($prepage + 1); unset($result['list']); } echo json_encode($result); }
public function index() { $GLOBALS['tmpl']->assign("page_title", "最新动态"); $param = array(); //参数集合 //数据来源参数 $r = strim($_REQUEST['r']); //推荐类型 $param['r'] = $r ? $r : ''; $GLOBALS['tmpl']->assign("p_r", $r); $id = intval($_REQUEST['id']); //分类id $param['id'] = $id; $GLOBALS['tmpl']->assign("p_id", $id); $loc = strim($_REQUEST['loc']); //地区 $param['loc'] = $loc; $GLOBALS['tmpl']->assign("p_loc", $loc); $state = intval($_REQUEST['state']); //状态 $param['state'] = $state; $GLOBALS['tmpl']->assign("p_state", $state); $tag = strim($_REQUEST['tag']); //标签 $param['tag'] = $tag; $GLOBALS['tmpl']->assign("p_tag", $tag); $kw = strim($_REQUEST['k']); //关键词 $param['k'] = $kw; $GLOBALS['tmpl']->assign("p_k", $kw); $type = intval($_REQUEST['type']); //推荐类型 $param['type'] = $type; $GLOBALS['tmpl']->assign("p_type", $type); if (intval($_REQUEST['redirect']) == 1) { $param = array(); if ($r != "") { $param = array_merge($param, array("r" => $r)); } if ($id > 0) { $param = array_merge($param, array("id" => $id)); } if ($loc != "") { $param = array_merge($param, array("loc" => $loc)); } if ($state != "") { $param = array_merge($param, array("state" => $state)); } if ($tag != "") { $param = array_merge($param, array("tag" => $tag)); } if ($kw != "") { $param = array_merge($param, array("k" => $kw)); } if ($type != "") { $param = array_merge($param, array("type" => $type)); } app_redirect(url_wap("deals", $param)); } $image_list = load_dynamic_cache("INDEX_IMAGE_LIST"); if ($image_list === false) { $image_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "index_image order by sort asc"); set_dynamic_cache("INDEX_IMAGE_LIST", $image_list); } $GLOBALS['tmpl']->assign("image_list", $image_list); $cate_list = load_dynamic_cache("INDEX_CATE_LIST"); if (!$cate_list) { $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc"); set_dynamic_cache("INDEX_CATE_LIST", $cate_list); } $cate_result = array(); foreach ($cate_list as $k => $v) { if ($v['pid'] == 0) { $temp_param = $param; $cate_result[$v['id']]['id'] = $v['id']; $cate_result[$v['id']]['name'] = $v['name']; $temp_param['id'] = $v['id']; $cate_result[$v['id']]['url'] = url_wap("deals", $temp_param); } else { if ($v['pid'] > 0) { $temp_param['id'] = $v['id']; $cate_result[$v['pid']]['child'][] = array('id' => $v['id'], 'name' => $v['name'], 'url' => url_wap("deals", $temp_param)); } } if ($v['id'] == $id) { $GLOBALS['tmpl']->assign("cate_name", $v['name']); } } $GLOBALS['tmpl']->assign("cate_list", $cate_result); $pid = $id; //获取父类id if ($cate_list) { $pid = $this->get_child($cate_list, $pid); } /*子分类 start*/ $cate_ids = array(); $is_child = false; $temp_cate_ids = array(); if ($cate_list) { $child_cate_result = array(); foreach ($cate_list as $k => $v) { if ($v['pid'] == $pid) { if ($v['id'] > 0) { $temp_param = $param; $child_cate_result[$v['id']]['id'] = $v['id']; $child_cate_result[$v['id']]['name'] = $v['name']; $temp_param['id'] = $v['id']; $child_cate_result[$v['id']]['url'] = url_wap("deals", $temp_param); if ($id == $v['id']) { $is_child = true; } } } if ($v['pid'] == $pid || $pid == 0) { $temp_cate_ids[] = $v['id']; } } } //假如选择了子类 那么使用子类ID 否则使用 父类和其子类 if ($is_child) { $cate_ids[] = $id; } else { $cate_ids[] = $pid; $cate_ids = array_merge($cate_ids, $temp_cate_ids); } $cate_ids = array_filter($cate_ids); $GLOBALS['tmpl']->assign("child_cate_list", $child_cate_result); $GLOBALS['tmpl']->assign("pid", $pid); /*子分类 end*/ $city_list = load_dynamic_cache("INDEX_CITY_LIST"); if ($type == 1) { if (!$city_list) { $city_list = $GLOBALS['db']->getAll("select province from " . DB_PREFIX . "deal where type=1 and is_effect =1 group by province order by sort asc"); // set_dynamic_cache("INDEX_CITY_LIST",$city_list); } } if ($type == 0) { if (!$city_list) { $city_list = $GLOBALS['db']->getAll("select province from " . DB_PREFIX . "deal where type=0 and is_effect =1 group by province order by sort asc"); // set_dynamic_cache("INDEX_CITY_LIST",$city_list); } } foreach ($city_list as $k => $v) { $temp_param = $param; $temp_param['loc'] = $v['province']; $city_list[$k]['url'] = url_wap("deals", $temp_param); if ($v['id']) { $child = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "region_conf where pid=" . $v['id']); if ($child) { foreach ($child as $k1 => $v1) { $temp_param['loc'] = $v1['name']; $child[$k1]['url'] = url_wap("deals", $temp_param); } $city_list[$k]['child'] = $child; } } } $GLOBALS['tmpl']->assign("city_list", $city_list); //=================region_conf============== $state_list = array(1 => array("name" => "筹资成功"), 2 => array("name" => "筹资失败"), 3 => array("name" => "筹资中")); foreach ($state_list as $k => $v) { $temp_param = $param; $temp_param['state'] = $k; $state_list[$k]['url'] = url_wap("deals", $temp_param); } if ($state == 0) { $GLOBALS['tmpl']->assign("state_name", "所有项目"); } else { $GLOBALS['tmpl']->assign("state_name", $state_list[$state]['name']); } $GLOBALS['tmpl']->assign("state_list", $state_list); $page_size = PAGE_SIZE; $step_size = PAGE_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); $condition = " d.is_delete = 0 and d.is_effect = 1 "; if ($r != "") { if ($r == "new") { $condition .= " and " . NOW_TIME . " - d.begin_time < " . 7 * 24 * 3600 . " and " . NOW_TIME . " - d.begin_time > 0 "; //上线不超过一天 $GLOBALS['tmpl']->assign("page_title", "最新上线"); } elseif ($r == "rec") { $condition .= " and d.is_recommend = 1 "; $GLOBALS['tmpl']->assign("page_title", "推荐项目"); } elseif ($r == "yure") { $condition .= " and " . NOW_TIME . " < d.begin_time "; $GLOBALS['tmpl']->assign("page_title", "正在预热"); } elseif ($r == "nend") { $condition .= " and d.end_time - " . NOW_TIME . " < " . 7 * 24 * 3600 . " and d.end_time - " . NOW_TIME . " > 0 "; //三天就要结束 $GLOBALS['tmpl']->assign("page_title", "即将结束"); } elseif ($r == "classic") { $condition .= " and d.is_classic = 1 "; $GLOBALS['tmpl']->assign("page_title", "经典项目"); $GLOBALS['tmpl']->assign("is_classic", true); } elseif ($r == "limit_price") { $condition .= " and max(d.limit_price) "; $GLOBALS['tmpl']->assign("page_title", "最高目标金额"); } } switch ($state) { //筹资成功 case 1: $condition .= " and d.is_success=1 and d.end_time < " . NOW_TIME; $GLOBALS['tmpl']->assign("page_title", "筹资成功"); break; //筹资失败 //筹资失败 case 2: $condition .= " and d.end_time < " . NOW_TIME . " and d.end_time!=0 and d.is_success=0 "; $GLOBALS['tmpl']->assign("page_title", "筹资失败"); break; //筹资中 //筹资中 case 3: $condition .= " and (d.end_time > " . NOW_TIME . " or d.end_time=0 ) and d.begin_time < " . NOW_TIME . " "; $GLOBALS['tmpl']->assign("page_title", "筹资中"); break; } if (count($cate_ids) > 0) { $condition .= " and d.cate_id in (" . implode(",", $cate_ids) . ")"; $GLOBALS['tmpl']->assign("page_title", $cate_result[$id]['name']); } if ($loc != "") { $condition .= " and (d.province = '" . $loc . "' or city = '" . $loc . "') "; $GLOBALS['tmpl']->assign("page_title", $loc); } if ($tag != "") { $unicode_tag = str_to_unicode_string($tag); $condition .= " and match(d.tags_match) against('" . $unicode_tag . "' IN BOOLEAN MODE) "; $GLOBALS['tmpl']->assign("page_title", $tag); } if ($type !== "") { $type = intval($type); $condition .= " and type={$type} "; } if ($kw != "") { $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(d.name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or match(d.tags_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or d.name like '%" . $kw . "%') "; $GLOBALS['tmpl']->assign("page_title", $kw); } $result = get_deal_list($limit, $condition); foreach ($result['list'] as $k => $v) { } $GLOBALS['tmpl']->assign("deal_list", $result['list']); $GLOBALS['tmpl']->assign("deal_count", intval($result['rs_count'])); $page = new Page($result['rs_count'], $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("usermessage_url", url_wap("ajax#usermessage", array("id" => intval($GLOBALS['user_info']['id'])))); $GLOBALS['tmpl']->display("deals_index.html"); }
public function deals() { $r = strim($_REQUEST['r']); //推荐类型 $id = intval($_REQUEST['id']); //分类id $loc = strim($_REQUEST['loc']); //地区 $tag = strim($_REQUEST['tag']); //标签 $kw = strim($_REQUEST['k']); //关键词 $page_size = DEAL_PAGE_SIZE; $step_size = DEAL_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; $condition = " is_delete = 0 and is_effect = 1 "; if ($r != "") { if ($r == "new") { $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time > 0 "; //上线不超过一天 } if ($r == "nend") { $condition .= " and end_time - " . NOW_TIME . " < " . 24 * 3600 . " and end_time - " . NOW_TIME . " > 0 "; //当天就要结束 } if ($r == "classic") { $condition .= " and is_classic = 1 "; } } if ($id > 0) { $condition .= " and cate_id = " . $id; } if ($loc != "") { $condition .= " and (province = '" . $loc . "' or city = '" . $loc . "') "; } if ($tag != "") { $unicode_tag = str_to_unicode_string($tag); $condition .= " and match(tags_match) against('" . $unicode_tag . "' IN BOOLEAN MODE) "; } if ($kw != "") { $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or match(tags_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $kw . "%') "; } $deal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where " . $condition . " order by sort asc limit " . $limit); $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where " . $condition); foreach ($deal_list as $k => $v) { $deal_list[$k]['remain_days'] = floor(($v['end_time'] - NOW_TIME) / (24 * 3600)); $deal_list[$k]['percent'] = round($v['support_amount'] / $v['limit_price'] * 100); } $GLOBALS['tmpl']->assign("deal_list", $deal_list); $data['html'] = $GLOBALS['tmpl']->fetch("inc/deal_list.html"); if ($step * $step_size < $page_size) { if ($deal_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 index() { $field = es_cookie::get("shop_sort_field"); $field_sort = es_cookie::get("shop_sort_type"); require APP_ROOT_PATH . 'app/Lib/page.php'; $level_list = load_auto_cache("level"); $GLOBALS['tmpl']->assign("level_list", $level_list['list']); if (check_ipop_limit(get_client_ip(), "transfer_status", 10)) { syn_transfer_status(); } if (trim($_REQUEST['cid']) == "last") { $cate_id = "-1"; $page_title = $GLOBALS['lang']['LAST_SUCCESS_DEALS'] . " - "; } else { $cate_id = intval($_REQUEST['cid']); } if ($cate_id == 0) { $page_title = $GLOBALS['lang']['ALL_TRANSFER'] . " - "; } $keywords = trim(htmlspecialchars($_REQUEST['keywords'])); $GLOBALS['tmpl']->assign("keywords", $keywords); $level = intval($_REQUEST['level']); $GLOBALS['tmpl']->assign("level", $level); $interest = intval($_REQUEST['interest']); $GLOBALS['tmpl']->assign("interest", $interest); $months = intval($_REQUEST['months']); $GLOBALS['tmpl']->assign("months", $months); $months_type = intval($_REQUEST['months_type']); $GLOBALS['tmpl']->assign("months_type", $months_type); $lefttime = intval($_REQUEST['lefttime']); $GLOBALS['tmpl']->assign("lefttime", $lefttime); $city = intval($_REQUEST['city']); $GLOBALS['tmpl']->assign("city_id", $city); $scity = intval($_REQUEST['scity']); $GLOBALS['tmpl']->assign("scity_id", $scity); //输出分类 $deal_cates_db = load_auto_cache("cache_deal_cate"); $deal_cates = array(); foreach ($deal_cates_db as $k => $v) { if ($cate_id == $v['id']) { $v['current'] = 1; $page_title = $v['name'] . " - "; } $v['url'] = url("index", "transfer", array("cid" => $v['id'])); $deal_cates[] = $v; } unset($deal_cates_db); //输出投标列表 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $page_args = array(); $sfield = ""; switch ($field) { case "borrow_amount": $sfield = "dlt.transfer_amount"; break; case "rate": $sfield = "d.rate"; break; case "repay_time": $sfield = "dlt.last_repay_time"; break; case "remain_time": $sfield = "dlt.near_repay_time"; break; default: $sfield = ""; } $condition = " AND dlt.status=1 "; if ($cate_id > 0) { $condition .= "AND d.deal_status >=4 and cate_id=" . $cate_id; if ($sfield && $field_sort) { $orderby = "{$sfield} {$field_sort} ,d.deal_status desc , d.sort DESC,d.id DESC"; } else { $orderby = "d.update_time DESC ,d.sort DESC,d.id DESC"; } } elseif ($cate_id == 0) { if ($sfield && $field_sort) { $orderby = "{$sfield} {$field_sort}, dlt.create_time DESC , dlt.id DESC "; } else { $orderby = " d.create_time DESC , dlt.id DESC"; } } elseif ($cate_id == "-1") { $condition .= "AND d.deal_status >=4 AND dlt.t_user_id > 0 "; $orderby = "dlt.transfer_time DESC,d.create_time DESC , dlt.id DESC"; } if ($keywords) { $kw_unicode = str_to_unicode_string($keywords); $condition .= " and (match(d.name_match,d.deal_cate_match,d.tag_match,d.type_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } if ($level > 0) { $point = $level_list['point'][$level]; $condition .= " AND d.user_id in(SELECT u.id FROM " . DB_PREFIX . "user u LEFT JOIN " . DB_PREFIX . "user_level ul ON ul.id=u.level_id WHERE ul.point >= {$point})"; } if ($interest > 0) { $condition .= " AND d.rate >= " . $interest; } if ($months > 0) { if ($months == 12) { $condition .= " AND d.repay_time <= " . $months; } elseif ($months == 18) { $condition .= " AND d.repay_time >= " . $months; } } if ($months_type > 0) { if ($months_type == 1) { $condition .= " AND ((d.repay_time < 3 and d.repay_time_type = 1) or d.repay_time_type = 0) "; } else { if ($months_type == 2) { $condition .= " AND d.repay_time in (3,4,5) and d.repay_time_type = 1 "; } else { if ($months_type == 3) { $condition .= " AND d.repay_time in (6,7,8) and d.repay_time_type = 1 "; } else { if ($months_type == 4) { $condition .= " AND d.repay_time in (9,10,11) and d.repay_time_type = 1 "; } else { $condition .= " AND d.repay_time >= 12 and d.repay_time_type = 1 "; } } } } } if ($city > 0) { if ($scity > 0) { $dealid_list = $GLOBALS['db']->getAll("SELECT deal_id FROM " . DB_PREFIX . "deal_city_link where city_id = " . $scity); } else { $dealid_list = $GLOBALS['db']->getAll("SELECT deal_id FROM " . DB_PREFIX . "deal_city_link where city_id = " . $city); } $flatmap = array_map("array_pop", $dealid_list); $s2 = implode(',', $flatmap); $condition .= " AND id in (" . $s2 . ") "; } if ($lefttime > 0) { $condition .= " AND (d.next_repay_time + 24*3600 - 1 - " . TIME_UTC . ") <= " . $lefttime * 24 * 3600 . " AND dlt.t_user_id = 0 "; } if (es_cookie::get("shop_sort_field") == "ulevel") { $union_sql = ' LEFT join ' . DB_PREFIX . 'user u ON d.user_id = u.id '; $extfield = ",u.level_id "; } $limit = ($page - 1) * app_conf("DEAL_PAGE_SIZE") . "," . app_conf("DEAL_PAGE_SIZE"); $result = get_transfer_list($limit, $condition, $extfield, $union_sql, $orderby); if ($result['rs_count'] > 0) { $page_args['cid'] = $cate_id; $page_args['keywords'] = $keywords; $page_args['level'] = $level; $page_args['interest'] = $interest; $page_args['months'] = $months; $page_args['lefttime'] = $lefttime; $page_args['months_type'] = $months_type; $page_args['city'] = $city; $page_pram = ""; foreach ($page_args as $k => $v) { $page_pram .= "&" . $k . "=" . $v; } $page = new Page($result['rs_count'], app_conf("DEAL_PAGE_SIZE"), $page_pram); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign('transfer_list', $result['list']); } //分类 $cate_list_url = array(); $tmp_args = $page_args; $tmp_args['cid'] = 0; $cate_list_url[0]['url'] = url("index", "deals#index", $tmp_args); $cate_list_url[0]['name'] = "不限"; $cate_list_url[0]['id'] = 0; foreach ($deal_cates as $k => $v) { $cate_list_url[$k + 1] = $v; $tmp_args = $page_args; $tmp_args['cid'] = $v['id']; $cate_list_url[$k + 1]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('cate_list_url', $cate_list_url); //利率 $interest_url = array(array("interest" => 0, "name" => "不限"), array("interest" => 10, "name" => "10%"), array("interest" => 12, "name" => "12%"), array("interest" => 15, "name" => "15%"), array("interest" => 18, "name" => "18")); foreach ($interest_url as $k => $v) { $tmp_args = $page_args; $tmp_args['interest'] = $v['interest']; $interest_url[$k]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('interest_url', $interest_url); //几天内 $lefttime_url = array(array("lefttime" => 0, "name" => "不限"), array("lefttime" => 1, "name" => "1天"), array("lefttime" => 3, "name" => "3天"), array("lefttime" => 6, "name" => "6天"), array("lefttime" => 9, "name" => "9天"), array("lefttime" => 12, "name" => "12天")); foreach ($lefttime_url as $k => $v) { $tmp_args = $page_args; $tmp_args['lefttime'] = $v['lefttime']; $lefttime_url[$k]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('lefttime_url', $lefttime_url); //借款期限 $months_type_url = array(array("name" => "不限"), array("name" => "3 个月以下"), array("name" => "3-6 个月"), array("name" => "6-9 个月"), array("name" => "9-12 个月"), array("name" => "12 个月以上")); foreach ($months_type_url as $k => $v) { $tmp_args = $page_args; $tmp_args['months_type'] = $k; $months_type_url[$k]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('months_type_url', $months_type_url); //城市 $temp_city_urls = load_auto_cache("deal_city"); $city_urls[0]['id'] = 0; $city_urls[0]['name'] = "全部"; if (count($temp_city_urls) == 1) { $temp_city_urls = $temp_city_urls[key($temp_city_urls)]['child']; } $temp_city_urls = array_merge($city_urls, $temp_city_urls); $city_urls = array(); foreach ($temp_city_urls as $k => $v) { $city_urls[$v['id']] = $v; $tmp_args = $page_args; $tmp_args['city'] = $v['id']; $city_urls[$v['id']]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('city_urls', $city_urls); $sub_citys = $city_urls[$city]['child']; foreach ($sub_citys as $k => $v) { $tmp_args = $page_args; $tmp_args['city'] = $v['pid']; $tmp_args['scity'] = $v['id']; $sub_citys[$k]['url'] = url("index", "transfer#index", $tmp_args); } $GLOBALS['tmpl']->assign('sub_citys', $sub_citys); //使用技巧 $use_tech_list = get_article_list(4, 6); $GLOBALS['tmpl']->assign("use_tech_list", $use_tech_list); //输出公告 $notice_list = get_notice(3); $GLOBALS['tmpl']->assign("notice_list", $notice_list); //会员等级 $level_list_url = array(); $tmp_args = $page_args; $tmp_args['level'] = 0; $level_list_url[0]['url'] = url("index", "deals#index", $tmp_args); $level_list_url[0]['name'] = "不限"; foreach ($level_list['list'] as $k => $v) { $tmp_args = $page_args; $tmp_args['level'] = $v['id']; $level_list_url[$k + 1] = $v; $level_list_url[$k + 1]['url'] = url("index", "deals#index", $tmp_args); } $GLOBALS['tmpl']->assign('level_list_url', $level_list_url); $GLOBALS['tmpl']->assign("page_title", $page_title . $GLOBALS['lang']['FINANCIAL_MANAGEMENT']); $GLOBALS['tmpl']->assign("cate_id", $cate_id); $GLOBALS['tmpl']->assign("cid", strim($_REQUEST['cid'])); $GLOBALS['tmpl']->assign("keywords", $keywords); $GLOBALS['tmpl']->assign("deal_cate_list", $deal_cates); $GLOBALS['tmpl']->assign("field", $field); $GLOBALS['tmpl']->assign("field_sort", $field_sort); $GLOBALS['tmpl']->display("page/transfers.html"); }
/** * 构建活动查询条件 * @param unknown_type $param * @return string */ function build_event_filter_condition($param, $tname = "") { $area_id = intval($param['aid']); $quan_id = intval($param['qid']); $cate_id = intval($param['cid']); $city_id = intval($param['city_id']); $condition = ""; if ($city_id > 0) { $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id)); if ($ids) { if ($tname) { $condition .= " and " . $tname . ".city_id in (" . implode(",", $ids) . ")"; } else { $condition .= " and city_id in (" . implode(",", $ids) . ")"; } } } if ($area_id > 0) { if ($quan_id > 0) { $area_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id = " . $quan_id); $kw_unicodes[] = str_to_unicode_string($area_name); $kw_unicode = implode(" ", $kw_unicodes); //有筛选 if ($tname) { $condition .= " and (match(" . $tname . ".locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) "; } else { $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE)) "; } } else { $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $area_id)); $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")"); $unicode_quans = array(); foreach ($quan_list as $k => $v) { $unicode_quans[] = str_to_unicode_string($v['name']); } $kw_unicode = implode(" ", $unicode_quans); if ($tname) { $condition .= " and (match(" . $tname . ".locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } else { $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } } } if ($cate_id > 0) { $cate_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "event_cate where id = " . $cate_id); $cate_name_unicode = str_to_unicode_string($cate_name); if ($tname) { $condition .= " and (match(" . $tname . ".cate_match) against('" . $cate_name_unicode . "' IN BOOLEAN MODE)) "; } else { $condition .= " and (match(cate_match) against('" . $cate_name_unicode . "' IN BOOLEAN MODE)) "; } } return $condition; }
public function index2() { $quan_id = intval($GLOBALS['request']['quan_id']); //商圈ID $city_id = intval($GLOBALS['request']['city_id']); $city_name = strim($GLOBALS['request']['city_name']); //城市分类ID //print_r($GLOBALS['request']); $root = array(); $root['return'] = 1; $city_list = $GLOBALS['db']->getAll("select *from " . DB_PREFIX . "deal_city where is_effect=1 and is_delete=0 order by id asc"); $root['city_list'] = $city_list; if ($city_id > 0) { /*当前城市商圈*/ $indexs_quan = $GLOBALS['cache']->get("MOBILE_INDEX2_QUAN_" . intval($GLOBALS['city_id'])); if ($indexs_quan === false) { $indexs_quan = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "area where pid=0 and city_id=" . $city_id . " order by sort desc"); } if ($indexs_quan) { $root['quans'] = $indexs_quan; } else { $root['quans'] = array(); } $root['quan_id'] = $quan_id; /*城市列表*/ /*当前城市热门团购(正在团购 的推荐商品)*/ $time = get_gmtime(); $condition = " is_effect = 1 and is_delete = 0 and is_shop = 0 and (" . $time . ">= begin_time or begin_time = 0) and (" . $time . "< end_time or end_time = 0) and buy_status <> 2"; if ($city_id == 0) { $city = get_current_deal_city(); $city_id = $city['id']; } if ($city_id > 0) { $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id)); if ($ids) { $condition .= " and city_id in (" . implode(",", $ids) . ")"; } } if ($quan_id > 0) { $ids = load_auto_cache("deal_quan_ids", array("quan_id" => $quan_id)); $quan_list = $GLOBALS['db']->getAll("select `name` from " . DB_PREFIX . "area where id in (" . implode(",", $ids) . ")"); $unicode_quans = array(); foreach ($quan_list as $k => $v) { $unicode_quans[] = str_to_unicode_string($v['name']); } $kw_unicode = implode(" ", $unicode_quans); $condition .= " and (match(locate_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))"; } $sql = "select id,name,sub_name,icon,origin_price,current_price,buy_count from " . DB_PREFIX . "deal where " . $condition . " order by is_recommend desc,sort desc limit 20"; $deal_list = $GLOBALS['db']->getAll($sql); $taday_begin = to_timespan(to_date(get_gmtime(), 'Y-m-d')); $taday_end = $taday_begin * 24 * 60 * 60; foreach ($deal_list as $k => $v) { $deal_list[$k]['current_price'] = round($v['current_price'], 2); $deal_list[$k]['origin_price'] = round($v['origin_price'], 2); $deal_list[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 300, 181, 0)); if ($v['begin_time'] > 0 && ($taday_begin < $v['begin_time'] && $v['begin_time'] < $taday_end)) { $deal_list[$k]['is_taday'] = 1; } else { if ($v['begin_time'] == 0 && ($taday_begin < $v['create_time'] && $v['create_time'] < $taday_end)) { $deal_list[$k]['is_taday'] = 1; } else { $deal_list[$k]['is_taday'] = 0; } } unset($deal_list[$k]['begin_time'], $deal_list[$k]['create_time']); } if ($deal_list) { $root['deal_list'] = $deal_list; } else { $root['deal_list'] = array(); } } else { $root['quans'] = array(); $root['quan_id'] = 0; $root['deal_list'] = array(); } $root['city_name'] = $city_name; $root['page_title'] = "选择城市"; output($root); }
public function index() { $l = intval($_REQUEST['l']) ? "limit " . intval($_REQUEST['l']) : ""; $r = strim($_REQUEST['r']); //推荐类型 $id = intval($_REQUEST['id']); //分类id $loc = strim($_REQUEST['loc']); //地区 $tag = strim($_REQUEST['tag']); //标签 $kw = strim($_REQUEST['k']); //关键词 if (intval($_REQUEST['redirect']) == 1) { $param = array(); if ($r != "") { $param = array_merge($param, array("r" => $r)); } if ($id > 0) { $param = array_merge($param, array("id" => $id)); } if ($loc != "") { $param = array_merge($param, array("loc" => $loc)); } if ($tag != "") { $param = array_merge($param, array("tag" => $tag)); } if ($kw != "") { $param = array_merge($param, array("k" => $kw)); } } $image_list = load_dynamic_cache("INDEX_IMAGE_LIST"); if ($image_list === false) { $image_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "index_image order by sort asc"); } $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; } } $loc_result = load_dynamic_cache("INDEX_CATE_LOC"); if ($loc_result === false) { $loc_list = $GLOBALS['db']->getAll("select province from " . DB_PREFIX . "deal GROUP by province"); $loc_result = array(); foreach ($loc_list as $k => $v) { $loc_result[$v['province']] = $v; } } $condition = " is_delete = 0 and is_effect = 1 "; if ($r != "") { if ($r == "new") { $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time > 0 "; //上线不超过一天 } if ($r == "nend") { $condition .= " and end_time - " . NOW_TIME . " < " . 24 * 3600 . " and end_time - " . NOW_TIME . " > 0 "; //当天就要结束 } if ($r == "classic") { $condition .= " and is_classic = 1 "; } } if ($id > 0) { $condition .= " and cate_id = " . $id; } if ($loc != "" && $loc != "all") { $condition .= " and (province = '" . $loc . "' or city = '" . $loc . "') "; } if ($tag != "") { $unicode_tag = str_to_unicode_string($tag); $condition .= " and match(tags_match) against('" . $unicode_tag . "' IN BOOLEAN MODE) "; } if ($kw != "") { $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or match(tags_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $kw . "%') "; } $deal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where " . $condition . " order by sort asc "); $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where " . $condition); foreach ($deal_list as $k => $v) { $deal_list[$k]['support_amount'] = number_price_format($deal_list[$k]['support_amount']); $deal_list[$k]['image'] = APP_ROOT . substr($deal_list[$k]['image'], 1); $deal_list[$k]['remain_days'] = floor(($v['end_time'] - NOW_TIME) / (24 * 3600)); $deal_list[$k]['percent'] = round($v['support_amount'] / $v['limit_price'] * 100); $deal_list[$k]['limit_price'] = number_format($v['limit_price']); } $arr = array('data' => $deal_list, 'total' => $deal_count); echo json_encode($arr); }
public function index() { $root = array(); $root['return'] = 1; $catalog_id = intval($GLOBALS['request']['catalog_id']); //商品分类ID $cata_type_id = intval($GLOBALS['request']['cata_type_id']); //商品二级分类 $city_id = intval($GLOBALS['request']['city_id']); //城市分类ID $page = intval($GLOBALS['request']['page']); //分页 $keyword = strim($GLOBALS['request']['keyword']); $page = $page == 0 ? 1 : $page; $quan_id = intval($GLOBALS['request']['quan_id']); //商圈id $order_type = strim($GLOBALS['request']['order_type']); //if(!$city_id) //{ // $city = get_current_deal_city(); // $city_id = $city['id']; //} $ytop = $latitude_top = floatval($GLOBALS['request']['latitude_top']); //最上边纬线值 ypoint $ybottom = $latitude_bottom = floatval($GLOBALS['request']['latitude_bottom']); //最下边纬线值 ypoint $xleft = $longitude_left = floatval($GLOBALS['request']['longitude_left']); //最左边经度值 xpoint $xright = $longitude_right = floatval($GLOBALS['request']['longitude_right']); //最右边经度值 xpoint $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']); //ypoint $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']); //xpoint /*输出分类*/ $bcate_list = getCateList(); $url_param['quan_id'] = $quan_id; $url_param['catalog_id'] = $catalog_id; $url_param['cata_type_id'] = $cata_type_id; foreach ($bcate_list as $k => $v) { $tmp_url_param = $url_param; unset($tmp_url_param['catalog_id']); $tmp_url_param['catalog_id'] = $v['id']; $tmp_url_param['catename'] = $v['name']; if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = wap_url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["url"] = $url; foreach ($v['bcate_type'] as $kk => $vv) { $tmp_url_param = $url_param; unset($tmp_url_param['cata_type_id']); $tmp_url_param['cata_type_id'] = $vv["id"]; $tmp_url_param['catename'] = $vv['name']; $tmp_url_param['catalog_id'] = $vv['cate_id']; if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = wap_url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["bcate_type"][$kk]["url"] = $url; } } /*输出商圈*/ $quan_list = getQuanList($city_id); foreach ($quan_list as $k => $v) { $tmp_url_param = $url_param; unset($tmp_url_param['quan_id']); $tmp_url_param['quan_id'] = $v['id']; $tmp_url_param['quanname'] = $v['name']; if ($catalog_id > 0) { $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $catalog_id); $tmp_url_param['catename'] = $catename; } else { $tmp_url_param['catename'] = "全部分类"; } $turl = wap_url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $quan_list[$k]["url"] = $url; foreach ($v['quan_sub'] as $kk => $vv) { $tmp_url_param = $url_param; unset($tmp_url_param['quan_id']); $tmp_url_param['quan_id'] = $vv['id']; $tmp_url_param['quanname'] = $vv['name']; if ($catalog_id > 0) { $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $catalog_id); $tmp_url_param['catename'] = $catename; } else { $tmp_url_param['catename'] = "全部分类"; } $turl = wap_url("index", "tuanlist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $quan_list[$k]["quan_sub"][$kk]["url"] = $url; } } $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition = " (match(tag_match,name_match,locate_match,deal_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%') and "; } //buy_type 0普通团购;2在线订购;3秒杀抢团 //is_shop 0团购;1:商品; $condition .= " buy_type = 0 and is_shop = 0 and is_lottery = 0 "; if ($xpoint > 0) { $pi = 3.14159265; //圆周率 $r = 6378137; //地球平均半径(米) $field_append = ", (ACOS(SIN(({$ypoint} * {$pi}) / 180 ) *SIN((ypoint * {$pi}) / 180 ) +COS(({$ypoint} * {$pi}) / 180 ) * COS((ypoint * {$pi}) / 180 ) *COS(({$xpoint} * {$pi}) / 180 - (xpoint * {$pi}) / 180 ) ) * {$r}) as distance "; if ($ybottom != 0 && $ytop != 0 && $xleft != 0 && $xright != 0) { if ($condition != "") { $condition .= " and "; } $condition .= " ypoint > {$ybottom} and ypoint < {$ytop} and xpoint > {$xleft} and xpoint < {$xright} "; } $order = " distance asc,id desc "; } else { $order = "sort desc,id desc "; } /*排序 智能排序和 离我最的 是一样的 都以距离来升序来排序,只有这两种情况有传经纬度过来,就没有把 这两种情况写在 下面的判断里,写在上面了。 default 智能(默认),nearby 离我,avg_point 评价,newest 最新,buy_count 人气,price_asc 价低,price_desc 价高 */ $ordertype[] = array("name" => "默认排序", "sc" => "avg_point"); $ordertype[] = array("name" => "最新发布", "sc" => "newest"); $ordertype[] = array("name" => "销量最高", "sc" => "buy_count"); $ordertype[] = array("name" => "价格最高", "sc" => "price_desc"); $ordertype[] = array("name" => "价格最低", "sc" => "price_asc"); foreach ($ordertype as $k => $v) { $tmp_url_param = $url_param; if ($quanname) { $tmp_url_param['quanname'] = $quanname; } if ($catename) { $tmp_url_param['catename'] = $catename; } if ($keyword) { $tmp_url_param['keyword'] = $keyword; } $tmp_url_param['order_type'] = $v['sc']; $turl = wap_url("index", "goodslist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $ordertype[$k]["url"] = $url; } $root['ordertype'] = $ordertype; if ($order_type == 'avg_point') { /*评价*/ $order = " avg_point desc,id desc "; } elseif ($order_type == 'newest') { /*最新*/ $order = " create_time desc,id desc "; } elseif ($order_type == 'buy_count') { /*销量*/ $order = " buy_count desc,id desc "; } elseif ($order_type == 'price_asc') { /*价格升*/ $order = " current_price asc,id desc "; } elseif ($order_type == 'price_desc') { /*价格降*/ $order = " current_price desc,id desc "; } //根据传入的商圈ID来搜索该商圈下的商品 if ($quan_id > 0) { $sql_q = "select name from " . DB_PREFIX . "area where id = " . intval($quan_id); $q_name = $GLOBALS['db']->getOne($sql_q); $q_name_unicode = str_to_unicode_string($q_name); $condition .= " and (match(locate_match) against('" . $q_name_unicode . "' IN BOOLEAN MODE))"; } $deals = m_get_deal_list($limit, $catalog_id, $city_id, array(DEAL_ONLINE), $condition, $order, 0, $field_append, $cata_type_id); $list = $deals['list']; $count = $deals['count']; $page_total = ceil($count / $page_size); //$root['sql'] = $deals['sql']; $taday_begin = to_timespan(to_date(get_gmtime(), 'Y-m-d')); $taday_end = $taday_begin * 24 * 60 * 60; $goodses = array(); foreach ($list as $k => $v) { $goodses[$k]['id'] = $v['id']; $goodses[$k]['distance'] = $v['distance']; $goodses[$k]['ypoint'] = $v['ypoint']; $goodses[$k]['xpoint'] = $v['xpoint']; $goodses[$k]['name'] = $v['name']; $goodses[$k]['sub_name'] = $v['sub_name']; $goodses[$k]['goods_brief'] = $v['brief']; $goodses[$k]['buy_count'] = $v['buy_count']; $goodses[$k]['auto_order'] = $v['auto_order']; $goodses[$k]['current_price'] = round($v['current_price'], 2); $goodses[$k]['origin_price'] = round($v['origin_price'], 2); $goodses[$k]['icon'] = get_abs_img_root(get_spec_image($v['icon'], 140, 85, 0)); if ($v['begin_time'] > 0 && ($taday_begin < $v['begin_time'] && $v['begin_time'] < $taday_end)) { $goodses[$k]['is_taday'] = 1; } else { if ($v['begin_time'] == 0 && ($taday_begin < $v['create_time'] && $v['create_time'] < $taday_end)) { $goodses[$k]['is_taday'] = 1; } else { $goodses[$k]['is_taday'] = 0; } } } $root['city_id'] = $city_id; $root['quan_id'] = $quan_id; $root['catalog_id'] = $catalog_id; $root['page_title'] = "团购列表"; $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size); if ($goodses === false) { $root['item'] = array(); } else { $root['item'] = $goodses; } if ($bcate_list === false) { $root[''] = array(); } else { $root['bcate_list'] = $bcate_list; } if ($quan_list === false) { $root['quan_list'] = array(); } else { $root['quan_list'] = $quan_list; } output($root); }
public function index() { require_once APP_ROOT_PATH . 'system/model/deal.php'; $root = array(); $root['return'] = 1; $catalog_id = intval($GLOBALS['request']['catalog_id']); //商品分类ID $cata_type_id = intval($GLOBALS['request']['cata_type_id']); //商品二级分类 $city_id = intval($GLOBALS['request']['city_id']); //城市分类ID $page = intval($GLOBALS['request']['page']); //分页 $keyword = strim($GLOBALS['request']['keyword']); $city_name = strim($GLOBALS['request']['city_name']); //城市名称 //print_r($GLOBALS['request']); $order_type = strim($GLOBALS['request']['order_type']); $quan_id = intval($GLOBALS['request']['quan_id']); //商圈id if ($cata_type_id > 0) { $catalog_id = $cata_type_id; } if ($order_type == 'buy_count') { $marked_tag = 1; } elseif ($order_type == 'price_desc') { $marked_tag = 2; } elseif ($order_type == 'newest') { $marked_tag = 3; } else { $marked_tag = 1; } $root['marked_tag'] = $marked_tag; /*输出分类*/ $bcate_list = getShopcateList(); $url_param['quan_id'] = $quan_id; $url_param['catalog_id'] = $catalog_id; foreach ($bcate_list as $k => $v) { if ($catalog_id == $v['id']) { $bcate_list[$k]['marked_tag'] = 1; } /* if($catalog_id==$v['id']) { $bcate_list['bcate_type'][$k]['act'] = 1; } */ $tmp_url_param = $url_param; unset($tmp_url_param['catalog_id']); $tmp_url_param['catalog_id'] = $v['id']; $tmp_url_param['catename'] = $v['name']; if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = wap_url("index", "goodslist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["url"] = $url; foreach ($v['bcate_type'] as $kk => $vv) { /* if($catalog_id==$vv['id']) { $bcate_list['bcate_type'][$kk]['act'] = 1; } */ $tmp_url_param = $url_param; unset($tmp_url_param['catalog_id']); $tmp_url_param['catalog_id'] = $vv['id']; if ($bcate_list['bcate_type'][$kk]['id'] == $vv['id']) { $tmp_url_param['catename'] = $v['name']; } else { $tmp_url_param['catename'] = $vv['name']; } if ($quan_id > 0) { $quanname = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "area a where id=" . $quan_id); $tmp_url_param['quanname'] = $quanname; } else { $tmp_url_param['quanname'] = "全城"; } $turl = wap_url("index", "goodslist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $bcate_list[$k]["bcate_type"][$kk]["url"] = $url; } } //品牌列表 if ($catalog_id > 0) { $cate_key = load_auto_cache("shop_cate_key", array("cid" => $catalog_id)); $brand_list = $GLOBALS['db']->getAll("select id,name,sort,0 as city_id, from " . DB_PREFIX . "brand where match(tag_match) against('" . $cate_key . "' IN BOOLEAN MODE) order by sort limit 100"); } else { $brand_list = $GLOBALS['db']->getAll("select id,name,sort,0 as city_id from " . DB_PREFIX . "brand order by sort limit 100"); } $quan_list = array(); $quan_list[0]['id'] = 0; $quan_list[0]['name'] = '全部品牌'; /* $quan_list[0]['quan_sub'][0]['id']=0; $quan_list[0]['quan_sub'][0]['pid']=0; $quan_list[0]['quan_sub'][0]['name']='全部'; */ foreach ($brand_list as $k => $v) { $quan_list[] = $v; } foreach ($quan_list as $k => $v) { $tmp_url_param = $url_param; unset($tmp_url_param['quan_id']); $tmp_url_param['quan_id'] = $v['id']; $tmp_url_param['quanname'] = $v['name']; if ($catalog_id > 0) { $catename = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "shop_cate where id=" . $catalog_id); $tmp_url_param['catename'] = $catename; } else { $tmp_url_param['catename'] = "全部分类"; } $turl = wap_url("index", "goodslist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $quan_list[$k]["url"] = $url; $quan_list[$k]['quan_sub'][] = array('id' => $v['id'], 'pid' => $v['id'], 'name' => '全部'); } $ordertype[] = array("name" => "默认排序", "sc" => "avg_point"); $ordertype[] = array("name" => "最新发布", "sc" => "newest"); $ordertype[] = array("name" => "销量最高", "sc" => "buy_count"); $ordertype[] = array("name" => "价格最高", "sc" => "price_desc"); $ordertype[] = array("name" => "价格最低", "sc" => "price_asc"); foreach ($ordertype as $k => $v) { $tmp_url_param = $url_param; if ($quanname) { $tmp_url_param['quanname'] = $quanname; } if ($catename) { $tmp_url_param['catename'] = $catename; } if ($keyword) { $tmp_url_param['keyword'] = $keyword; } $tmp_url_param['order_type'] = $v['sc']; $turl = wap_url("index", "goodslist", $tmp_url_param); $url = str_replace('sjmapi', 'wap', $turl); $ordertype[$k]["url"] = $url; } $root['ordertype'] = $ordertype; /*排序*/ if ($order_type == 'avg_point') { $order = " avg_point desc,id desc "; } elseif ($order_type == 'newest') { $order = " create_time desc,id desc "; } elseif ($order_type == 'buy_count') { $order = " buy_count desc,id desc "; } elseif ($order_type == 'price_asc') { $order = " current_price asc,id desc "; } elseif ($order_type == 'price_desc') { $order = " current_price desc,id desc "; } else { $order = "sort desc,id desc "; } $page = $page == 0 ? 1 : $page; $page_size = PAGE_SIZE; $limit = ($page - 1) * $page_size . "," . $page_size; //buy_type = 0 普通商品;1积分商品 $condition = " buy_type = 0 and is_shop=1"; if ($keyword) { $kws_div = div_str($keyword); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(tag_match,name_match,locate_match,shop_cate_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $keyword . "%')"; } $merchant_id = intval($GLOBALS['request']['merchant_id']); if ($merchant_id > 0) { $deal_ids = $GLOBALS['db']->getOne("select group_concat(deal_id) from " . DB_PREFIX . "deal_location_link where location_id = " . $merchant_id); if ($deal_ids) { $condition .= " and id in (" . $deal_ids . ") "; } else { $condition .= " and id ='' "; } } //根据传入的商圈ID来搜索该商圈下的商品 if ($quan_id > 0) { $condition .= " and brand_id = " . $quan_id; } //get_goods_list($limit,$type=array(DEAL_ONLINE,DEAL_HISTORY,DEAL_NOTICE),$param=array("cid"=>0,"city_id"=>0), $join='', $where='',$orderby = '') $deals = get_goods_list($limit, array(DEAL_ONLINE, DEAL_HISTORY), array("cid" => $catalog_id, "city_id" => $city_id), '', $condition, $order); $condition = $deals['condition']; $sql = "select count(*) from " . DB_PREFIX . "deal as d where " . $condition; $count = $GLOBALS['db']->getOne($sql); $list = $deals['list']; $page_total = ceil($count / $page_size); $goodses = array(); foreach ($list as $item) { //$goods = array(); $goods = getGoodsArray($item); $goods['image'] = get_abs_img_root(get_spec_image($item['img'], 140, 85, 0)); $goodses[] = $goods; } $root['item'] = $goodses; $root['page'] = array("page" => $page, "page_total" => $page_total, "page_size" => $page_size); //$root['quan_list'] = getCityList(); /* //输出城市 $root['city_list']=getCityList(); //输出商圈 $quan_list=getQuanList($city_id); $root['quan_list2'] = $quan_list; */ //$root['bcate_list'] = $bcate_list; //$root['quan_list'] = $quan_list; if ($bcate_list === false) { $root['bcate_list'] = array(); } else { $root['bcate_list'] = $bcate_list; } if ($quan_list === false) { $root['quan_list'] = array(); } else { $root['quan_list'] = $quan_list; } $root['page_title'] = "商品列表"; $root['city_name'] = $city_name; output($root); }
public function index() { $root = array(); $page = intval($GLOBALS['request']['page']); // 分页 $page = $page == 0 ? 1 : $page; $root['response_code'] = 1; $param = array(); // 参数集合 // 数据来源参数 $r = strim($_REQUEST['r']); // 推荐类型 $param['r'] = $r ? $r : ''; $id = intval($_REQUEST['id']); // 分类id3 $param['id'] = $id; // ios标志 if ($id == 0) { $isAll = 1; } else { $isAll = 0; } $loc = strim($_REQUEST['loc']); // 地区 $param['loc'] = $loc; $GLOBALS['tmpl']->assign("p_loc", $loc); $state = intval($_REQUEST['state']); // 状态1 $param['state'] = $state; $tag = strim($_REQUEST['tag']); // 标签 $param['tag'] = $tag; $GLOBALS['tmpl']->assign("p_tag", $tag); $kw = strim($_REQUEST['key']); // 关键词 $param['kw'] = $kw; $cate_list = load_dynamic_cache("INDEX_CATE_LIST"); if (!$cate_list) { $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc"); set_dynamic_cache("INDEX_CATE_LIST", $cate_list); } $cate_result = array(); $cate_result[0]['id'] = '0'; $cate_result[0]['name'] = "全部"; foreach ($cate_list as $k => $v) { $temp_param = $param; $cate_result[$k + 1]['id'] = $v['id']; $cate_result[$k + 1]['name'] = $v['name']; $temp_param['id'] = $v['id']; } $root['cate_list'] = $cate_result; $pid = 0; // 获取父类id if ($cate_list) { foreach ($cate_list as $k => $v) { if ($v['id'] == $id) { if ($v['pid'] > 0) { $pid = $v['pid']; } else { $pid = $id; } } } } /* 子分类 start */ $cate_ids = array(); $is_has_child = false; $temp_cate_ids = array(); if ($cate_list) { $child_cate_result = array(); foreach ($cate_list as $k => $v) { if ($v['pid'] == $pid) { if ($v['pid'] > 0) { $temp_param = $param; $child_cate_result[$v['id']]['id'] = $v['id']; $child_cate_result[$v['id']]['name'] = $v['name']; $temp_param['id'] = $v['id']; $child_cate_result[$v['id']]['url'] = url_mapi("deals", $temp_param); if ($v['id'] == $id) { $is_has_child = true; } } } if ($v['pid'] == $pid || $pid == 0) { $temp_cate_ids[] = $v['id']; } } } // 假如选择了子类 那么使用子类ID 否则使用 父类和其子类 if ($is_has_child) { $cate_ids[] = $id; } else { $cate_ids[] = $pid; $cate_ids = array_merge($cate_ids, $temp_cate_ids); } $root['child_cate_list'] = $child_cate_result; $root['pid'] = $pid; /* 子分类 end */ $city_list = load_dynamic_cache("INDEX_CITY_LIST"); if (!$city_list) { $city_list = $GLOBALS['db']->getAll("select province from " . DB_PREFIX . "deal group by province order by sort asc"); set_dynamic_cache("INDEX_CITY_LIST", $city_list); } foreach ($city_list as $k => $v) { $temp_param = $param; $temp_param['loc'] = $v['province']; $city_list[$k]['url'] = url_mapi("deals", $temp_param); } $root['city_list'] = $city_list; $state_list = array(0 => array("name" => "全部"), 1 => array("name" => "筹资成功"), 2 => array("name" => "筹资失败"), 3 => array("name" => "筹资中")); foreach ($state_list as $k => $v) { $temp_param = $param; $temp_param['state'] = $k; $state_list[$k]['url'] = url_mapi("deals", $temp_param); } $root['state_list'] = $state_list; $page_size = $GLOBALS['m_config']['page_size']; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $condition = " is_delete = 0 and is_effect = 1 "; if ($r != "") { if ($r == "new") { $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time > 0 "; // 上线不超过一天 $GLOBALS['tmpl']->assign("page_title", "最新上线"); } if ($r == "rec") { $condition .= " and " . NOW_TIME . " <= end_time AND " . NOW_TIME . " >= begin_time and is_recommend = 1 "; $GLOBALS['tmpl']->assign("page_title", "推荐项目"); } if ($r == "yure") { $condition .= " and " . NOW_TIME . " - begin_time < " . 24 * 3600 . " and " . NOW_TIME . " - begin_time < 0 "; // 上线不超过一天 $GLOBALS['tmpl']->assign("page_title", "正在预热"); } if ($r == "nend") { $condition .= " and end_time - " . NOW_TIME . " < " . 24 * 3600 . " and end_time - " . NOW_TIME . " > 0 "; // 当天就要结束 $GLOBALS['tmpl']->assign("page_title", "即将结束"); } if ($r == "classic") { $condition .= " and is_classic = 1 "; $GLOBALS['tmpl']->assign("page_title", "经典项目"); } if ($r == "limit_price") { $condition .= " and max(limit_price) "; $GLOBALS['tmpl']->assign("page_title", "最高目标金额"); } } switch ($state) { // 筹资中 case 0: $GLOBALS['tmpl']->assign("page_title", "全部"); break; // 筹资成功 // 筹资成功 case 1: $condition .= " and end_time < " . NOW_TIME . " and support_amount >= limit_price"; $GLOBALS['tmpl']->assign("page_title", "筹资成功"); break; // 筹资失败 // 筹资失败 case 2: $condition .= " and end_time < " . NOW_TIME . " and support_amount < limit_price "; $GLOBALS['tmpl']->assign("page_title", "筹资失败"); break; // 筹资中 // 筹资中 case 3: $condition .= " and end_time > " . NOW_TIME . " and begin_time < " . NOW_TIME . " "; $GLOBALS['tmpl']->assign("page_title", "筹资中"); break; } if (count($cate_ids) > 0) { $condition .= " and cate_id in (" . implode(",", $cate_ids) . ")"; $GLOBALS['tmpl']->assign("page_title", $cate_result[$id]['name']); } if ($loc != "") { $condition .= " and (province = '" . $loc . "' or city = '" . $loc . "') "; $GLOBALS['tmpl']->assign("page_title", $loc); } if ($tag != "") { $unicode_tag = str_to_unicode_string($tag); $condition .= " and match(tags_match) against('" . $unicode_tag . "' IN BOOLEAN MODE) "; $GLOBALS['tmpl']->assign("page_title", $tag); } if ($kw != "") { $kws_div = div_str($kw); foreach ($kws_div as $k => $item) { $kws[$k] = str_to_unicode_string($item); } $ukeyword = implode(" ", $kws); $condition .= " and (match(name_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or match(tags_match) against('" . $ukeyword . "' IN BOOLEAN MODE) or name like '%" . $kw . "%') "; $GLOBALS['tmpl']->assign("page_title", $kw); } // 权限浏览控制 if ($GLOBALS['user_info']['user_level'] != 0) { $condition .= " AND (user_level ='' or user_level=0 or user_level <=" . $GLOBALS['user_info']['user_level'] . ") "; } else { $condition .= " AND (user_level =0 or user_level =1 or user_level ='') "; } $deal_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where " . $condition); /* (所需项目)准备虚拟数据 start */ $deal_list = array(); if ($deal_count > 0) { $now_time = get_gmtime(); // $deal_list = $GLOBALS['db']->getAll("select * from // ".DB_PREFIX."deal where ".$condition." order by sort asc "); $deal_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where " . $condition . " order by sort asc limit " . $limit); $deal_ids = array(); foreach ($deal_list as $k => $v) { // $deal_list['percent'] = // round($deal_list['support_amount']/$deal_list['limit_price']*100); } // 获取当前项目列表下的所有子项目 $temp_virtual_person_list = $GLOBALS['db']->getAll("select deal_id,virtual_person,price from " . DB_PREFIX . "deal_item where deal_id in(" . implode(",", $deal_ids) . ") "); $virtual_person_list = array(); // 重新组装一个以项目ID为KEY的 统计所有的虚拟人数和虚拟价格 foreach ($temp_virtual_person_list as $k => $v) { $virtual_person_list[$v['deal_id']]['total_virtual_person'] += $v['virtual_person']; $virtual_person_list[$v['deal_id']]['total_virtual_price'] += $v['price'] * $v['virtual_person']; } unset($temp_virtual_person_list); // 将获取到的虚拟人数和虚拟价格拿到项目列表里面进行统计 foreach ($deal_list as $k => $v) { $deal_list[$k]['virtual_person'] = $virtual_person_list[$v['id']]['total_virtual_person']; $deal_list[$k]['percent'] = round(($v['support_amount'] + $virtual_person_list[$v['id']]['total_virtual_price']) / $v['limit_price'] * 100); $deal_list[$k]['support_count'] += $deal_list[$k]['virtual_person']; $deal_list[$k]['support_amount'] += $virtual_person_list[$v['id']]['total_virtual_price']; /* * * $deal_list[$k]['description']=get_abs_img_root(get_spec_image($v['description'],640,240,1)); * $deal_list[$k]['content']=get_abs_img_root(get_spec_image($v['description'],640,240,1)); * $deal_list[$k]['content_1']=get_abs_img_root(get_spec_image($v['description_1'],640,240,1)); * $deal_list[$k]['deal_extra_cache']=null; */ $deal_list[$k]['image'] = get_abs_img_root(get_spec_image($v['image'], 640, 240, 1)); if ($v['end_time'] > 0 && $v['end_time'] > $now_time) { $deal_list[$k]['remain_days'] = floor(($v['end_time'] - $now_time) / (24 * 3600)); } elseif ($v['end_time'] > 0 && $v['end_time'] <= $now_time) { $deal_list[$k]['remain_days'] = 0; } if ($v['begin_time'] > $now_time) { $deal_list[$k]['left_days'] = intval(($now_time - $v['create_time']) / 24 / 3600); } else { $deal_list[$k]['left_days'] = 0; } $deal_list[$k]['num_days'] = floor(($v['end_time'] - $v['begin_time']) / (24 * 3600)); // $deal_list[$k]['status']值0表示即将开始;1表示已成功;2表示筹资失败;3表示筹资中;4表示长期项目 if ($v['begin_time'] > $now_time) { $deal_list[$k]['status'] = '0'; } elseif ($v['end_time'] < $now_time && $v['end_time'] > 0) { if ($deal_list[$k]['percent'] >= 100) { $deal_list[$k]['status'] = '1'; } else { if ($deal_list[$k]['percent'] >= 0) { $deal_list[$k]['status'] = '2'; } } } else { if ($v['end_time'] > 0) { if ($deal_list[$k]['percent'] >= 100) { $deal_list[$k]['status'] = '1'; } else { $deal_list[$k]['status'] = '3'; } } else { $deal_list[$k]['status'] = '4'; } } $deal_list[$k]['end_time'] = to_date($v['end_time'], 'Y-m-d'); $deal_list[$k]['begin_time'] = to_date($v['begin_time'], 'Y-m-d'); $deal_list[$k]['create_time'] = to_date($v['create_time'], 'Y-m-d'); $deal_ids[] = $v['id']; // 查询出对应项目id的user_level $deal_list[$k]['deal_level'] = $GLOBALS['db']->getOne("select level from " . DB_PREFIX . "deal_level where id=" . intval($deal_list[$k]['user_level'])); } } /* (所需项目)准备虚拟数据 end */ $root['isAll'] = $isAll; $root['deal_list'] = $deal_list; $root['deal_count'] = $deal_count; $root['page'] = array("page" => $page, "page_total" => ceil($deal_count / $page_size), "page_size" => intval($page_size), 'total' => intval($deal_count)); output($root); }
public function atme() { $ajax = intval($_REQUEST['ajax']); if ($ajax == 0) { $this->init_main(); $is_merchant = intval($GLOBALS['user_info']['is_merchant']); $GLOBALS['tmpl']->assign('is_merchant', $is_merchant); } $user_id = intval($GLOBALS['user_info']['id']); //输出发言列表 $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * app_conf("PAGE_SIZE") . "," . app_conf("PAGE_SIZE"); $user_name = $GLOBALS['user_info']['user_name']; $user_name_unicode = str_to_unicode_string($user_name); $condition = " match(user_name_match) against('" . $user_name_unicode . "' IN BOOLEAN MODE) "; $result = get_topic_list($limit, $condition); $result['list'] = div_to_col($result['list']); $GLOBALS['tmpl']->assign("topic_list", $result['list']); $page = new Page($result['total'], app_conf("PAGE_SIZE")); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); if ($ajax == 0) { $list_html = decode_topic_without_img($GLOBALS['tmpl']->fetch("inc/topic_col_list.html")); $GLOBALS['tmpl']->assign("list_html", $list_html); $GLOBALS['tmpl']->assign("page_title", $GLOBALS['lang']['UC_CENTER_ATME']); $GLOBALS['tmpl']->assign("post_title", $GLOBALS['lang']['UC_CENTER_ATME']); $GLOBALS['tmpl']->assign("inc_file", "inc/uc/uc_center_index.html"); $GLOBALS['tmpl']->display("uc.html"); } else { header("Content-Type:text/html; charset=utf-8"); echo decode_topic_without_img($GLOBALS['tmpl']->fetch("inc/topic_col_list.html")); } }