Esempio n. 1
0
function get_side_deal($deal_id)
{
    $city = get_current_deal_city();
    $city_id = $city['id'];
    $side_deal_list = get_deal_list_show(app_conf("SIDE_DEAL_COUNT"), intval($GLOBALS['deal_cate_id']), $city_id, array(DEAL_ONLINE), "id<>" . $deal_id . " and buy_type <> 1 ");
    return $side_deal_list['list'];
}
Esempio n. 2
0
 public function all()
 {
     $city_name = trim(addslashes($_REQUEST['city']));
     if ($city_name) {
         $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where uname='' and is_effect = 1 and is_delete = 0");
     }
     if (!$deal_city) {
         $deal_city = get_current_deal_city();
     }
     es_cookie::set("deal_city", $deal_city['id']);
     app_redirect(url("index"));
 }
Esempio n. 3
0
function get_supplier_list($limit, $cate_id = 0, $city_id = 0, $where = '')
{
    $condition = " is_effect = 1 ";
    if ($cate_id > 0) {
        $ids = load_auto_cache("deal_sub_parent_cate_ids", array("cate_id" => $cate_id));
        $condition .= " and cate_id in (" . implode(",", $ids) . ")";
    }
    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 ($where != '') {
        $condition .= " and " . $where;
    }
    $sql = "select * from " . DB_PREFIX . "supplier where " . $condition . " order by sort desc limit " . $limit;
    $count_sql = "select count(*) from " . DB_PREFIX . "supplier where " . $condition;
    $suppliers = $GLOBALS['db']->getAll($sql);
    $suppliers_count = $GLOBALS['db']->getOne($count_sql);
    foreach ($suppliers as $k => $v) {
        $suppliers[$k]['url'] = url("shop", "brand", array("id" => $v['id']));
        $main_location = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . $v['id'] . " and is_main = 1");
        $suppliers[$k]['tel'] = $main_location['tel'];
        $suppliers[$k]['address'] = $main_location['address'];
        $suppliers[$k]['contact'] = $main_location['contact'];
        $suppliers[$k]['brief'] = $main_location['brief'];
        $suppliers[$k]['deal_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal where supplier_id = " . $v['id'] . " and is_effect = 1 and is_delete = 0 and buy_type <> 1 and time_status > 0");
        $max_price = $GLOBALS['db']->getOne("select max(current_price) from " . DB_PREFIX . "deal where supplier_id = " . $v['id'] . " and is_effect = 1 and is_delete = 0 and buy_type <> 1");
        $min_price = $GLOBALS['db']->getOne("select min(current_price) from " . DB_PREFIX . "deal where supplier_id = " . $v['id'] . " and is_effect = 1 and is_delete = 0 and buy_type <> 1");
        if ($max_price == $min_price) {
            $suppliers[$k]['deal_price'] = format_price($max_price);
        } else {
            $suppliers[$k]['deal_price'] = format_price($min_price) . " - " . format_price($max_price);
        }
        $suppliers[$k]['comment_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_table='supplier' and rel_id = " . $v['id']);
        $suppliers[$k]['comment1_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_table='supplier' and rel_id = " . $v['id'] . " and point = 1");
        //差
        $suppliers[$k]['comment2_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_table='supplier' and rel_id = " . $v['id'] . " and point = 2");
        //中
        $suppliers[$k]['comment3_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "message where rel_table='supplier' and rel_id = " . $v['id'] . " and point = 3");
        //好
    }
    return array('list' => $suppliers, 'count' => $suppliers_count);
}
Esempio n. 4
0
 public function index()
 {
     $rss = new UniversalFeedCreator();
     $rss->useCached();
     // use cached version if age<1 hour
     $rss->title = app_conf("SHOP_TITLE") . " - " . app_conf("SHOP_SEO_TITLE");
     $rss->description = app_conf("SHOP_SEO_TITLE");
     //optional
     $rss->descriptionTruncSize = 500;
     $rss->descriptionHtmlSyndicated = true;
     $rss->link = get_domain() . APP_ROOT;
     $rss->syndicationURL = get_domain() . APP_ROOT;
     //optional
     $image->descriptionTruncSize = 500;
     $image->descriptionHtmlSyndicated = true;
     $domain = app_conf("PUBLIC_DOMAIN_ROOT") == '' ? get_domain() . $GLOBALS['IMG_APP_ROOT'] : app_conf("PUBLIC_DOMAIN_ROOT");
     $city = get_current_deal_city();
     $city_id = $city['id'];
     $deal_list = get_deal_list(app_conf("DEAL_PAGE_SIZE"), 0, 0, array(DEAL_ONLINE), " buy_type <> 1 or ( is_shop = 1 and is_effect =1 and is_delete = 0 and buy_type <> 1)");
     $deal_list = $deal_list['list'];
     foreach ($deal_list as $data) {
         $item = new FeedItem();
         if ($data['uname'] != '') {
             $gurl = url("shop", "goods", array("id" => $data['uname']));
         } else {
             $gurl = url("shop", "goods", array("id" => $data['id']));
         }
         $data['url'] = $gurl;
         $item->title = msubstr($data['name'], 0, 30);
         $item->link = get_domain() . $data['url'];
         $data['description'] = str_replace($GLOBALS['IMG_APP_ROOT'] . "./public/", $domain . "/public/", $data['description']);
         $data['description'] = str_replace("./public/", $domain . "/public/", $data['description']);
         $data['img'] = str_replace("./public/", $domain . "/public/", $data['img']);
         $item->description = "<img src='" . $data['img'] . "' /><br />" . $data['brief'] . "<br /> <a href='" . get_domain() . $data['url'] . "' target='_blank' >" . $GLOBALS['lang']['VIEW_DETAIL'] . "</a>";
         //optional
         $item->descriptionTruncSize = 500;
         $item->descriptionHtmlSyndicated = true;
         if ($data['end_time'] != 0) {
             $item->date = date('r', $data['end_time']);
         }
         $item->source = $data['url'];
         $item->author = app_conf("SHOP_TITLE");
         $rss->addItem($item);
     }
     $rss->saveFeed($format = "RSS0.91", $filename = APP_ROOT_PATH . "public/runtime/app/tpl_caches/rss.xml");
 }
 public function addmail()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!check_ipop_limit(get_client_ip(), "subscribe#addmail", intval(app_conf("SUBMIT_DELAY")), 0)) {
         showErr($GLOBALS['lang']['SUBMIT_TOO_FAST'], $ajax);
     }
     if (trim($_REQUEST['email']) == '') {
         showErr($GLOBALS['lang']['EMAIL_EMPTY_TIP'], $ajax);
     }
     if (!check_email($_REQUEST['email'])) {
         showErr($GLOBALS['lang']['EMAIL_FORMAT_ERROR_TIP'], $ajax);
     }
     if ($_REQUEST['othercity'] && trim($_REQUEST['othercity']) != '') {
         //提交其他城市
         $other_city = htmlspecialchars(addslashes($_REQUEST['othercity']));
         $other_city_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where name = '" . $other_city . "'");
         if ($other_city_item) {
             $city_id = $other_city_item['id'];
         } else {
             $new_city['name'] = $other_city;
             $new_city['pid'] = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "deal_city where pid = 0");
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_city", $new_city);
             $city_id = $GLOBALS['db']->insert_id();
         }
     } elseif (intval($_REQUEST['cityid']) != 0) {
         $city_id = intval($_REQUEST['cityid']);
     } else {
         $city_item = get_current_deal_city();
         $city_id = $city_item['id'];
     }
     $mail_item['mail_address'] = addslashes(trim(htmlspecialchars($_REQUEST['email'])));
     $mail_item['city_id'] = $city_id;
     $mail_item['is_effect'] = 1;
     if ($GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "mail_list where mail_address='" . $mail_item['mail_address'] . "'") == 0) {
         //没有订阅过
         $GLOBALS['db']->autoExecute(DB_PREFIX . "mail_list", $mail_item);
     }
     showSuccess($GLOBALS['lang']['SUBSCRIBE_SUCCESS'], $ajax);
 }
