diff --git a/app/common/controller/ImController.php b/app/common/controller/ImController.php index b2c37e842..b67463aa9 100644 --- a/app/common/controller/ImController.php +++ b/app/common/controller/ImController.php @@ -327,12 +327,12 @@ class ImController extends BaseLikeAdminController //获取消息 $msg_no_read = UserImMessage::field('id')->where('from_user_id',$item['id'])->where('to_user_id',$params['user_id'])->where('is_read',0)->count(); $last_msg = UserImMessage::field('id,content,create_time')->where('from_user_id',$item['id'])->where('to_user_id',$params['user_id'])->where('is_read',0)->order('create_time desc')->limit(1)->findOrEmpty(); - $item['mag'] = [ - 'no_read_num' => $msg_no_read, - 'last_msg_content' => $last_msg['content'], - 'last_msg_time' => $last_msg['create_time'], - ]; + $item['no_read_num'] = $msg_no_read; + $item['last_msg_content'] = $last_msg['content']; + $item['last_msg_time'] = $last_msg['create_time']; })->toArray(); + $key = array_column($users,'last_msg_time'); + array_multisort($key,SORT_DESC,$users); //返回数据 return $this->success('请求成功',$users); }