Пример #1
0
 public function get_condition()
 {
     $condition = '';
     if ($this->input['sort_id']) {
         $condition .= " AND r.group_id =" . intval($this->input['sort_id']);
     }
     if ($this->input['wd'] || $this->input['jd']) {
         $distance = $this->input['distance'] ? intval($this->input['distance']) : 10;
         $jwd = hg_jwd_square(intval($this->input['wd']), intval($this->input['jd']), $distance);
         $condition .= " AND r.baidu_latitude >=" . $jwd['wd']['min'] . " AND r.baidu_latitude <= " . $jwd['wd']['max'];
         $condition .= " AND r.baidu_longitude >=" . $jwd['jd']['min'] . " AND r.baidu_longitude <= " . $jwd['jd']['max'];
     }
     if ($this->settings['jwd']['wd']) {
         $condition .= " AND r.baidu_latitude >=" . $this->settings['jwd']['wd']['min'] . " AND r.baidu_latitude <= " . $this->settings['jwd']['wd']['max'];
     }
     if ($this->settings['jwd']['jd']) {
         $condition .= " AND r.baidu_longitude >=" . $this->settings['jwd']['jd']['min'] . " AND r.baidu_longitude <= " . $this->settings['jwd']['jd']['max'];
     }
     if ($is_hot = $this->input['is_hot']) {
         $condition .= " AND r.is_hot =1";
     }
     if ($area = $this->input['area']) {
         $condition .= " AND ra.aid in(" . $area . ")";
     }
     //查询排序方式(升序或降序,默认为降序)
     $hgupdown .= $this->input['descasc'] ? $this->input['descasc'] : ' DESC ';
     //根据时间,order_id 和 istop字段排序,istop字段优先级高 create_time<orderid
     $condition .= " ORDER BY (r.create_time + r.effect_time * 60) " . $hgupdown . ",r.orderid " . $hgupdown;
     return $condition;
 }
Пример #2
0
 public function get_subway_site()
 {
     $offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0;
     $count = $this->input['count'] ? intval(urldecode($this->input['count'])) : 100;
     $limit = " limit {$offset}, {$count}";
     $info = $subway = array();
     $condition = '';
     // $this->input['title'] = '迈皋桥';
     if ($this->input['title']) {
         $condition .= ' AND  a.title  LIKE "%' . trim($this->input['title']) . '%"';
     }
     //$this->input['longitude'] =	'118.810206';
     //$this->input['latitude'] = '32.102944';
     if ($this->input['longitude'] && $this->input['latitude']) {
         $info = array('longitude' => $this->input['longitude'], 'latitude' => $this->input['latitude']);
     } else {
         if ($this->input['x'] && $this->input['y']) {
             $gps = $this->subway->GpsToBaidu($this->input['x'], $this->input['y']);
             $info = array('longitude' => $gps['x'], 'latitude' => $gps['y']);
         }
     }
     if ($info['latitude'] && $info['longitude']) {
         $distance = $this->input['distance'] ? intval($this->input['distance']) : DISTANCE;
         $jwd = hg_jwd_square(intval($info['latitude']), intval($info['longitude']), $distance);
         //$condition .= ' AND  latitude >='. $jwd['wd']['min'] .' AND  latitude <='. $jwd['wd']['max'] ;
         //$condition .= ' AND  longitude >='. $jwd['jd']['min'] .' AND  longitude <='. $jwd['jd']['max'] ;
     }
     $limit = '';
     $subway = $this->subway->get_subway_sites($condition, $limit, $info);
     if (is_array($subway)) {
         foreach ($subway as $k => $v) {
             $this->addItem($v);
         }
         $this->output();
     }
 }
