public function get_list($lat, $long, $page, $pagesize, $activity_type)
 {
     $where = array("status" => 0, "invite_time" => array("gt", time()));
     if ($activity_type !== false) {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.activity_type=" . $activity_type . " AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
         $where["activity_type"] = intval($activity_type);
     } else {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.status=0 AND i.invite_time>" . time() . " ORDER BY i.pigcms_id DESC, u.sex DESC";
     }
     $start = ($page - 1) * $pagesize;
     $count = $this->where($where)->count();
     $sql .= " limit {$start}, {$pagesize}";
     $mode = new Model();
     $res = $mode->query($sql);
     $today = strtotime(date("Y-m-d")) + 86400;
     $tomorrow = $today + 86400;
     $lastday = $tomorrow + 86400;
     foreach ($res as &$v) {
         $v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
         $v["juli"] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($lat * PI() / 180 - $v["lat"] * PI() / 180) / 2), 2) + COS($lat * PI() / 180) * COS($v["lat"] * PI() / 180) * POW(SIN(($long * PI() / 180 - $v["long"] * PI() / 180) / 2), 2))) * 1000);
         $v["juli"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
         $v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天  " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天  " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
         $v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
         $v["age"] = 100 < $v["age"] || $v["age"] < 0 ? "保密" : $v["age"] . "岁";
     }
     return array("data" => $res, "total" => $count);
 }
Example #2
0
 public function news($lat, $lon)
 {
     $return = array();
     $where = array();
     $where['token'] = $this->token;
     $where['latitude'] = array('gt', '0');
     $news2 = M('Img')->where($where)->order('ACOS(SIN((' . $lat . ' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS((' . $lat . ' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS((' . $lon . ' * 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 ASC')->limit(10)->select();
     if (!$news2) {
         return array('没有对应的图文消息', 'text');
     }
     $ids = array();
     //img库中查出图文消息
     foreach ($news2 as $keya => $infot) {
         //distance KM
         $distance = ACOS(SIN($lat * 3.1415 / 180) * SIN($infot['latitude'] * 3.1415 / 180) + COS($lat * 3.1415 / 180) * COS($infot['latitude'] * 3.1415 / 180) * COS($lon * 3.1415 / 180 - $infot['longitude'] * 3.1415 / 180)) * 6380;
         //
         if ($infot['url'] != false) {
             //处理外链
             if (!(strpos($infot['url'], 'http') === FALSE)) {
                 $url = $this->getFuncLink(html_entity_decode($infot['url']));
             } else {
                 //内部模块的外链
                 $url = $this->getFuncLink($infot['url']);
             }
         } else {
             $url = rtrim($this->siteUrl, '/') . U('Wap/Index/content', array('token' => $this->token, 'id' => $infot['id'], 'wecha_id' => $this->wecha_id));
         }
         array_push($ids, $news2['id']);
         $return[] = array($infot['title'], $this->handleIntro($infot['text']), $infot['pic'], $url);
     }
     //点击数处理
     if ($back) {
         M('Img')->where(array('id' => array('in', $ids)))->setInc('click');
     }
     return array($return, 'news');
 }
