Преглед изворни кода

聊天室增加是否开启

caihongxingqiu пре 5 година
родитељ
комит
c197852ee1
1 измењених фајлова са 20 додато и 1 уклоњено
  1. 20 1
      app/Repositories/BeanRepository.php

+ 20 - 1
app/Repositories/BeanRepository.php

@@ -221,7 +221,26 @@ class BeanRepository
         $star_home['battle']['news'] = Redis::get('battle_latest_info_'.$activityInfo['id'])??'战场四平八稳,劳驾老板亲自去战场督战';
 
         //聊天室
-        $star_home['chatroom'] = json_decode(Redis::get('user_service_chatroom'),true)??[];
+        $chatrooms = json_decode(Redis::get('user_service_chatroom'),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['id_open'] = 0;
+                } else {
+                    $chatroom['id_open'] = 1;
+                }
+            } elseif ($chatroom['start']>$chatroom['end']) {
+                if ($current<$chatroom['end']) {
+                    $chatroom['id_open'] = 0;
+                } else {
+                    $chatroom['id_open'] = 1;
+                }
+            } else {
+                $chatroom['id_open'] = 1;
+            }
+        }
+        $star_home['chatroom'] = $chatrooms;
 
         return $star_home;