Пример #3
0
 public function get_condition()
 {
     $condition = '';
     if ($this->input['market_id']) {
         $condition .= " AND ms.market_id IN (" . $this->input['market_id'] . ")";
     }
     //根据坐标来查询(算出最近的商超即在一定距离范围内)注:传过来的是GPS坐标
     if ($this->input['wd'] || $this->input['jd']) {
         $distance = $this->input['distance'] ? intval($this->input['distance']) : 10;
         $jwd = hg_jwd_square($this->input['wd'], $this->input['jd'], $distance);
         $condition .= " AND ms.gps_y >=" . $jwd['wd']['min'] . " AND ms.gps_y <= " . $jwd['wd']['max'];
         $condition .= " AND ms.gps_x >=" . $jwd['jd']['min'] . " AND ms.gps_x <= " . $jwd['jd']['max'];
     }
     if ($this->input['id']) {
         $condition .= " AND ms.id IN (" . $this->input['id'] . ")";
     }
     if ($this->input['k'] || trim($this->input['k']) == '0') {
         $condition .= ' AND  ms.name  LIKE "%' . trim($this->input['k']) . '%"';
     }
     if ($this->input['start_time']) {
         $start_time = strtotime(trim($this->input['start_time']));
         $condition .= " AND ms.create_time >= '" . $start_time . "'";
     }
     if ($this->input['end_time']) {
         $end_time = strtotime(trim($this->input['end_time']));
         $condition .= " AND ms.create_time <= '" . $end_time . "'";
     }
     //权重
     if ($this->input['start_weight'] && $this->input['start_weight'] != -1) {
         $condition .= " AND ms.weight >=" . $this->input['start_weight'];
     }
     if ($this->input['end_weight'] && $this->input['end_weight'] != -2) {
         $condition .= " AND ms.weight <= " . $this->input['end_weight'];
     }
     if ($this->input['date_search']) {
         $today = strtotime(date('Y-m-d'));
         $tomorrow = strtotime(date('y-m-d', TIMENOW + 24 * 3600));
         switch (intval($this->input['date_search'])) {
             case 1:
                 //所有时间段
                 break;
             case 2:
                 //昨天的数据
                 $yesterday = strtotime(date('y-m-d', TIMENOW - 24 * 3600));
                 $condition .= " AND  ms.create_time > '" . $yesterday . "' AND ms.create_time < '" . $today . "'";
                 break;
             case 3:
                 //今天的数据
                 $condition .= " AND  ms.create_time > '" . $today . "' AND ms.create_time < '" . $tomorrow . "'";
                 break;
             case 4:
                 //最近3天
                 $last_threeday = strtotime(date('y-m-d', TIMENOW - 2 * 24 * 3600));
                 $condition .= " AND  ms.create_time > '" . $last_threeday . "' AND ms.create_time < '" . $tomorrow . "'";
                 break;
             case 5:
                 //最近7天
                 $last_sevenday = strtotime(date('y-m-d', TIMENOW - 6 * 24 * 3600));
                 $condition .= " AND  ms.create_time > '" . $last_sevenday . "' AND ms.create_time < '" . $tomorrow . "'";
                 break;
             default:
                 //所有时间段
                 break;
         }
     }
     return $condition;
 }
Пример #4
0
 public function get_condition()
 {
     $condition = '';
     //站点名称
     if ($this->input['name']) {
         $condition .= ' AND c.name LIKE "%' . trim($this->input['name']) . '%"';
     }
     if ($this->input['id']) {
         $condition .= " AND c.id =" . intval($this->input['id']);
     }
     //根据区域查询
     if ($this->input['district_id']) {
         $condition .= " AND c.district_id =" . intval($this->input['district_id']);
     }
     //根据分类id查询
     if ($this->input['type_id']) {
         $condition .= " AND c.type_id = " . intval($this->input['type_id']);
     }
     //根据坐标来查询(算出最近的停车场即在一定距离范围内)注:传过来的是GPS坐标,库里面存的是百度坐标,所以要转换
     if ($this->input['wd'] || $this->input['jd']) {
         $distance = $this->input['distance'] ? intval($this->input['distance']) : 10;
         $jwd = hg_jwd_square(intval($this->input['wd']), intval($this->input['jd']), $distance);
         $condition .= " AND c.GPS_y  >=" . $jwd['wd']['min'] . " AND c.GPS_y  <= " . $jwd['wd']['max'];
         $condition .= " AND c.GPS_x >=" . $jwd['jd']['min'] . " AND c.GPS_x <= " . $jwd['jd']['max'];
     }
     $condition .= " AND c.status = 2";
     return $condition;
 }