Esempio n. 6
0
/**
 * 获取正在团购的产品列表
 */
function get_deal_list_show($limit, $cate_id = 0, $city_id = 0, $type = array(DEAL_ONLINE, DEAL_HISTORY, DEAL_NOTICE), $where = '', $orderby = '')
{
    $time = get_gmtime();
    $time_condition = '  and is_shop = 0 and ( 1<>1 ';
    if (in_array(DEAL_ONLINE, $type)) {
        //进行中的团购
        $time_condition .= " or ((" . $time . ">= begin_time or begin_time = 0) and (" . $time . "<end_time or end_time = 0) and buy_status <> 2) ";
    }
    if (in_array(DEAL_HISTORY, $type)) {
        //往期团购
        $time_condition .= " or ((" . $time . ">=end_time and end_time <> 0) or buy_status = 2) ";
    }
    if (in_array(DEAL_NOTICE, $type)) {
        //预告
        $time_condition .= " or ((" . $time . " < begin_time and begin_time <> 0 and notice = 1)) ";
    }
    $time_condition .= ')';
    $count_sql = "select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0 " . $time_condition;
    $sql = "select * from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0 " . $time_condition;
    if ($cate_id > 0) {
        $ids = load_auto_cache("deal_sub_parent_cate_ids", array("cate_id" => $cate_id));
        $sql .= " and cate_id in (" . implode(",", $ids) . ")";
        $count_sql .= " and cate_id in (" . implode(",", $ids) . ")";
    }
    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));
        $sql .= " and city_id in (" . implode(",", $ids) . ")";
        $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
    }
    if ($where != '') {
        $sql .= " and " . $where;
        $count_sql .= " and " . $where;
    }
    if ($orderby == '') {
        $sql .= " order by sort desc limit " . $limit;
    } else {
        $sql .= " order by " . $orderby . " limit " . $limit;
    }
    $deals = $GLOBALS['db']->getAll($sql);
    $deals_count = $GLOBALS['db']->getOne($count_sql);
    if ($deals) {
        foreach ($deals as $k => $deal) {
            //格式化数据
            $deal['begin_time_format'] = to_date($deal['begin_time']);
            $deal['end_time_format'] = to_date($deal['end_time']);
            $deal['origin_price_format'] = format_price($deal['origin_price']);
            $deal['current_price_format'] = format_price($deal['current_price']);
            $deal['success_time_format'] = to_date($deal['success_time']);
            if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                //手动折扣
                $deal['save_price'] = $deal['origin_price'] - $deal['current_price'];
            } else {
                $deal['save_price'] = $deal['origin_price'] * ((10 - $deal['discount']) / 10);
            }
            if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                $deal['discount'] = round($deal['current_price'] / $deal['origin_price'] * 10, 2);
            }
            $deal['discount'] = round($deal['discount'], 2);
            $deal['save_price_format'] = format_price($deal['save_price']);
            if ($deal['uname'] != '') {
                $durl = url("tuan", "deal", array("id" => $deal['uname']));
            } else {
                $durl = url("tuan", "deal", array("id" => $deal['id']));
            }
            $deal['url'] = $durl;
            $deal['deal_success_num'] = sprintf($GLOBALS['lang']['SUCCESS_BUY_COUNT'], $deal['buy_count']);
            $deal['current_bought'] = $deal['buy_count'];
            if ($deal['buy_status'] == 0) {
                $deal['success_less'] = sprintf($GLOBALS['lang']['SUCCESS_LESS_BUY_COUNT'], $deal['min_bought'] - $deal['buy_count']);
            }
            $deals[$k] = $deal;
        }
    }
    return array('list' => $deals, 'count' => $deals_count);
}
Esempio n. 7
0
 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);
 }
