From 08439964698d018e2d3e8471c7f270a96969048b Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 8 Oct 2026 16:38:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=AE=89=E5=85=A8=E5=86=99=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/application/api/controller/Message.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/application/api/controller/Message.php b/backend/application/api/controller/Message.php index 9dd2169..406d00a 100644 --- a/backend/application/api/controller/Message.php +++ b/backend/application/api/controller/Message.php @@ -29,10 +29,14 @@ class Message extends Api } //总未读数(兼容旧字段)+ 分类未读数(前端tab角标用) $unreadCount = MessageService::where($where + ['is_read' => CommonService::STATUS_OFF])->count(); + //where() 走的是 Query 对象,select() 返回普通数组而非 Collection,需兼容处理 $unreadList = MessageService::where(['to_user_id' => $user_id, 'is_read' => CommonService::STATUS_OFF]) ->field('message_type, count(*) as total') ->group('message_type') - ->select()->toArray(); + ->select(); + $unreadList = is_object($unreadList) && method_exists($unreadList, 'toArray') + ? $unreadList->toArray() + : (array)$unreadList; $unreadMap = [ MessageService::TYPE_SYSTEM => 0, MessageService::TYPE_NOTICE => 0,