lip 3 месяцев назад
Родитель
Сommit
ff059bab1b
3 измененных файлов с 14 добавлено и 7 удалено
  1. 1 1
      app/admin/model/KefuTime.php
  2. 1 1
      app/admin/model/KefuWork.php
  3. 12 5
      app/enterprise/model/User.php

+ 1 - 1
app/admin/model/KefuTime.php

@@ -21,7 +21,7 @@ class KefuTime extends BaseModel
 
     //结束服务时间
     public static function endData($admin_id, $type) {
-        $exits = KefuTime::where('admin_id', $admin_id)->where('type', $type)->where("created_at", '>=', date("Y-m-d"))->orderBy('id', 'desc')->find();
+        $exits = KefuTime::where('admin_id', $admin_id)->where('type', $type)->where("created_at", '>=', date("Y-m-d"))->order('id', 'desc')->find();
         if ($exits && $exits->status == 0) {
             $exits->status = 1;
             $exits->end_time = time();

+ 1 - 1
app/admin/model/KefuWork.php

@@ -35,7 +35,7 @@ class KefuWork extends BaseModel
         }
 
         if ($type) {
-            $exits = KefuTime::where('admin_id', $admin_id)->where('type', $type)->where("created_at", '>=', date("Y-m-d"))->orderBy('id', 'desc')->find();
+            $exits = KefuTime::where('admin_id', $admin_id)->where('type', $type)->where("created_at", '>=', date("Y-m-d"))->order('id', 'desc')->find();
             if ($exits && $exits->status == 0) {
                 $exits->status = 1;
                 $exits->end_time = time();

+ 12 - 5
app/enterprise/model/User.php

@@ -786,25 +786,32 @@ class User extends BaseModel
                 $sign->updated_at = date('Y-m-d H:i:s');
                 $sign->save();
             }
+            //结束客服接线时间
+            KefuTime::endData($user->uid, 3);
             //结束客服服务时间
             KefuTime::endData($user->uid, 4);
         }
-        //上线
-        if ($user->online == 0 && $is_online == 1 && $user->role == 3) {
+         //上线
+         if ($user->online == 0 && $is_online == 1 && $user->role == 3) {
             //添加客服服务时间
             KefuWork::addNum($user->uid, 'online_num');
-        }
+         }
 
         //忙碌
          if ($user->online != 2 && $is_online == 2 && $user->role == 3) {
             //更新客服忙碌次数
             KefuWork::addNum($user->uid, 'busy_num');
          }
+
+         if ($user->onlie == 2 && $is_online != 2 && $user->role == 3) {
+            //结束客服忙碌时间
+            KefuTime::endData($user->uid, 1);
+         }
         return self::where('user_id', $user_id)->update(['is_online' => $is_online]);
     }
 
-    public static function isOnline($user_id)
+    public static function isOnline($user_id = null)
     {
-        Gateway::isUidOnline($user_id);
+        return $user_id ? Gateway::isUidOnline($user_id) : 0;
     }
 }