瀏覽代碼

后院【未登录】接口增加聊天室

caihongxingqiu 5 年之前
父節點
當前提交
b2319d514e
共有 1 個文件被更改,包括 23 次插入0 次删除
  1. 23 0
      app/Repositories/BeanRepository.php

+ 23 - 0
app/Repositories/BeanRepository.php

@@ -410,6 +410,29 @@ class BeanRepository
         $star_lists['daily_news'] = $this->getNews($request);
         $star_lists['tips'] = $this->getPlatformContent($id = 1);
 
+        //聊天室
+        $tmpChatroom = Redis::get('user_service_chatroom');
+        $chatrooms = $tmpChatroom?json_decode($tmpChatroom,true):[];
+        $current = Carbon::now()->format('H:i:s');
+        foreach ($chatrooms as &$chatroom) {
+            if ($chatroom['start']<$chatroom['end']) {
+                if ($current<$chatroom['start'] || $current>$chatroom['end']) {
+                    $chatroom['is_open'] = 0;
+                } else {
+                    $chatroom['is_open'] = 1;
+                }
+            } elseif ($chatroom['start']>$chatroom['end']) {
+                if ($current<$chatroom['end']) {
+                    $chatroom['is_open'] = 0;
+                } else {
+                    $chatroom['is_open'] = 1;
+                }
+            } else {
+                $chatroom['is_open'] = 1;
+            }
+        }
+        $star_lists['chatroom'] = $chatrooms;
+
         return $star_lists;
     }