Esempio n. 8
0
 public function index()
 {
     $GLOBALS['tmpl']->caching = true;
     $cache_id = md5(MODULE_NAME . ACTION_NAME . $GLOBALS['deal_city']['id']);
     if (!$GLOBALS['tmpl']->is_cached('mall.html', $cache_id)) {
         //输出商城分类
         $cate_tree = get_cate_tree(0, 1);
         $top_count = 0;
         foreach ($cate_tree as $k => $v) {
             if ($v['level'] == 0) {
                 $top_count++;
             }
             //				if($top_count>6)
             //				{
             //					$cate_tree[$k]['is_hide'] = 1;
             //				}
         }
         $GLOBALS['tmpl']->assign("cate_tree", $cate_tree);
         //获取推荐
         $hot_list = get_goods_list(intval(app_conf("REC_HOT_LIMIT")), 0, " is_hot = 1 and buy_type <> 1", "", false);
         $best_list = get_goods_list(intval(app_conf("REC_BEST_LIMIT")), 0, " is_best = 1 and buy_type <> 1 ", "", false);
         $new_list = get_goods_list(intval(app_conf("REC_NEW_LIMIT")), 0, " is_new = 1 and buy_type <> 1 ", "", false);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['HOT_LIST'], 'list' => $hot_list['list'], 'url' => url("shop", "rec#rhot")));
         $hot_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("hot_span_goods_html", $hot_span_goods_html);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['BEST_LIST'], 'list' => $best_list['list'], 'url' => url("shop", "rec#rbest")));
         $best_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("best_span_goods_html", $best_span_goods_html);
         $GLOBALS['tmpl']->assign("inc_var", array('title' => $GLOBALS['lang']['NEW_LIST'], 'list' => $new_list['list'], 'url' => url("shop", "rec#rnew")));
         $new_span_goods_html = $GLOBALS['tmpl']->fetch("inc/span_goods.html");
         $GLOBALS['tmpl']->assign("new_span_goods_html", $new_span_goods_html);
         $recommend_cate = $GLOBALS['db']->getAll("select id,name,uname from " . DB_PREFIX . "shop_cate where grade = 0 order by sort desc");
         //输出分类商品
         $recommend_cate_html = "";
         foreach ($recommend_cate as $cate => $catev) {
             require_once APP_ROOT_PATH . "system/utils/child.php";
             $ids_util = new child("shop_cate");
             $ids = $ids_util->getChildIds($catev['id']);
             $ids[] = $catev['id'];
             $brand_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "brand where shop_cate_id in (" . implode(",", $ids) . ") limit 8");
             foreach ($brand_list as $kk => $brand_item) {
                 $brand_list[$kk]['url'] = url("shop", "brand#index", array("id" => $brand_item['id']));
             }
             //商城推荐分类列表
             $time = get_gmtime();
             $count_sql = "select count(*) from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0  and p_shop_cate_id=" . $catev['id'];
             $sql = "select * from " . DB_PREFIX . "deal where is_effect = 1 and is_delete = 0  and p_shop_cate_id=" . $catev['id'];
             $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) {
                     $sql .= " and city_id in (" . implode(",", $ids) . ")";
                     $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
                 }
             }
             $sql .= " and buy_type <> 1 ";
             $count_sql .= " and buy_type <> 1 ";
             $sql .= " order by sort desc limit 10 ";
             $deals = $GLOBALS['db']->getAll($sql);
             $deals_count = $GLOBALS['db']->getOne($count_sql);
             if ($deals) {
                 foreach ($deals as $k => $deal) {
                     if ($deal['buy_type'] == 1) {
                         $module = "exchange";
                     } else {
                         $module = "goods";
                     }
                     if ($deal['uname'] != '') {
                         $durl = url("shop", $module, array("id" => $deal['uname']));
                     } else {
                         $durl = url("shop", $module, array("id" => $deal['id']));
                     }
                     $deal['url'] = $durl;
                     $deals[$k] = $deal;
                 }
             }
             $cate_list = array('list' => $deals, 'count' => $deals_count);
             //$cate_list=$catev['id'];
             //$cate_list['sd'] = get_goods_list(intval(app_conf("REC_CATE_GOODS_LIMIT")),$catev['id']," buy_type <> 1 ","",false);
             $cate_title = $catev['name'];
             if ($catev['uname'] != "") {
                 $curl = url("shop", "cate#index", array("id" => $catev['uname']));
             } else {
                 $curl = url("shop", "cate#index", array("id" => $catev['id']));
             }
             $GLOBALS['tmpl']->assign("inc_var", array('id' => $catev['id'], 'brand_list' => $brand_list, 'title' => $cate_title, 'list' => $cate_list['list'], 'url' => $curl));
             $recommend_cate_html .= $GLOBALS['tmpl']->fetch("inc/recommend_cate_goods.html");
         }
         $GLOBALS['tmpl']->assign("recommend_cate_html", $recommend_cate_html);
         $GLOBALS['tmpl']->assign("page_title", app_conf("MALL_SHOP_TITLE"));
         $GLOBALS['tmpl']->assign("page_keyword", app_conf("MALL_SHOP_TITLE"));
         $GLOBALS['tmpl']->assign("page_description", app_conf("MALL_SHOP_TITLE"));
         //输出商城公告
         $notice_list = get_notice(0, array(0, 2));
         $GLOBALS['tmpl']->assign("notice_list", $notice_list);
     }
     $GLOBALS['tmpl']->display("mall.html", $cache_id);
 }
