Browse Source

动态附近,只要100km内的

lizhen_gitee 1 year ago
parent
commit
07be3e9423
1 changed files with 8 additions and 3 deletions
  1. 8 3
      application/api/controller/Topicdongtai.php

+ 8 - 3
application/api/controller/Topicdongtai.php

@@ -266,8 +266,10 @@ class Topicdongtai extends Api
 
 
         //附近,根据距离排序
+        $having_dis = '';
         if($order == 'near'){
-            $where['dt.provincename'] = $this->auth->provincename;
+//            $where['dt.provincename'] = $this->auth->provincename;
+            $having_dis = 'distance < ' . 100000; //100公里范围
             $orderby  = 'dt.toptime desc,distance asc';
         }
 
@@ -302,8 +304,11 @@ class Topicdongtai extends Api
             ->where($where)
             ->where($where_exp)
             ->where($where_follow)
-            ->where($where_black)
-            ->order($orderby)
+            ->where($where_black);
+        if($order == 'near'){
+            $list = $list->having($having_dis);
+        }
+        $list = $list->order($orderby)
             ->autopage()->select();
         $list = list_domain_image($list,['images','audio_file','avatar']);