|
@@ -15,12 +15,16 @@ class Info
|
|
}
|
|
}
|
|
|
|
|
|
# 获取店铺基本信息
|
|
# 获取店铺基本信息
|
|
- public function get($city, $lng, $lat, $name = '', $method = 'fetch', $shop_id = false)
|
|
|
|
|
|
+ public function get($city, $lng, $lat, $name = '', $method = 'fetch', $shop_id = false, $address = false)
|
|
{
|
|
{
|
|
if (!$city) {
|
|
if (!$city) {
|
|
Dever::alert('请传入城市');
|
|
Dever::alert('请传入城市');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ((!$lng || !$lat) && $address) {
|
|
|
|
+ list($lng, $lat) = Dever::load('shop/lib/info')->geo($city, $address);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!$lng || !$lat) {
|
|
if (!$lng || !$lat) {
|
|
$city_info = Dever::db('area/city')->find($city);
|
|
$city_info = Dever::db('area/city')->find($city);
|
|
list($lng, $lat) = Dever::load('shop/lib/info')->geo($city, $city_info['name']);
|
|
list($lng, $lat) = Dever::load('shop/lib/info')->geo($city, $city_info['name']);
|
|
@@ -157,7 +161,7 @@ class Info
|
|
}
|
|
}
|
|
|
|
|
|
# 获取距离
|
|
# 获取距离
|
|
- private function fetch($id, $city, $lng, $lat, $type = 1, $name = '', $method = 'fetch')
|
|
|
|
|
|
+ public function fetch($id, $city, $lng, $lat, $type = 1, $name = '', $method = 'fetch')
|
|
{
|
|
{
|
|
$page = array();
|
|
$page = array();
|
|
if ($method == 'fetchAll') {
|
|
if ($method == 'fetchAll') {
|
|
@@ -167,15 +171,22 @@ class Info
|
|
$page = false;
|
|
$page = false;
|
|
}
|
|
}
|
|
|
|
|
|
- $where = 'type = '.$type.' and status = 1 and state = 1';
|
|
|
|
|
|
+ $where = 'status = 1 and state = 1';
|
|
|
|
|
|
- $county = Dever::db('area/county')->find($city);
|
|
|
|
- if ($county) {
|
|
|
|
- $city = $county['city_id'];
|
|
|
|
|
|
+ if ($type) {
|
|
|
|
+ $where .= ' and type = ' . $type;
|
|
}
|
|
}
|
|
- if ($type == 1 && $city) {
|
|
|
|
- $where .= ' and city = ' . $city;
|
|
|
|
|
|
+
|
|
|
|
+ if ($city) {
|
|
|
|
+ $county = Dever::db('area/county')->find($city);
|
|
|
|
+ if ($county) {
|
|
|
|
+ $city = $county['city_id'];
|
|
|
|
+ }
|
|
|
|
+ if ($type == 1 && $city) {
|
|
|
|
+ $where .= ' and city = ' . $city;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
if ($name) {
|
|
if ($name) {
|
|
$where .= ' and name like("%'.$name.'%")';
|
|
$where .= ' and name like("%'.$name.'%")';
|
|
}
|
|
}
|
|
@@ -183,7 +194,7 @@ class Info
|
|
$where .= ' and id = ' . $id;
|
|
$where .= ' and id = ' . $id;
|
|
}
|
|
}
|
|
if ($lng && $lat) {
|
|
if ($lng && $lat) {
|
|
- $sql = 'select id,name,`desc`,truename,mobile,lng,lat,address,open,worktime,method,gotime,pdesc,round((st_distance(point(lng, lat), point('.$lng.', '.$lat.'))*111195)/1000, 2) as distance from {table} where '.$where.' order by distance asc';
|
|
|
|
|
|
+ $sql = 'select id,name,`desc`,truename,mobile,lng,lat,address,open,worktime,method,gotime,city,area,province,county,town,coupon_city,pdesc,license,food_license,jy_license,license_number,company_name,round((st_distance(point(lng, lat), point('.$lng.', '.$lat.'))*111195)/1000, 2) as distance from {table} where '.$where.' order by distance asc';
|
|
|
|
|
|
$data = Dever::db('shop/info')->$method($sql, array(), $page);
|
|
$data = Dever::db('shop/info')->$method($sql, array(), $page);
|
|
} else {
|
|
} else {
|