Esempio n. 9
0
 public function index()
 {
     $cur_city_id = intval($GLOBALS['request']['cur_city_id']);
     if ($cur_city_id == 0) {
         $deal_city = get_current_deal_city();
         //默认城市id
         //print_r($deal_city); exit;
         $cur_city_id = $deal_city['id'];
         $city_name = $deal_city['name'];
     } else {
         $city_name = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_city where id = " . $cur_city_id);
     }
     $root = array();
     $root['return'] = 1;
     $root['city_id'] = $cur_city_id;
     $root['city_name'] = $city_name;
     $root['catalog_id'] = intval($GLOBALS['m_config']['catalog_id']);
     //团购,优惠券默认分类id
     $root['catalog_id_name'] = $GLOBALS['m_config']['catalog_id_name'];
     $root['shop_cate_id'] = intval($GLOBALS['m_config']['shop_cate_id']);
     //商城默认分类id
     $root['shop_cate_id_name'] = $GLOBALS['m_config']['shop_cate_id_name'];
     $root['event_cate_id'] = intval($GLOBALS['m_config']['event_cate_id']);
     //活动默认分类id
     $root['event_cate_id_name'] = $GLOBALS['m_config']['event_cate_id_name'];
     $root['citylist'] = getCityArray();
     //$root['cataloglist'] = getCatalogArray();
     //$root['cataloglistsearch'] = getCatalogArraySearch();
     $root['region_version'] = intval($GLOBALS['m_config']['region_version']);
     //当前配送地区的数据版本(如果大于客户端的版本号,则客户端在选择,配送地区时会提示升级),int 数字类型
     $root['only_one_delivery'] = intval($GLOBALS['m_config']['only_one_delivery']);
     //1:会员只有一个配送地址;0:会员可以有多个配送地址
     $root['kf_phone'] = $GLOBALS['m_config']['kf_phone'];
     //客服电话
     $root['kf_email'] = $GLOBALS['m_config']['kf_email'];
     //客服邮箱
     $root['about_info'] = $GLOBALS['m_config']['about_info'];
     $root['version'] = VERSION;
     //接口版本号int
     $root['page_size'] = PAGE_SIZE;
     //默认分页大小
     $root['has_region'] = intval($GLOBALS['m_config']['has_region']);
     $root['newslist'] = $GLOBALS['m_config']['newslist'];
     $root['program_title'] = $GLOBALS['m_config']['program_title'];
     $root['addr_tlist'] = $GLOBALS['m_config']['addr_tlist'];
     //保存地址标题
     //$root['adv_youhui'] = m_adv_youhui($cur_city_id);
     $root['quanlist'] = getQuanArray($cur_city_id);
     //商圈列表
     $root['deal_cate_list'] = getDealCateArray();
     //优惠券分类
     $root['index_logo'] = get_abs_img_root($GLOBALS['m_config']['index_logo']);
     if (strim($GLOBALS['m_config']['sina_app_key']) != "" && strim($GLOBALS['m_config']['sina_app_secret']) != "") {
         $root['api_sina'] = 1;
         $root['sina_app_key'] = $GLOBALS['m_config']['sina_app_key'];
         $root['sina_app_secret'] = $GLOBALS['m_config']['sina_app_secret'];
         $root['sina_bind_url'] = $GLOBALS['m_config']['sina_bind_url'];
     }
     if (strim($GLOBALS['m_config']['tencent_app_key']) != "" && strim($GLOBALS['m_config']['tencent_app_secret']) != "") {
         $root['api_tencent'] = 1;
         $root['tencent_app_key'] = $GLOBALS['m_config']['tencent_app_key'];
         $root['tencent_app_secret'] = $GLOBALS['m_config']['tencent_app_secret'];
         $root['tencent_bind_url'] = $GLOBALS['m_config']['tencent_bind_url'];
     }
     output($root);
 }
