예제 #1
0
 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']), "min_price" => doubleval($_REQUEST['min_price']), "max_price" => doubleval($_REQUEST['max_price']), "keyword" => $keyword);
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "ycate", $url_param));
     }
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['NEED_BUY_YOUHUI'], 'url' => url("youhui", "ycate#index"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     //输出当前的site_nav
     //输出热卖
     $res = search_youhui_list(app_conf("SIDE_DEAL_COUNT"), 0, "", "d.buy_count desc", true, "");
     $GLOBALS['tmpl']->assign("hot_sale_list", $res['list']);
     $seo_title = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     $seo_keyword = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     $seo_description = $GLOBALS['lang']['NEED_BUY_YOUHUI'];
     //
     $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");
     $id = intval($_REQUEST['cid']);
     if ($id == 0) {
         $uname = addslashes(trim($_REQUEST['id']));
     }
     $cate_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $id . " or (uname = '" . $uname . "' and uname <> '')");
     $condition = " d.is_shop = 2 ";
     //条件
     $tp_url_param = $url_param;
     unset($tp_url_param['min_price']);
     unset($tp_url_param['max_price']);
     unset($tp_url_param['keyword']);
     $sub_nav[] = array("name" => $GLOBALS['lang']['FREE_YOUHUI'], "url" => url("youhui", "fcate", $tp_url_param), "current" => 0);
     $sub_nav[] = array("name" => $GLOBALS['lang']['NEED_BUY_YOUHUI'], "url" => url("youhui", "ycate", $tp_url_param), "current" => 1);
     $sub_nav[] = array("name" => $GLOBALS['lang']['TUAN'], "url" => url("youhui", "tuan", $tp_url_param), "current" => 0);
     $GLOBALS['tmpl']->assign("sub_nav", $sub_nav);
     $GLOBALS['tmpl']->assign("url_param", $tp_url_param);
     //将变量输出到模板
     $ids = load_auto_cache("deal_sub_cate_ids", array("cate_id" => intval($cate_item['id'])));
     $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("byouhui_filter_nav_cache", $cache_param);
     //输出大区
     $append_seo = "";
     $area_id = intval($_REQUEST['aid']);
     $quan_id = intval($_REQUEST['qid']);
     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(d.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(d.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_item['id'];
     $deal_quan_id = $area_id;
     if ($deal_cate_id > 0) {
         $GLOBALS['tmpl']->assign("scate_list", $result['scate_list']);
         if ($append_seo != "") {
             $append_seo .= " - ";
         }
         $append_seo .= $cate_item['name'];
     }
     //输出价格区间
     $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";
     if ($sort_field != "update_time" && $sort_field != "current_price" && $sort_field != "buy_count" && $sort_field != "avg_point" && $sort_field != "sort") {
         $sort_field = "sort";
     }
     if ($sort_type != "desc" && $sort_type != "asc") {
         $sort_type = "desc";
     }
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     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(d.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(d.name_match) against('" . $ukeyword . "'  IN BOOLEAN MODE) or d.name like '%" . $keyword . "%') ";
         $seo_title = $keyword . " - " . $seo_title;
     }
     $result = search_youhui_list($limit, intval($cate_item['id']), $condition, "d." . $sort_field . " " . $sort_type, false, "");
     $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']);
     //
     $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_ycate.html");
 }
