public function index() { $GLOBALS['tmpl']->caching = true; $GLOBALS['tmpl']->cache_lifetime = 600; //优惠首页缓存10分钟 $cache_id = md5(MODULE_NAME . ACTION_NAME . $GLOBALS['deal_city']['id']); if (!$GLOBALS['tmpl']->is_cached('youhui_index.html', $cache_id)) { make_deal_cate_js(); make_deal_region_js(); $result = load_auto_cache("fyouhui_filter_nav_cache", array('city_id' => $GLOBALS['deal_city']['id'])); $GLOBALS['tmpl']->assign("cate_list", $result['cate_list']); $GLOBALS['tmpl']->assign("area_list", $result['area_list']); //输出右侧的优惠列表 $youhui_list = get_free_youhui_list(5, 0, "", " view_count desc "); $youhui_list = $youhui_list['list']; $GLOBALS['tmpl']->assign("youhui_list", $youhui_list); $right_youhui_html = $GLOBALS['tmpl']->fetch("index/index_right_youhui.html"); $GLOBALS['tmpl']->assign("right_youhui_html", $right_youhui_html); //输出右侧商家 $city_ids = load_auto_cache("deal_city_belone_ids", array("city_id" => intval($GLOBALS['deal_city']['id']))); if ($city_ids) { $store_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "supplier_location use index(avg_point) WHERE city_id in(" . implode(",", $city_ids) . ") and is_effect = 1 order by avg_point desc limit 5"); } else { $store_list = $GLOBALS['db']->getAll("SELECT * FROM " . DB_PREFIX . "supplier_location use index(avg_point) WHERE is_effect = 1 order by avg_point desc limit 5"); } $GLOBALS['tmpl']->assign("store_list", $store_list); $right_store_html = $GLOBALS['tmpl']->fetch("index/index_right_store.html"); $GLOBALS['tmpl']->assign("right_store_html", $right_store_html); //输出左侧推荐分类 $recommend_cate = $GLOBALS['db']->getAll("select id,name from " . DB_PREFIX . "deal_cate where rec_youhui = 1 order by sort desc"); $recommend_cate_html = ""; foreach ($recommend_cate as $cate) { $youhui_list = get_free_youhui_list(8, $cate['id'], "", ""); $youhui_list = $youhui_list['list']; $GLOBALS['tmpl']->assign("youhui_list", $youhui_list); $scate_list = $GLOBALS['db']->getAll("select t.* from " . DB_PREFIX . "deal_cate_type as t left join " . DB_PREFIX . "deal_cate_type_link as l on l.deal_cate_type_id = t.id where t.is_recommend = 1 and l.cate_id = " . $cate['id'] . " order by sort desc"); $GLOBALS['tmpl']->assign("scate_list", $scate_list); $GLOBALS['tmpl']->assign("bcate_item", $cate); $recommend_cate_html .= $GLOBALS['tmpl']->fetch("inc/recommend_cate_youhui.html"); } $GLOBALS['tmpl']->assign("recommend_cate_html", $recommend_cate_html); //输出下载的动态 $down_load_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_msg_list where is_youhui = 1 and youhui_id <> 0 order by create_time desc limit 50"); foreach ($down_load_list as $k => $v) { $down_load_list[$k]['youhui_name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "youhui where id = " . intval($v['youhui_id'])); } $GLOBALS['tmpl']->assign("down_load_list", $down_load_list); } $GLOBALS['tmpl']->display("youhui_index.html", $cache_id); }
public function load($param) { $key = $this->build_key(__CLASS__, $param); $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/"); $free_youhui_list = $GLOBALS['fcache']->get($key); if ($free_youhui_list === false) { $free_youhui_list = get_free_youhui_list(app_conf("SIDE_DEAL_COUNT"), $cate_id = 0, $where = '', $orderby = 'sms_count desc'); $free_youhui_list = $free_youhui_list['list']; foreach ($free_youhui_list as $k => $v) { $free_youhui_list[$k]['url'] = url("youhui", "fdetail", array("id" => $v['id'])); $supplier_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . intval($v['supplier_id'])); $locations = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . intval($supplier_info['id'])); if (count($locations) != 1) { $supplier_info['url'] = url("youhui", "store", array("id" => $supplier_info['id'])); } else { $supplier_info['url'] = url("youhui", "store#view", array("id" => $locations[0]['id'])); } $free_youhui_list[$k]['supplier_info'] = $supplier_info; } $GLOBALS['fcache']->set_dir(APP_ROOT_PATH . "public/runtime/data/" . __CLASS__ . "/"); $GLOBALS['fcache']->set($key, $free_youhui_list); } return $free_youhui_list; }
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"); } }
public function index() { if (check_ipop_limit(get_client_ip(), "view_youhui", intval(app_conf("SUBMIT_DELAY")), trim($_REQUEST['id']))) { $GLOBALS['db']->query("update " . DB_PREFIX . "youhui set view_count = view_count + 1 where id = " . intval($_REQUEST['id'])); } $preview = intval($_REQUEST['preview']); $GLOBALS['tmpl']->caching = false; $cache_id = md5(MODULE_NAME . ACTION_NAME . trim($_REQUEST['id']) . $GLOBALS['deal_city']['id'] . $preview); if (!$GLOBALS['tmpl']->is_cached('youhui_fdetail.html', $cache_id)) { $youhui_id = intval($_REQUEST['id']); if ($preview > 0) { $youhui_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where id =" . $youhui_id); $adm_session = es_session::get(md5(app_conf("AUTH_KEY"))); $adm_name = $adm_session['adm_name']; $adm_id = intval($adm_session['adm_id']); if ($adm_id == 0) { //验证是否当前的商家(不是后台管理员) $s_account_info = es_session::get("account_info"); if ($s_account_info) { foreach ($s_account_info['location_ids'] as $id) { $location = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where id = " . $id); if ($location) { $locations[] = $location; } } $deal_test = $GLOBALS['db']->getRow("select y.* from " . DB_PREFIX . "youhui as y left join " . DB_PREFIX . "youhui_location_link as l on l.youhui_id = y.id where y.id = " . intval($youhui_info['id']) . " and y.publish_wait = 1 and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")"); if (!$deal_test) { showErr("优惠不存在或者没有预览该优惠的权限", 0, APP_ROOT . "/admin.php?m=Public&a=login"); } } else { showErr("您不是系统管理员或者商家会员,无法预览", 0, APP_ROOT . "/"); } } } else { $youhui_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where is_effect = 1 and id =" . $youhui_id); } if (!$youhui_info) { showErr("非法的优惠券ID"); } $youhui_info['supplier_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . intval($youhui_info['supplier_id']) . ""); //print_r($youhui_info);die(); $GLOBALS['tmpl']->assign("youhui_info", $youhui_info); //供应商的地址列表 //定义location_id //$locations = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."supplier_location where supplier_id = ".intval($youhui_info['supplier_id'])." order by is_main desc"); $locations = $GLOBALS['db']->getAll("select a.* from " . DB_PREFIX . "supplier_location as a left join " . DB_PREFIX . "youhui_location_link as b on a.id = b.location_id where a.is_effect = 1 and b.youhui_id = " . intval($youhui_info['id'])); $json_location = array(); $location_ids = array(0); foreach ($locations as $litem) { $location_ids[] = $litem['id']; $arr = array(); $arr['title'] = $litem['name']; $arr['address'] = $litem['address']; $arr['tel'] = $litem['tel']; $arr['lng'] = $litem['xpoint']; $arr['lat'] = $litem['ypoint']; $json_location[] = $arr; } $GLOBALS['tmpl']->assign("json_location", json_encode($json_location)); $GLOBALS['tmpl']->assign("locations", $locations); //周边热卖 $areas = $GLOBALS['db']->getAll("select a.name from " . DB_PREFIX . "area as a left join " . DB_PREFIX . "supplier_location_area_link as l on l.area_id = a.id where l.location_id in (" . implode(",", $location_ids) . ")"); $condition_arr = array(); foreach ($areas as $area) { $condition_arr[] = str_to_unicode_string($area['name']); } $condition = " (match(locate_match) against('" . implode(" ", $condition_arr) . "' IN BOOLEAN MODE)) and id <> " . intval($youhui_info['id']); $near_youhui = get_free_youhui_list(4, 0, $condition, ""); $GLOBALS['tmpl']->assign("near_youhui_list", $near_youhui['list']); $rec_youhui = get_free_youhui_list(4, $youhui_info['deal_cate_id'], "is_recommend = 1", ""); $GLOBALS['tmpl']->assign("rec_youhui_list", $rec_youhui['list']); $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $youhui_info['deal_cate_id']); $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index")); $site_nav[] = array('name' => $cate_item['name'], 'url' => url("youhui", "fcate#index", array("cid" => $cate_item['id']))); $site_nav[] = array('name' => $youhui_info['name'], 'url' => url("youhui", "fdetail", array("id" => $youhui_info['id']))); $GLOBALS['tmpl']->assign("site_nav", $site_nav); $seo_title = $youhui_info['name']; $GLOBALS['tmpl']->assign("page_title", $seo_title); $seo_keyword = $youhui_info['name']; $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ","); $seo_description = $youhui_info['name']; $GLOBALS['tmpl']->assign("page_description", $seo_description . ","); } $GLOBALS['tmpl']->display("youhui_fdetail.html", $cache_id); }
public function index_right_youhui() { $youhui_list = get_free_youhui_list(5, 0, "", " view_count desc "); $youhui_list = $youhui_list['list']; $GLOBALS['tmpl']->assign("youhui_list", $youhui_list); return $GLOBALS['tmpl']->fetch("index/index_right_youhui.html"); }