Esempio n. 10
0
function m_search_youhui_list($limit, $cate_id = 0, $where = '', $orderby = '', $city_id = 0, $field_append = "")
{
    if ($city_id == 0) {
        $city = get_current_deal_city();
        $city_id = $city['id'];
    }
    $count_sql = "select count(*) from " . DB_PREFIX . "deal ";
    $sql = "select * {$field_append} from " . DB_PREFIX . "deal ";
    $time = get_gmtime();
    $time_condition = '  and (end_time = 0 or end_time > ' . $time . ') ';
    $count_sql .= " where is_effect = 1 and is_delete = 0 and is_shop = 2 " . $time_condition;
    $sql .= " where is_effect = 1 and is_delete = 0 and is_shop = 2 " . $time_condition;
    if ($cate_id > 0) {
        $ids = load_auto_cache("deal_sub_cate_ids", array("cate_id" => $cate_id));
        $sql .= " and cate_id in (" . implode(",", $ids) . ")";
        $count_sql .= " and cate_id in (" . implode(",", $ids) . ")";
    }
    if ($city_id > 0) {
        $ids = load_auto_cache("deal_city_belone_ids", array("city_id" => $city_id));
        if ($ids) {
            $sql .= " and city_id in (" . implode(",", $ids) . ")";
            $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
        }
    }
    $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) {
            $sql .= " and id in (" . $deal_ids . ")";
            $count_sql .= " and id in (" . $deal_ids . ")";
        } else {
            $sql .= " and id = 0 ";
            $count_sql .= " and id = 0 ";
        }
    }
    if ($where != '') {
        $sql .= " and " . $where;
        $count_sql .= " and " . $where;
    }
    if ($orderby == '') {
        $sql .= " order by sort desc limit " . $limit;
    } else {
        $sql .= " order by " . $orderby . " limit " . $limit;
    }
    $deals = $GLOBALS['db']->getAll($sql);
    $deals_count = $GLOBALS['db']->getOne($count_sql);
    if ($deals) {
        foreach ($deals as $k => $deal) {
            //格式化数据
            $deal['origin_price_format'] = format_price($deal['origin_price']);
            $deal['current_price_format'] = format_price($deal['current_price']);
            if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                //手动折扣
                $deal['save_price'] = $deal['origin_price'] - $deal['current_price'];
            } else {
                $deal['save_price'] = $deal['origin_price'] * ((10 - $deal['discount']) / 10);
            }
            if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                $deal['discount'] = round($deal['current_price'] / $deal['origin_price'] * 10, 2);
            }
            $deal['discount'] = round($deal['discount'], 2);
            $deal['save_price_format'] = format_price($deal['save_price']);
            if ($deal['uname'] != '') {
                $durl = url("youhui", "ydetail", array("id" => $deal['uname']));
            } else {
                $durl = url("youhui", "ydetail", array("id" => $deal['id']));
            }
            $deal['url'] = $durl;
            $deals[$k] = $deal;
        }
    }
    $res = array('list' => $deals, 'count' => $deals_count);
    return $res;
}
Esempio n. 11
0
/**
 * 搜索活动列表
 */
