예제 #1
0
function assign_store_list($sel_sid)
{
    global $smarty;
    $col_size = 4;
    $store_list = get_store_list();
    array_unshift($store_list, array('store_id' => '0', 'store_name' => '全部仓库'));
    $store_list_new = array();
    $i = 1;
    foreach ($store_list as $key => $val) {
        $cur_scr = ceil($i / $col_size);
        $store_list_new[$cur_scr][] = $val;
        if ($val['store_id'] == $sel_sid) {
            $smarty->assign('sel_store', $val);
        }
        $i++;
    }
    $store_list = $store_list_new;
    $store_list_count = count($store_list);
    $smarty->assign('store_list_count', $store_list_count);
    $smarty->assign('store_list', $store_list);
    $smarty->assign('showck', !empty($sel_sid) ? 1 : 0);
}
예제 #2
0
 public function index()
 {
     convert_req($_REQUEST);
     $_REQUEST['cid'] = intval($_REQUEST['cid']);
     $keyword = addslashes(htmlspecialchars(trim($_REQUEST['keyword'])));
     //获取当前页的团购商品列表
     require_once APP_ROOT_PATH . 'app/Lib/page.php';
     $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");
     $cate_list = load_auto_cache("cache_deal_cate");
     $cid = intval($_REQUEST['cid']);
     $uname = addslashes(trim($_REQUEST['cid']));
     //$cate_item = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."deal_cate where id = ".$cid." or (uname = '".$uname."' and uname <> '')");
     $cate_item = $cate_list[$cid];
     $condition = " 1=1 ";
     //条件
     $base_param = $url_param = array("cid" => $_REQUEST['cid'], "aid" => intval($_REQUEST['aid']), "tid" => intval($_REQUEST['tid']), "qid" => intval($_REQUEST['qid']), "keyword" => $keyword, "minprice" => $minprice = doubleval($_REQUEST['minprice']) > 0 ? doubleval($_REQUEST['minprice']) : 0, "maxprice" => $maxprice = doubleval($_REQUEST['maxprice']) > 0 ? doubleval($_REQUEST['maxprice']) : 0);
     //组装分组筛选
     if ($_REQUEST['g'] && is_array($_REQUEST['g'])) {
         foreach ($_REQUEST['g'] as $k => $v) {
             $url_param["g[" . $k . "]"] = addslashes(trim($v));
         }
     }
     if (intval($_REQUEST['is_redirect']) == 1) {
         app_redirect(url("youhui", "store", $url_param));
     }
     $GLOBALS['tmpl']->assign("url_param", $url_param);
     //将变量输出到模板
     unset($url_param['keyword']);
     unset($url_param['minprice']);
     unset($url_param['maxprice']);
     $cache_param = $url_param;
     $cache_param['cid'] = $cate_item['id'];
     $cache_param['city_id'] = $city_id;
     $result = load_auto_cache("store_filter_nav_cache", $cache_param);
     $filter_url_param = $base_param;
     $filter_url_param['has_tuan'] = intval($_REQUEST['has_tuan']);
     $filter_url_param['has_daijin'] = intval($_REQUEST['has_daijin']);
     $filter_url_param['has_youhui'] = intval($_REQUEST['has_youhui']);
     $filter_url_param['has_event'] = intval($_REQUEST['has_event']);
     $filter_url_param['has_goods'] = intval($_REQUEST['has_goods']);
     $filter_url_param['is_verify'] = intval($_REQUEST['is_verify']);
     $GLOBALS['tmpl']->assign("filter_url_param", $filter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_tuan'] == 1) {
         $tmpfilter_url_param['has_tuan'] = 0;
     } else {
         $tmpfilter_url_param['has_tuan'] = 1;
     }
     $filter_url['has_tuan'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_daijin'] == 1) {
         $tmpfilter_url_param['has_daijin'] = 0;
     } else {
         $tmpfilter_url_param['has_daijin'] = 1;
     }
     $filter_url['has_daijin'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_youhui'] == 1) {
         $tmpfilter_url_param['has_youhui'] = 0;
     } else {
         $tmpfilter_url_param['has_youhui'] = 1;
     }
     $filter_url['has_youhui'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_event'] == 1) {
         $tmpfilter_url_param['has_event'] = 0;
     } else {
         $tmpfilter_url_param['has_event'] = 1;
     }
     $filter_url['has_event'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['has_goods'] == 1) {
         $tmpfilter_url_param['has_goods'] = 0;
     } else {
         $tmpfilter_url_param['has_goods'] = 1;
     }
     $filter_url['has_goods'] = url("youhui", "store", $tmpfilter_url_param);
     $tmpfilter_url_param = $filter_url_param;
     if ($filter_url_param['is_verify'] == 1) {
         $tmpfilter_url_param['is_verify'] = 0;
     } else {
         $tmpfilter_url_param['is_verify'] = 1;
     }
     $filter_url['is_verify'] = url("youhui", "store", $tmpfilter_url_param);
     $GLOBALS['tmpl']->assign("filter_url", $filter_url);
     //输出大区
     $seo_title = $GLOBALS['lang']['STORE_LIST'];
     $seo_keyword = $GLOBALS['lang']['STORE_LIST'];
     $seo_description = $GLOBALS['lang']['STORE_LIST'];
     $append_seo = "";
     $area_id = intval($_REQUEST['aid']);
     $quan_id = intval($_REQUEST['qid']);
     $area_result = load_auto_cache("cache_area", array("city_id" => $GLOBALS['deal_city']['id']));
     if ($area_id > 0) {
         // 			$area_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."area where id = ".$area_id);
         $area_name = $area_result[$area_id]['name'];
         $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 ($ids as $k => $v) {
                 $unicode_quans[] = str_to_unicode_string($area_result[$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);
             $area_name = $area_result[$quan_id]['name'];
             $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']);
         $GLOBALS['tmpl']->assign("tag_group", $result['tag_group']);
         //$deal_cate_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."deal_cate where id = ".$deal_cate_id);
         $deal_cate_name = $cate_list[$deal_cate_id]['name'];
         $deal_cate_name_unicode = str_to_unicode_string($deal_cate_name);
         $condition .= " and (match(deal_cate_match) against('" . $deal_cate_name_unicode . "' IN BOOLEAN MODE)) ";
         $cate_condition = " (match(deal_cate_match) against('" . $deal_cate_name_unicode . "' IN BOOLEAN MODE)) ";
         if ($append_seo != "") {
             $append_seo .= " - ";
         }
         $append_seo .= $cate_item['name'];
     }
     if ($deal_type_id > 0) {
         $type_list = load_auto_cache("cache_deal_cate_type", array("cate_id" => $deal_cate_id));
         // 			$deal_type_name = $GLOBALS['db']->getOne("select name from ".DB_PREFIX."deal_cate_type where id = ".$deal_type_id);
         $deal_type_name = $type_list[$deal_type_id]['name'];
         $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;
     $supplier_id = intval($_REQUEST['id']);
     if ($supplier_id > 0) {
         $supplier_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . $supplier_id);
         if ($supplier_info) {
             $GLOBALS['tmpl']->assign("supplier_info", $supplier_info);
             $condition .= " and supplier_id = " . $supplier_id;
         }
     }
     $url_param['tag'] = addslashes($_REQUEST['tag']);
     if ($url_param['tag']) {
         $kw_unicode = str_to_unicode_string($url_param['tag']);
         //有筛选
         $condition .= " and (match(tags_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
     }
     if ($_REQUEST['g'] && is_array($_REQUEST['g'])) {
         foreach ($_REQUEST['g'] as $k => $v) {
             if (trim($v) != "") {
                 $kw_unicode = str_to_unicode_string($v);
                 $condition .= " and (match(tags_match) against('" . $kw_unicode . "' IN BOOLEAN MODE))";
             }
         }
     }
     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);
         //有筛选
         $condition .= " and (locate_match_row like '%" . $keyword . "%' or name like '%" . $keyword . "%') ";
     }
     if ($minprice > 0) {
         $condition .= " and ref_avg_price >= " . $minprice;
         $GLOBALS['tmpl']->assign("minprice", round($minprice));
     }
     if ($maxprice > 0) {
         $condition .= " and ref_avg_price <= " . $maxprice;
         $GLOBALS['tmpl']->assign("maxprice", round($maxprice));
     }
     if ($filter_url_param['has_tuan'] > 0) {
         $condition .= " and tuan_count > 0 ";
     }
     if ($filter_url_param['has_daijin'] > 0) {
         $condition .= " and daijin_count > 0 ";
     }
     if ($filter_url_param['has_youhui'] > 0) {
         $condition .= " and youhui_count > 0 ";
     }
     if ($filter_url_param['has_event'] > 0) {
         $condition .= " and event_count > 0 ";
     }
     if ($filter_url_param['has_goods'] > 0) {
         $condition .= " and shop_count > 0 ";
     }
     if ($filter_url_param['is_verify'] > 0) {
         $condition .= " and is_verify = 1 ";
     }
     $sort_field = es_cookie::get("store_sort_field");
     $sort_type = es_cookie::get("store_sort_type");
     if ($sort_type != "desc" && $sort_type != "asc") {
         $sort_type = "desc";
     }
     if ($sort_field != "default" && $sort_field != "dp_count" && $sort_field != "avg_point" && $sort_field != "ref_avg_price") {
         $sort_field = "default";
     }
     if ($sort_field == 'default') {
         $sortby = " sort desc, id desc,is_verify desc,dp_count desc ";
     } else {
         $sortby = $sort_field . " " . $sort_type;
     }
     $GLOBALS['tmpl']->assign('sort_field', $sort_field);
     $GLOBALS['tmpl']->assign('sort_type', $sort_type);
     $result = get_store_list($limit, 0, $condition, $sortby, 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);
     $site_nav[] = array('name' => $GLOBALS['lang']['HOME_PAGE'], 'url' => url("index", "index"));
     $site_nav[] = array('name' => $GLOBALS['lang']['STORE_LIST'], 'url' => url("youhui", "store"));
     $GLOBALS['tmpl']->assign("site_nav", $site_nav);
     //输出最新加入的商家
     $new_stores = get_store_list(5, 0, $cate_condition, " id desc ", false, false);
     $GLOBALS['tmpl']->assign("new_stores", $new_stores['list']);
     if (trim($cate_condition) != '') {
         $rec_stores = get_store_list(5, 0, $cate_condition . " and is_recommend = 1 ", " id desc ", false, false);
     } else {
         $rec_stores = get_store_list(5, 0, " is_recommend = 1 ", " id desc ", false, false);
     }
     $GLOBALS['tmpl']->assign("rec_stores", $rec_stores['list']);
     $GLOBALS['tmpl']->assign("page_title", $seo_title);
     $GLOBALS['tmpl']->assign("page_keyword", $seo_keyword . ",");
     $GLOBALS['tmpl']->assign("page_description", $seo_description . ",");
     $GLOBALS['tmpl']->display("store_index.html");
 }
예제 #3
0
}
$config = get_server_config();
if (!$config) {
    error("no config file");
}
if (!init_db($config)) {
    error("can't connect to DB");
}
$req = json_decode($_POST['request']);
switch ($req->operation) {
    case 'create_observation':
        create_observation($req);
        break;
    case 'create_file':
        create_file($req);
        break;
    case 'delete_file':
        delete_file($req);
        break;
    case 'create_copy_task':
        create_copy_task($req);
        break;
    case 'get_store_list':
        get_store_list($req);
        break;
    case 'recommended_store':
        recommended_store($req);
        break;
    default:
        error("unknown op {$req->operation}");
}
예제 #4
0
function lookup_store($site_name, $store_name)
{
    $ret = get_store_list($site_name);
    if (!$ret->success) {
        return $ret;
    }
    foreach ($ret->stores as $store) {
        if ($store_name == $store->name) {
            $ret->store = $store;
            return $ret;
        }
    }
    $ret->success = false;
    $ret->message = "no such store";
    return $ret;
}