Example #3
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);
 }
 public function mysign()
 {
     $invitation_signs = D("Invitation_sign")->field("invid")->where(array("uid" => $this->user_session["uid"]))->order("invid DESC")->select();
     $invids = $pre = "";
     foreach ($invitation_signs as $is) {
         $invids .= $pre . $is["invid"];
         $pre = ",";
     }
     $today = strtotime(date("Y-m-d")) + 86400;
     $tomorrow = $today + 86400;
     $lastday = $tomorrow + 86400;
     if ($invids) {
         $sql = "SELECT i.*, u.* FROM " . C("DB_PREFIX") . "user as u INNER JOIN " . C("DB_PREFIX") . "invitation as i ON i.uid=u.uid WHERE i.pigcms_id IN ({$invids}) ORDER BY i.pigcms_id DESC, u.sex DESC";
         $mode = new Model();
         $res = $mode->query($sql);
         foreach ($res as &$v) {
             $v["_time"] = date("Y-m-d H:i", $v["invite_time"]);
             $v["juli"] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($this->_lat * PI() / 180 - $v["lat"] * PI() / 180) / 2), 2) + COS($this->_lat * PI() / 180) * COS($v["lat"] * PI() / 180) * POW(SIN(($this->_long * PI() / 180 - $v["long"] * PI() / 180) / 2), 2))) * 1000);
             $v["juli"] = 1000 < $v["juli"] ? number_format($v["juli"] / 1000, 1) . "km" : ($v["juli"] < 100 ? "<100m" : $v["juli"] . "m");
             $v["invite_time"] = $v["invite_time"] < $today ? "今天 " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $tomorrow ? "明天  " . date("H:i", $v["invite_time"]) : ($v["invite_time"] < $lastday ? "后天  " . date("H:i", $v["invite_time"]) : date("m-d H:i", $v["invite_time"])));
             $v["birthday"] && ($v["age"] = date("Y") - date("Y", strtotime($v["birthday"])));
         }
         $this->assign("date_list", $res);
     }
     $this->display();
 }
 public function wap_get_store_list_by_catid($cat_id, $area_id, $order, $lat, $long, $cat_url)
 {
     $stores = D('Store_category')->field('store_id')->where("cat_id='{$cat_id}'")->select();
     foreach ($stores as $s) {
         $store_ids[] = $s['store_id'];
     }
     $store_ids && ($where['store_id'] = array('in', $store_ids));
     if ($cat_url == 'dianying' && empty($store_ids)) {
         return false;
     }
     // 		$where['have_meal'] = 1;
     $where['status'] = 1;
     $area_id && ($where['area_id'] = $area_id);
     $count = D('Merchant_store')->where($where)->count();
     //排序
     switch ($order) {
         case 'distance':
             $order = "ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat} * PI() / 180- `lat` * PI()/180)/2),2)+COS({$lat} *PI()/180)*COS(`lat`*PI()/180)*POW(SIN(({$long} *PI()/180- `long`*PI()/180)/2),2)))*1000) ASC";
             //'`g`.`price` ASC,`g`.`group_id` DESC';
             break;
             // 			case 'priceDesc':
             // 				$order = '`g`.`price` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'solds':
             // 				$order = '`g`.`sale_count` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'rating':
             // 				$order = '`g`.`score_mean` DESC,`g`.`group_id` DESC';
             // 				break;
             // 			case 'start':
             // 				$order = '`g`.`last_time` DESC,`g`.`group_id` DESC';
             // 				break;
         // 			case 'priceDesc':
         // 				$order = '`g`.`price` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'solds':
         // 				$order = '`g`.`sale_count` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'rating':
         // 				$order = '`g`.`score_mean` DESC,`g`.`group_id` DESC';
         // 				break;
         // 			case 'start':
         // 				$order = '`g`.`last_time` DESC,`g`.`group_id` DESC';
         // 				break;
         default:
             $order = '`store_id` DESC';
     }
     import('@.ORG.wap_group_page');
     $p = new Page($count, C('config.group_page_row'), C('config.group_page_val'));
     $list = D('Merchant_store')->field(true)->where($where)->order($order)->limit($p->firstRow . ',' . $p->listRows)->select();
     // 		echo D('Merchant_store')->_sql();
     $return['pagebar'] = $p->show();
     if ($list) {
         $store_image_class = new store_image();
         foreach ($list as &$v) {
             $images = $store_image_class->get_allImage_by_path($v['pic_info']);
             $v['image'] = $images ? array_shift($images) : '';
             $v['juli'] = ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(($lat * PI() / 180 - $v['lat'] * PI() / 180) / 2), 2) + COS($lat * PI() / 180) * COS($v['lat'] * PI() / 180) * POW(SIN(($long * PI() / 180 - $v['long'] * PI() / 180) / 2), 2))) * 1000);
             $v['juli'] = $v['juli'] > 1000 ? number_format($v['juli'] / 1000, 1) . 'km' : ($v['juli'] < 100 ? '<100m' : $v['juli'] . 'm');
         }
     }
     $return['store_list'] = $list;
     return $return;
 }