예제 #2
0
 public function daijin_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('daijin_index.html', $cache_id)) {
         make_deal_cate_js();
         make_deal_region_js();
         $result = load_auto_cache("byouhui_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']);
         //输出右侧的优惠列表
         $result = search_youhui_list(5, 0, "", "", false, "", $GLOBALS['deal_city']['id']);
         $daijin_list = $result['list'];
         $GLOBALS['tmpl']->assign("daijin_list", $daijin_list);
         $right_daijin_html = $GLOBALS['tmpl']->fetch("index/index_right_daijin.html");
         $GLOBALS['tmpl']->assign("right_daijin_html", $right_daijin_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_daijin = 1 order by sort desc");
         $recommend_cate_html = "";
         foreach ($recommend_cate as $cate) {
             $daijin_list = search_youhui_list(8, $cate['id'], "", "", false, "", $GLOBALS['deal_city']['id']);
             $daijin_list = $daijin_list['list'];
             $GLOBALS['tmpl']->assign("daijin_list", $daijin_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_daijin.html");
         }
         $GLOBALS['tmpl']->assign("recommend_cate_html", $recommend_cate_html);
     }
     $GLOBALS['tmpl']->display("daijin_index.html", $cache_id);
 }
예제 #3
0
 public function index()
 {
     $preview = intval($_REQUEST['preview']);
     $GLOBALS['tmpl']->caching = true;
     $cache_id = md5(MODULE_NAME . ACTION_NAME . trim($_REQUEST['id']) . $GLOBALS['deal_city']['id'] . $preview);
     if (!$GLOBALS['tmpl']->is_cached('youhui_ydetail.html', $cache_id)) {
         //获取当前页的团购商品
         $id = intval($_REQUEST['id']);
         $uname = addslashes(trim($_REQUEST['id']));
         if ($id == 0 && $uname == '') {
             app_redirect(url("shop", "index"));
         } elseif ($id == 0 && $uname != '') {
             $id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "deal where uname = '" . $uname . "'");
         }
         if ($preview > 0) {
             $youhui = get_youhui($id, $preview);
             $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 d.* from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.id = " . intval($youhui['id']) . " and d.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 = get_youhui($id);
         }
         jump_deal($youhui, MODULE_NAME);
         if (!$youhui) {
             app_redirect(url("youhui", "index"));
         }
         $GLOBALS['tmpl']->assign("youhui", $youhui);
         //供应商的地址列表
         //定义location_id
         $locations = $GLOBALS['db']->getAll("select a.* from " . DB_PREFIX . "supplier_location as a left join " . DB_PREFIX . "deal_location_link as b on a.id = b.location_id where a.is_effect = 1 and b.deal_id = " . intval($youhui['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);
         //输出促销
         if ($youhui['allow_promote'] == 1) {
             $promote = load_auto_cache("cache_promote");
             $GLOBALS['tmpl']->assign("promote", $promote);
         }
         //开始输出当前的site_nav
         $cates = array();
         $cate = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where id = " . $youhui['cate_id']);
         do {
             $cates[] = $cate;
             $pid = intval($cate['pid']);
             $cate = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_cate where is_effect =1 and is_delete =0 and id = " . $pid);
         } while ($pid != 0);
         krsort($cates);
         $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
         if ($cates) {
             foreach ($cates as $cate_row) {
                 if ($cate_row['uname'] != "") {
                     $curl = url("youhui", "ycate#index", array("cid" => $cate_row['uname']));
                 } else {
                     $curl = url("youhui", "ycate#index", array("cid" => $cate_row['id']));
                 }
                 $site_nav[] = array('name' => $cate_row['name'], 'url' => $curl);
             }
         }
         if ($youhui['uname'] != "") {
             $gurl = url("youhui", "ydetail#index", array("id" => $youhui['uname']));
         } else {
             $gurl = url("youhui", "ydetail#index", array("id" => $youhui['id']));
         }
         $site_nav[] = array('name' => $youhui['name'], 'url' => $gurl);
         $GLOBALS['tmpl']->assign("site_nav", $site_nav);
         //输出当前的site_nav
         $seo_title = $youhui['seo_title'] != '' ? $youhui['seo_title'] : $youhui['name'];
         $GLOBALS['tmpl']->assign("page_title", $seo_title);
         $seo_keyword = $youhui['seo_keyword'] != '' ? $youhui['seo_keyword'] : $youhui['name'];
         $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
         $seo_description = $youhui['seo_description'] != '' ? $youhui['seo_description'] : $youhui['name'];
         $GLOBALS['tmpl']->assign("page_description", $seo_description . ",");
         //周边热卖
         $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(d.locate_match) against('" . implode(" ", $condition_arr) . "' IN BOOLEAN MODE)) and d.id <> " . $youhui['id'];
         $near_youhui = search_youhui_list(4, 0, $condition, "", false, "");
         $GLOBALS['tmpl']->assign("near_youhui_list", $near_youhui['list']);
     }
     $GLOBALS['tmpl']->display("youhui_ydetail.html", $cache_id);
 }
예제 #4
0
 public function index_right_daijin()
 {
     $result = search_youhui_list(5, 0, "", "", false, "", $GLOBALS['deal_city']['id']);
     $daijin_list = $result['list'];
     $GLOBALS['tmpl']->assign("daijin_list", $daijin_list);
     return $GLOBALS['tmpl']->fetch("index/index_right_daijin.html");
 }