瀏覽代碼

动态附近,只要100km内的

lizhen_gitee 1 年之前
父節點
當前提交
07be3e9423
共有 1 個文件被更改,包括 8 次插入3 次删除
  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']);