dever 3 éve
szülő
commit
db511f98c6
3 módosított fájl, 21 hozzáadás és 5 törlés
  1. 2 1
      app/shop/database/info.php
  2. 15 4
      app/shop/lib/Info.php
  3. 4 0
      app/shop/src/Main.php

+ 2 - 1
app/shop/database/info.php

@@ -521,11 +521,12 @@ return array
             'option' => array
             (
                 'city' => 'yes',
+                'id' => 'yes',
                 'status' => 1,
                 'state' => 1,
             ),
             'type' => 'one',
-            'col' => '*',
+            'col' => 'id,name,`desc`,truename,mobile,lng,lat,address,open,worktime,method,gotime',
         ),
     ),
 );

+ 15 - 4
app/shop/lib/Info.php

@@ -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);

+ 4 - 0
app/shop/src/Main.php

@@ -123,10 +123,14 @@ class Main extends Core
     public function getGoods()
     {
         $shop_id = Dever::input('shop_id');
+        $lng = Dever::input('lng');
+        $lat = Dever::input('lat');
 
         $column = Dever::db('goods/column')->select();
 
         $data = array();
+
+        $data['shop'] = Dever::load('shop/lib/info')->getOne($shop_id, $lng, $lat);
         if ($column) {
             foreach ($column as $k => $v) {
                 $v['data'] = Dever::load('shop/lib/info')->getGoods($shop_id, 3, $v['id']);