|
@@ -6,6 +6,14 @@ use Dever;
|
|
|
|
|
|
class Info
|
|
|
{
|
|
|
+ # 获取店铺基本信息
|
|
|
+ public function getOne($shop_id, $lng, $lat)
|
|
|
+ {
|
|
|
+ $shop = $this->fetch($shop_id, false, $lng, $lat);
|
|
|
+
|
|
|
+ return $shop;
|
|
|
+ }
|
|
|
+
|
|
|
# 获取店铺基本信息
|
|
|
public function get($city, $lng, $lat, $name = '', $method = 'fetch', $shop_id = false)
|
|
|
{
|
|
@@ -17,11 +25,11 @@ class Info
|
|
|
Dever::alert('请传入用户坐标');
|
|
|
}
|
|
|
|
|
|
- $data = $this->fetch($city, $lng, $lat, 1, $name, $method);
|
|
|
+ $data = $this->fetch(false, $city, $lng, $lat, 1, $name, $method);
|
|
|
|
|
|
# 验证本城市内有没有店
|
|
|
if (!$data) {
|
|
|
- $data = $this->fetch($city, $lng, $lat, 2, $name, $method);
|
|
|
+ $data = $this->fetch(false, $city, $lng, $lat, 2, $name, $method);
|
|
|
}
|
|
|
|
|
|
if ($data) {
|
|
@@ -100,7 +108,7 @@ class Info
|
|
|
}
|
|
|
|
|
|
# 获取距离
|
|
|
- private function fetch($city, $lng, $lat, $type = 1, $name = '', $method = 'fetch')
|
|
|
+ private function fetch($id, $city, $lng, $lat, $type = 1, $name = '', $method = 'fetch')
|
|
|
{
|
|
|
$page = array();
|
|
|
if ($method == 'fetchAll') {
|
|
@@ -112,12 +120,15 @@ class Info
|
|
|
|
|
|
$where = 'type = '.$type.' and status = 1 and state = 1';
|
|
|
|
|
|
- if ($type == 1) {
|
|
|
+ if ($type == 1 && $city) {
|
|
|
$where .= ' and city = ' . $city;
|
|
|
}
|
|
|
if ($name) {
|
|
|
$where .= ' and name like("%'.$name.'%")';
|
|
|
}
|
|
|
+ if ($id) {
|
|
|
+ $where .= ' and id = ' . $id;
|
|
|
+ }
|
|
|
$sql = 'select id,name,`desc`,truename,mobile,lng,lat,address,open,worktime,method,gotime,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);
|