Example #6
0
	public function nearest($lat,$lon){
		$company_model=M('Company');
		$where=array('token'=>$this->token);
		$allcompanies=$company_model->where($where)->order('isbranch ASC,taxis ASC')->select();
		$companies=$company_model->where($where)->order('ACOS(SIN(('.$lat.' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS(('.$lat.' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(('.$lon.' * 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 ASC')->limit(1)->select();
		$nearestCompany=$companies[0];
		$distance=ACOS(SIN(($lat * 3.1415) / 180 ) *SIN(($infot['latitude'] * 3.1415) / 180 ) +COS(($lat * 3.1415) / 180 ) * COS(($infot['latitude'] * 3.1415) / 180 ) *COS(($lon * 3.1415) / 180 - ($infot['longitude'] * 3.1415) / 180 ) ) * 6380;
		$distance=$distance*1000;
		$distanceStr=$this->_getDistance($ldistance);
		$i=1;
		if ($allcompanies){
			foreach ($allcompanies as $ac){
				$i++;
				if ($ac['id']==$nearestCompany['id']){
					$index=$i;
					break;
				}
			}
			if (!$this->isamap){
				$imgUrl='http://api.map.baidu.com/staticimage?center='.$nearestCompany['longitude'].','.$nearestCompany['latitude'];
				$return[]=array('最近的是'.$nearestCompany['name'].',大约'.$distanceStr,"回复“步行去".$index."”“坐公交".$index."”或“开车去".$index."”获取详细路线图",$imgUrl,C('site_url').'/index.php?g=Wap&m=Company&a=map&companyid='.$nearestCompany['id'].'&token='.$this->token);
			}else {
				$amap=$this->amap;
				$imgUrl=$amap->staticMap($nearestCompany['longitude'],$nearestCompany['latitude'],$nearestCompany['name'],360,200);
				$link=$amap->getPointMapLink($nearestCompany['longitude'],$nearestCompany['latitude'],$nearestCompany['name']);
				$return[]=array('最近的是'.$nearestCompany['name'].',大约'.$distanceStr,"点击查看导航信息",$imgUrl,$link);
			}
			return array($return,'news');
		}else {
			return array('还没配置公司信息呢','text');
		}
		/*
		if (!$this->isamap){
			//
			$company_model=M('Company');
			$where=array('token'=>$this->token);
			$companies=$company_model->where($where)->order('isbranch ASC,taxis ASC')->select();
			$ldistance=0;
			$nearestCompany=array();
			$i=1;
			$index=0;
			$j=0;
			if ($companies){
				foreach ($companies as $c){
					$furl='http://api.map.baidu.com/direction/v1?region=&mode=driving&origin='.$x.','.$y.'&destination='.$c['latitude'].','.$c['longitude'].'&output=json&ak='.$this->apikey;
					//file_put_contents('s.html',$furl."\r\n".file_get_contents('s.html'));

					$json=file_get_contents($furl);
					$rt=json_decode($json,true);


					if (is_array($rt)){
						//长度
						$distance=$rt['result']['routes'][0]['distance'];
						if ($ldistance==0){
							$nearestCompany=$c;
							$ldistance=$distance;
							$index=1;
						}else {
							if ($distance<$ldistance){
								$nearestCompany=$c;
								$ldistance=$distance;
								$index=$j+1;
							}
						}

					}else {

					}
					$j++;
				}
				//
				$distanceStr=$this->_getDistance($ldistance);
				//$imgUrl='http://api.map.baidu.com/staticimage?center='.$nearestCompany['longitude'].','.$nearestCompany['latitude'].'&width=640&height=320&zoom=13&markers='.$nearestCompany['longitude'].','.$nearestCompany['latitude'];
				$imgUrl='http://api.map.baidu.com/staticimage?center='.$nearestCompany['longitude'].','.$nearestCompany['latitude'];
				$return[]=array('最近的是'.$nearestCompany['name'].',大约'.$distanceStr,"回复“步行去".$index."”“坐公交".$index."”或“开车去".$index."”获取详细路线图",$imgUrl,C('site_url').'/index.php?g=Wap&m=Company&a=map&companyid='.$nearestCompany['id'].'&token='.$this->token);
				return array($return,'news');
			}else {
				return array('还没配置公司信息呢,您稍等','text');
			}
		}else {
		}
		*/
	}
Example #7
0
 /**
  * The distance between two points, given longitude and latitude coordinates
  * @param float $lat1 latitude first point
  * @param float $lon1 longitude first point
  * @param float $lat2 latitude second point
  * @param float $lon2 longitude second point
  * @return float distance between two points
  */
 public static function getDistance($lat1, $lon1, $lat2, $lon2)
 {
     return acos(sin(deg2rad($lat1)) * SIN(deg2rad($lat2)) + COS(deg2rad($lat1)) * COS(deg2rad($lat2)) * COS(deg2rad($lon2 - $lon1))) * self::EARTH_RADIUS_KM;
 }
Example #8
0
 static function gps_distance($lon1, $lat1, $lon2, $lat2)
 {
     return 2 * ATAN2(SQRT(SIN(($lat1 - $lat2) * PI() / 180 / 2) * SIN(($lat1 - $lat2) * PI() / 180 / 2) + COS($lat2 * PI() / 180) * COS($lat1 * PI() / 180) * SIN(($lon1 - $lon2) * PI() / 180 / 2) * SIN(($lon1 - $lon2) * PI() / 180 / 2)), SQRT(1 - SIN(($lat1 - $lat2) * PI() / 180 / 2) * SIN(($lat1 - $lat2) * PI() / 180 / 2) + COS($lat2 * PI() / 180) * COS($lat1 * PI() / 180) * SIN(($lon1 - $lon2) * PI() / 180 / 2) * SIN(($lon1 - $lon2) * PI() / 180 / 2))) * 6378140;
 }