function search_event_list($limit, $cate_id = 0, $city_id = 0, $where = '', $orderby = '', $cached = false)
{
    $key = md5("EVENT_" . $limit . $cate_id . $city_id . $where . $orderby);
    if ($cached) {
        $res = $GLOBALS['cache']->get($key);
    } else {
        $res = false;
    }
    if ($res === false) {
        $count_sql = "select count(*) from " . DB_PREFIX . "event ";
        $sql = "select * from " . DB_PREFIX . "event ";
        $count_sql .= " where is_effect = 1 ";
        $sql .= " where is_effect = 1  ";
        if ($cate_id > 0) {
            $sql .= " and cate_id = " . $cate_id . " ";
            $count_sql .= " and cate_id = " . $cate_id . " ";
        }
        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) {
                $sql .= " and city_id in (" . implode(",", $ids) . ")";
                $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
            }
        }
        if ($where != '') {
            $sql .= " and " . $where;
            $count_sql .= " and " . $where;
        }
        if ($orderby == '') {
            $sql .= " order by is_recommend desc,sort desc  ";
        } else {
            $sql .= " order by is_recommend desc," . $orderby . "  ";
        }
        if ($limit != "") {
            $sql .= " limit " . $limit . " ";
        }
        $events = $GLOBALS['db']->getAll($sql);
        $events_count = $GLOBALS['db']->getOne($count_sql);
        $res = array('list' => $events, 'count' => $events_count);
        $GLOBALS['cache']->set($key, $res);
    }
    return $res;
}
/**
 * 获取指定的团购产品
 */
