예제 #1
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/deal.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;
     $deals = get_deal_list($limit, $catalog_id, $city_id, array(DEAL_ONLINE), "buy_type<>1 and is_lottery = 0 and name like '%" . $keyword . "%'", "sort desc");
     $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);
 }
예제 #2
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/deal.php';
     /**
      * has_attr: 0:无属性; 1:有属性
      * 有商品属性在要购买时,要选择属性后,才能购买
      * change_cart_request_server: 
      * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
      * 0:提交,1:不提交;
      * image_attr_a_id_{$attr_a_id} 图片列表,可以根据属性ID值,来切换图片列表;默认为:0
      * limit_num: 库存数量
      */
     $id = intval($GLOBALS['request']['id']);
     //商品ID
     $item = get_deal($id);
     $root = getGoodsArray($item);
     $root['return'] = 1;
     $root['attr'] = getAttrArray($id);
     $images = array();
     //image_attr_1_id_{$attr_1_id} 图片列表,可以根据属性ID值,来切换图片列表
     $sql = "select img from " . DB_PREFIX . "deal_gallery where deal_id = " . intval($id);
     $list = $GLOBALS['db']->getAll($sql);
     $gallery = array();
     $big_gallery = array();
     foreach ($list as $k => $image) {
         $gallery[] = get_abs_img_root(get_spec_image($image['img'], 320, 320, 0));
         $big_gallery[] = get_abs_img_root(get_spec_image($image['img'], 0, 0, 0));
     }
     $root['gallery'] = $gallery;
     $root['big_gallery'] = $big_gallery;
     output($root);
 }
예제 #3
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/supplier.php';
     $catalog_id = intval($GLOBALS['request']['catalog_id']);
     //商品分类ID
     $city_id = intval($GLOBALS['request']['city_id']);
     //城市分类ID
     $quan_id = intval($GLOBALS['request']['quan_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 ";
     $deals = get_supplier_list($limit, $catalog_id, $city_id, $condition);
     $list = $deals['list'];
     //var_dump($list);die;
     $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, "page_size" => $page_size);
     output($root);
 }
예제 #4
0
 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);
 }
