songxingwei 2 years ago
parent
commit
5d6a5caa7c
1 changed files with 24 additions and 0 deletions
  1. 24 0
      app/data/controller/api/auth/Center.php

+ 24 - 0
app/data/controller/api/auth/Center.php

@@ -1430,6 +1430,30 @@ class Center extends Auth
         $this->success('成功',$messagelist);
     }
 
+
+    /**
+     * @Title("消息未读数量")
+     * @Method("post")
+     * @Header("api-name",type="string",require=1,default="",desc="访问类型")
+     * @Header("api-token",type="string",require=1,default="",desc="token")
+     * @Returned("message_count",desc="后台消息未读数量")
+     * @Returned("notice_count",desc="系统通知未读数量")
+     */
+    public function messagenoread(){
+        $message = BaseUserMessage::mk()->where('type','message')->where('status',1)
+            ->where('deleted',0)->column('id');
+        $notice = BaseUserMessage::mk()->where('type','notice')->where('status',1)
+            ->where('deleted',0)->column('id');
+        $message_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$message)->count();
+        $notice_read_count = BaseUserMessageRead::mk()->where('uuid',$this->uuid)->whereIn('message_id',$notice)->count();
+        $array = [
+            'message_count'=>count($message)-$message_read_count,
+            'notice_count'=>count($notice)-$notice_read_count
+        ];
+        $this->success('成功',$array);
+    }
+
+
     /**
      * @Title("消息")
      * @Method("post")