function get_referral_deal($id = 0, $cate_id = 0, $city_id = 0)
{
    $time = get_gmtime();
    if ($id > 0) {
        $deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($id) . " and is_referral = 1 and is_effect = 1 and is_delete = 0 and (" . $time . ">= begin_time or begin_time = 0 or notice = 1) ");
    }
    if (!$deal) {
        $sql = "select * from " . DB_PREFIX . "deal where is_referral = 1 and is_effect = 1 and is_delete = 0 and buy_type <> 1 and (" . $time . ">= begin_time or begin_time = 0 or notice = 1) and (" . $time . "<end_time or end_time = 0) and buy_status <> 2 ";
        if ($cate_id > 0) {
            $ids = load_auto_cache("deal_sub_parent_cate_ids", array("cate_id" => $cate_id));
            $sql .= " and cate_id in (" . implode(",", $ids) . ")";
        }
        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) {
                $sql .= " and city_id in (" . implode(",", $ids) . ")";
            }
        }
        $sql .= " order by sort desc";
        $deal = $GLOBALS['db']->getRow($sql);
    }
    if ($deal) {
        if ($deal['time_status'] == 0 && $deal['begin_time'] == 0 || $deal['begin_time'] < get_gmtime()) {
            syn_deal_status($deal['id']);
            $deal = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_referral = 1 and id = " . $deal['id'] . " and is_effect = 1 and is_delete = 0");
        }
        //格式化数据
        $deal['begin_time_format'] = to_date($deal['begin_time']);
        $deal['end_time_format'] = to_date($deal['end_time']);
        $deal['origin_price_format'] = format_price($deal['origin_price']);
        $deal['current_price_format'] = format_price($deal['current_price']);
        $deal['success_time_format'] = to_date($deal['success_time']);
        if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
            //手动折扣
            $deal['save_price'] = $deal['origin_price'] - $deal['current_price'];
        } else {
            $deal['save_price'] = $deal['origin_price'] * ((10 - $deal['discount']) / 10);
        }
        if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
            $deal['discount'] = round($deal['current_price'] / $deal['origin_price'] * 10, 2);
        }
        $deal['discount'] = round($deal['discount'], 2);
        $deal['save_price_format'] = format_price($deal['save_price']);
        $deal['deal_success_num'] = sprintf($GLOBALS['lang']['SUCCESS_BUY_COUNT'], $deal['buy_count']);
        $deal['current_bought'] = $deal['buy_count'];
        if ($deal['buy_status'] == 0) {
            $deal['success_less'] = sprintf($GLOBALS['lang']['SUCCESS_LESS_BUY_COUNT'], $deal['min_bought'] - $deal['buy_count']);
        }
        $deal['success_time_tip'] = sprintf($GLOBALS['lang']['SUCCESS_TIME_TIP'], $deal['success_time_format'], $deal['min_bought']);
        //团购图片集
        $img_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_gallery where deal_id=" . intval($deal['id']) . " order by sort asc");
        $deal['image_list'] = $img_list;
        //商户信息
        $deal['supplier_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier where id = " . intval($deal['supplier_id']));
        $deal['supplier_address_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . intval($deal['supplier_id']) . " and is_main = 1");
        //属性列表
        $deal_attrs_res = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_attr where deal_id = " . intval($deal['id']) . " order by id asc");
        if ($deal_attrs_res) {
            foreach ($deal_attrs_res as $k => $v) {
                $deal_attr[$v['goods_type_attr_id']]['name'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "goods_type_attr where id = " . intval($v['goods_type_attr_id']));
                $deal_attr[$v['goods_type_attr_id']]['attrs'][] = $v;
            }
            $deal['deal_attr_list'] = $deal_attr;
        }
        if ($deal['uname'] != '') {
            $durl = url("tuan", "deal", array("id" => $deal['uname']));
        } else {
            $durl = url("tuan", "deal", array("id" => $deal['id']));
        }
        $deal['share_url'] = get_domain() . $durl;
        if ($GLOBALS['user_info']) {
            if (app_conf("URL_MODEL") == 0) {
                $deal['share_url'] .= "&r=" . base64_encode(intval($GLOBALS['user_info']['id']));
            } else {
                $deal['share_url'] .= "?r=" . base64_encode(intval($GLOBALS['user_info']['id']));
            }
        }
    }
    return $deal;
}
Esempio n. 13
0
/**
 * 获取产品列表
 */