예제 #5
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'system/model/deal.php';
     /**
      * has_attr: 0:无属性; 1:有属性
      * 有商品属性在要购买时,要选择属性后,才能购买
      * change_cart_request_server: 
      * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
      * 0:提交,1:不提交;
      * image_attr_a_id_{$attr_a_id} 图片列表,可以根据属性ID值,来切换图片列表;默认为:0
      * limit_num: 库存数量
      */
     $id = intval($GLOBALS['request']['id']);
     //商品ID
     $user = $GLOBALS['user_info'];
     $user_id = intval($user['id']);
     $is_collect = 0;
     if ($user_id > 0) {
         $sql2 = "select count(*) from " . DB_PREFIX . "deal_collect where deal_id = " . $id . " and user_id=" . $user_id;
         if ($GLOBALS['db']->getOne($sql2) > 0) {
             $is_collect = 1;
         }
     }
     $ypoint = $m_latitude = doubleval($GLOBALS['request']['m_latitude']);
     //ypoint
     $xpoint = $m_longitude = doubleval($GLOBALS['request']['m_longitude']);
     //xpoint
     $city_name = strim($GLOBALS['request']['city_name']);
     //城市名称
     $item = get_deal($id);
     //$item['origin_price_format'] = format_price2($item['origin_price']);
     //$item['current_price_format'] = format_price2($item['current_price']);
     //$item['save_price_format'] = format_price2($item['save_price']);
     $root = getGoodsArray($item);
     //$message_re=m_get_message_list(3," m.rel_table = 'deal' and m.rel_id=".$id." and m.is_buy = 1");/*购买评论*/
     require_once APP_ROOT_PATH . "system/model/review.php";
     require_once APP_ROOT_PATH . "system/model/user.php";
     $message_re = get_dp_list(3, $param = array("deal_id" => $id, "youhui_id" => 0, "event_id" => 0, "location_id" => 0, "tag" => ""), "", "");
     foreach ($message_re['list'] as $k => $v) {
         $message_re['list'][$k]['width'] = $v['point'] / 5 * 100;
         if ($v['point'] > 0) {
             $str = "";
             for ($i = 1; $i <= $v['point']; $i++) {
                 $str .= "★";
             }
             $message_re['list'][$k]['xing'] = $str;
         }
         $message_re['list'][$k]['reply_time_format'] = date("Y-m-d H:i:s", $v['reply_time']);
         $uinfo = load_user($v['user_id']);
         $message_re['list'][$k]['user_name'] = $uinfo['user_name'];
         foreach ($message_re['list'][$k]['images'] as $kk => $vv) {
             $message_re['list'][$k]['images'][$kk] = get_abs_img_root(get_spec_image($vv, 60, 60, 1));
             $message_re['list'][$k]['oimages'][$kk] = get_abs_img_root($vv);
         }
     }
     $root['message_list'] = $message_re['list'];
     if (count($message_re['list']) > 0) {
         $sql = "select count(*) from " . DB_PREFIX . "supplier_location_dp where  " . $message_re['condition'];
         $message_re['count'] = $GLOBALS['db']->getOne($sql);
     }
     $root['message_count'] = $message_re['count'];
     $pi = 3.14159265;
     //圆周率
     $r = 6378137;
     //地球平均半径(米)
     $root['distance'] = ACOS(SIN($ypoint * $pi / 180) * SIN($item['supplier_address_info']['ypoint'] * $pi / 180) + COS($ypoint * $pi / 180) * COS($item['supplier_address_info']['ypoint'] * $pi / 180) * COS($xpoint * $pi / 180 - $item['supplier_address_info']['xpoint'] * $pi / 180)) * $r;
     $root['return'] = 1;
     $images = array();
     //image_attr_1_id_{$attr_1_id} 图片列表,可以根据属性ID值,来切换图片列表
     $sql = "select img from " . DB_PREFIX . "deal_gallery where deal_id = " . intval($id) . " order by sort asc";
     $list = $GLOBALS['db']->getAll($sql);
     $gallery = array();
     $big_gallery = array();
     foreach ($list as $k => $image) {
         $gallery[] = get_abs_img_root(get_spec_image($image['img'], 460, 280, 1));
         $big_gallery[] = get_abs_img_root(get_spec_image($image['img'], 0, 0, 0));
     }
     $root['gallery'] = $gallery;
     $root['big_gallery'] = $big_gallery;
     //支持的门店列表;
     $sql = "select id,name,address,tel,xpoint,ypoint,supplier_id from " . DB_PREFIX . "supplier_location where id in (select location_id from " . DB_PREFIX . "deal_location_link where deal_id = " . $id . ")";
     $supplier_location_list = $GLOBALS['db']->getAll($sql);
     foreach ($supplier_location_list as $k => $sl) {
         $supplier_location_list[$k]['distance'] = ACOS(SIN($ypoint * $pi / 180) * SIN($sl['ypoint'] * $pi / 180) + COS($ypoint * $pi / 180) * COS($sl['ypoint'] * $pi / 180) * COS($xpoint * $pi / 180 - $sl['xpoint'] * $pi / 180)) * $r;
     }
     $root['supplier_location_list'] = $supplier_location_list;
     //其它团购
     //if($GLOBALS['request']['from']=="wap"){
     $time = get_gmtime();
     $time_condition = '  and is_shop = 0 ';
     $time_condition .= ' and (' . $time . '>=begin_time or begin_time = 0 ) and (' . $time . '< end_time or end_time = 0) and buy_type<>2 and is_recommend=1';
     $time_condition .= ' and id<>' . $id;
     /*
     if($item['cate_id']>0)
     {
     	$ids = load_auto_cache("deal_sub_parent_cate_ids",array("cate_id"=>$item['cate_id']));
     	$time_condition .= " and cate_id in (".implode(",",$ids).")";
     
     }
     
     if($item['city_id']==0)
     {
     	$city = get_current_deal_city();
     	$city_id = $city['id'];
     	$time_condition .= " and city_id in (".implode(",",$item['city_id']).")";
     }
     if($item['city_id']>0)
     {
     	$ids = load_auto_cache("deal_city_belone_ids",array("city_id"=>$item['city_id']));
     	if($ids)
     	{
     		$time_condition .= " and city_id in (".implode(",",$ids).")";
     
     	}
     }
     */
     $dealsql = "select * from " . DB_PREFIX . "deal where is_effect = 1 and  is_delete = 0 " . $time_condition . " order by sort desc,id desc limit 4";
     $deal_other = $GLOBALS['db']->getAll($dealsql);
     $root['deal_other'] = $deal_other;
     /*门店评论*/
     /*
     $comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $count_point=0;
     foreach($comment_list as $k=>$v)
     {
     	$comment_list[$k]['avg_price']=round($v['avg_price'],2);
     	$comment_list[$k]['time']=pass_date($v['create_time']);
     	$count_point+=$v['point'];
     }
     $root['comment_list']=$comment_list;
     $score=round($count_point/$comment_count,2);
     $width = $score > 0 ? ($score / 5) * 100 : 0;
     $root['point']=$score;
     $root['width']=$width;
     $root['comment_count']=$comment_count;
     */
     /*商品评论*/
     /*
     $comment_list=$GLOBALS['db']->getAll("select a.id,a.content,a.point,a.avg_price,a.create_time,b.id as user_id,b.user_name from ".DB_PREFIX."deal as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $comment_count=$GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."supplier_location_dp as a left join ".DB_PREFIX."user as b on b.id=a.user_id where a.supplier_location_id = ".$root['supplier_location_id']." and a.status = 1");
     $count_point=0;
     foreach($comment_list as $k=>$v)
     {
     	$comment_list[$k]['avg_price']=round($v['avg_price'],2);
     	$comment_list[$k]['time']=pass_date($v['create_time']);
     	$count_point+=$v['point'];
     }
     $root['comment_list']=$comment_list;
     $score=round($count_point/$comment_count,2);
     $width = $score > 0 ? ($score / 5) * 100 : 0;
     $root['point']=$score;
     $root['width']=$width;
     $root['comment_count']=$comment_count;
     */
     //购买点评数量
     $comment_count = $root['message_count'];
     // intval($GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."message where rel_id = ".$id." and rel_table = 'deal' and pid = 0 and is_buy = 1"));
     $buy_dp_sum = 0.0;
     $buy_dp_group = $GLOBALS['db']->getAll("select point,count(*) as num from " . DB_PREFIX . "message where rel_id = " . $id . " and rel_table = 'deal' and pid = 0 and is_buy = 1 group by point");
     foreach ($buy_dp_group as $dp_k => $dp_v) {
         $star = intval($dp_v['point']);
         if ($star >= 1 && $star <= 5) {
             $buy_dp_sum += $star * $dp_v['num'];
         }
     }
     //点评平均分
     $score = round($buy_dp_sum / $comment_count, 1);
     $width = $score > 0 ? $score / 5 * 110 : 0;
     $root['point'] = $score;
     $root['width'] = $width;
     /*
     $root['comment_count']=$comment_count;
     
     $sql = "select m.id,m.content,m.create_time,m.update_time, m.point,m.admin_reply,m.admin_id,u.user_name from ".DB_PREFIX."message m left join fanwe_user u on u.id = m.user_id where m.rel_id = ".$id." and m.rel_table = 'deal' and m.pid = 0 and m.is_buy = 1  order by m.create_time desc limit 0,8";
     $comment_list = $GLOBALS['db']->getAll($sql);			
     $root['comment_list']=$comment_list;
     */
     if ($item['is_shop'] == 0) {
         $root['page_title'] = "团购详情";
     } elseif ($item['is_shop'] == 1) {
         $root['page_title'] = "商品详情";
     } else {
         $root['page_title'] = "代金券详情";
     }
     //}
     $root['is_collect'] = $is_collect;
     $root['city_name'] = $city_name;
     output($root);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
 public function index()
 {
     require_once APP_ROOT_PATH . 'app/Lib/youhui_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;
     $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 . "%') ";
     }
     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 ";
     } else {
         $field_append = "";
         $order = " sort desc ";
     }
     $deals = m_search_youhui_list($limit, intval($catalog_id), $condition, $order, $city_id, $field_append);
     //		$deals = get_goods_list($limit,$catalog_id,"","sort 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);
         $goods['distance'] = round($goods['distance']);
         $goodses[] = $goods;
     }
     $root['item'] = $goodses;
     $root['page'] = array("page" => $page, "page_total" => $page_total);
     output($root);
 }