shq1016 преди 6 години
родител
ревизия
acd0f423e9
променени са 1 файла, в които са добавени 39 реда и са изтрити 16 реда
  1. 39 16
      app/admin/controller/MessageController.php

+ 39 - 16
app/admin/controller/MessageController.php

@@ -45,7 +45,7 @@ class MessageController extends AdminBaseController{
             $users = Db::name('user')->where('id','gt',1)->select();
             $this->assign('users',$users);
             //超级管理员
-            $lists = Db::name('message')->where($map)->order('id desc')->paginate(20,false,['query'=>$query]);
+            $lists = Db::name('message')->where($map)->order('create_time desc')->paginate(20,false,['query'=>$query]);
             $this->assign('lists',$lists);
 
 
@@ -79,29 +79,19 @@ class MessageController extends AdminBaseController{
                         ->alias('p1')
                         ->leftJoin('mobile_log p2','p1.`id`=p2.`msg_id`')
                         ->group('p1.`id`')
-                        ->order('p1.id','desc')
+                        ->order('p1.create_time','asc')
                         ->field($field)->where('p1.catid','in',$cates)->where($map2)->limit(0,$from)->select();
 
                 }else{
 
                     $field=['*'];
-                     $lists = Db::name('message')->field($field)->where('catid','in',$cates)->where($map)->order('id','desc')->limit(0,$from)->select();
-                }
-
-
+                     $lists = Db::name('message')->field($field)->where('catid','in',$cates)->where($map)->order('create_time','asc')->limit(0,$from)->select();
 
-              //  $lists = Db::name('message')->field($field)->where('catid','in',$cates)->where($map)->order('id')->limit(0,$from)->select();
 
-            //ppppp
-            	// if($from<20){
-            	// 	$lists = Db::name('message')->where('catid','in',$cates)->where($map)->order('id desc')->limit(0,$from)->select();
-
-            	// }else{
-            	// 	$curinfo = Db::name('message')->where('catid','in',$cates)->where($map)->order('id desc')->limit($from,1)->find();
+                }
 
-	            //     $curid = $curinfo['id'];
-	            //     $lists = Db::name('message')->where('catid','in',$cates)->where($map)->where('id','>',$curid)->order('id desc')->select;
-            	// }
+                $lists=$this->array_fan($lists);
+                array_multisort(array_column($lists,'create_time'), SORT_DESC, $lists);
 
             }
             $this->assign('fenpei',$fenpei);
@@ -110,6 +100,39 @@ class MessageController extends AdminBaseController{
         return $this->fetch();
     }
 
+
+    //把二维数组反转
+    public function array_fan($arr)
+    {
+
+        $data=array();
+        if(!empty($arr))
+        {
+            $num= count($arr);
+            $j=0;
+            $data=array();
+            for($i=$num-1;$i>=0;$i--)
+            {
+                $data[$i]=$arr[$j];
+                $j++;
+
+            }
+
+        }
+
+    return $data;
+
+
+    }
+
+
+    /***
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
     public function tomobile()
     {