function search_goods_list($limit, $cate_id = 0, $where = '', $orderby = '', $cached = true, $join_str = '')
{
    $key = md5($limit . $cate_id . $where . $orderby . $join_str);
    if ($cached) {
        $res = $GLOBALS['cache']->get($key);
    } else {
        $res = false;
    }
    if ($res === false) {
        $count_sql = "select count(*) from " . DB_PREFIX . "deal as d";
        $sql = "select d.* from " . DB_PREFIX . "deal as d ";
        if ($join_str != '') {
            $count_sql .= $join_str;
            $sql .= $join_str;
        }
        $time = get_gmtime();
        $time_condition = '  and (d.is_shop=1  or d.shop_cate_id <> 0 ) ';
        $count_sql .= " where d.is_effect = 1 and d.is_delete = 0 " . $time_condition;
        $sql .= " where d.is_effect = 1 and d.is_delete = 0 " . $time_condition;
        if ($cate_id > 0) {
            $ids = load_auto_cache("shop_sub_cate_ids", array("cate_id" => $cate_id));
            $sql .= " and d.shop_cate_id in (" . implode(",", $ids) . ")";
            $count_sql .= " and d.shop_cate_id in (" . implode(",", $ids) . ")";
        }
        $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) {
                $sql .= " and city_id in (" . implode(",", $ids) . ")";
                $count_sql .= " and city_id in (" . implode(",", $ids) . ")";
            }
        }
        if ($where != '') {
            $sql .= " and " . $where;
            $count_sql .= " and " . $where;
        }
        if ($orderby == '') {
            $sql .= " order by d.sort desc limit " . $limit;
        } else {
            $sql .= " order by " . $orderby . " limit " . $limit;
        }
        $deals = $GLOBALS['db']->getAll($sql);
        $deals_count = $GLOBALS['db']->getOne($count_sql);
        if ($deals) {
            foreach ($deals as $k => $deal) {
                //格式化数据
                $deal['origin_price_format'] = format_price($deal['origin_price']);
                $deal['current_price_format'] = format_price($deal['current_price']);
                if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                    //手动折扣
                    $deal['save_price'] = $deal['origin_price'] - $deal['current_price'];
                } else {
                    $deal['save_price'] = $deal['origin_price'] * ((10 - $deal['discount']) / 10);
                }
                if ($deal['origin_price'] > 0 && floatval($deal['discount']) == 0) {
                    $deal['discount'] = round($deal['current_price'] / $deal['origin_price'] * 10, 2);
                }
                $deal['discount'] = round($deal['discount'], 2);
                $deal['save_price_format'] = format_price($deal['save_price']);
                if ($deal['uname'] != '') {
                    $durl = url("shop", "goods", array("id" => $deal['uname']));
                } else {
                    $durl = url("shop", "goods", array("id" => $deal['id']));
                }
                $deal['url'] = $durl;
                $deals[$k] = $deal;
            }
        }
        $res = array('list' => $deals, 'count' => $deals_count);
        $GLOBALS['cache']->set($key, $res);
    }
    return $res;
}
Esempio n. 14
0
if (!file_exists(APP_ROOT_PATH . 'public/runtime/app/')) {
    mkdir(APP_ROOT_PATH . 'public/runtime/app/', 0777);
}
//处理城市
//$city_count = $GLOBALS['db']->getOne("select count(id) from ".DB_PREFIX."deal_city where is_effect = 1 and is_delete = 0");
$city_name = trim(addslashes($_REQUEST['city']));
$deal_city = '';
if ($city_name) {
    if ($city_name == 'all') {
        $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where pid = 0");
    } else {
        $deal_city = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_city where uname='" . $city_name . "' and is_effect = 1 and is_delete = 0");
    }
}
if (!$deal_city) {
    $deal_city = get_current_deal_city();
}
es_cookie::set("deal_city", $deal_city['id'], 24 * 3600 * 30);
$GLOBALS['tmpl']->assign("deal_city", $deal_city);
//输出城市
$deal_city_list = get_deal_citys();
$GLOBALS['tmpl']->assign("deal_city_list", $deal_city_list['ls']);
$GLOBALS['tmpl']->assign("deal_city_list_zm", $deal_city_list['zm']);
$GLOBALS['tmpl']->assign("shop_info", get_shop_info());
$GLOBALS['tmpl']->assign("deal_city", $deal_city);
$GLOBALS['tmpl']->assign("show_city_title", true);
if (count($deal_city_list['ls']) > 1) {
    $GLOBALS['tmpl']->assign("city_title", $deal_city['name']);
}
//输出根路径
$GLOBALS['tmpl']->assign("APP_ROOT", APP_ROOT);