lip 3 ماه پیش
والد
کامیت
4f52506baf
3فایلهای تغییر یافته به همراه25 افزوده شده و 1 حذف شده
  1. 3 1
      app/admin/validate/IpConfigValidate.php
  2. 18 0
      app/enterprise/controller/Im.php
  3. 4 0
      app/enterprise/model/Message.php

+ 3 - 1
app/admin/validate/IpConfigValidate.php

@@ -14,6 +14,7 @@ class IpConfigValidate extends BaseValidate
     protected $rule = [
     protected $rule = [
         'id' => 'require',
         'id' => 'require',
         'ip' => 'require|ip',
         'ip' => 'require|ip',
+        'type' => 'require|in:1,2',
         'status' => 'integer|in:0,1',
         'status' => 'integer|in:0,1',
         'remark' => 'length:0,200',
         'remark' => 'length:0,200',
     ];
     ];
@@ -26,6 +27,7 @@ class IpConfigValidate extends BaseValidate
     protected $field = [
     protected $field = [
         'id' => 'id',
         'id' => 'id',
         'ip' => 'IP地址',
         'ip' => 'IP地址',
+        'type' => '类型',
         'status' => '状态',
         'status' => '状态',
         'remark' => '备注',
         'remark' => '备注',
     ];
     ];
@@ -35,7 +37,7 @@ class IpConfigValidate extends BaseValidate
      */
      */
     public function sceneEdit()
     public function sceneEdit()
     {
     {
-        return $this->only(['ip', 'status', 'remark']);
+        return $this->only(['ip', 'type', 'status', 'remark']);
     }
     }
 
 
     public function sceneId()
     public function sceneId()

+ 18 - 0
app/enterprise/controller/Im.php

@@ -303,6 +303,24 @@ class Im extends BaseController
             $where[]=['msg_id','<',$last_id];
             $where[]=['msg_id','<',$last_id];
             $pageSize=1;
             $pageSize=1;
         }
         }
+        //判断是客服还是用户
+        if ($this->userInfo['role'] == 0) {
+            //用户可见历史记录的时长
+            $hours = Config::where('field', 'user_show_message')->value('val');
+            if ($hours > 0) {
+                $start_time = time() - $hours * 60 * 60;
+                $where[] = ['create_time', '>=', $start_time];
+            }
+        } elseif ($this->userInfo['role'] == 3) {
+            //客服可见历史记录的时长
+            $hours = Config::where('field', 'kefu_show_message')->value('val');
+            if ($hours > 0) {
+                $start_time = time() - $hours * 60 * 60;
+                $where[] = ['create_time', '>=', $start_time];
+            }
+        }
+        
+        
         $list = Message::getList($map, $where, 'msg_id desc', $listRows, $pageSize);
         $list = Message::getList($map, $where, 'msg_id desc', $listRows, $pageSize);
         $data = $this->recombileMsg($list,true,$groupManage);
         $data = $this->recombileMsg($list,true,$groupManage);
         // 如果是群聊并且是第一页消息,需要推送@数据给用户
         // 如果是群聊并且是第一页消息,需要推送@数据给用户

+ 4 - 0
app/enterprise/model/Message.php

@@ -101,6 +101,10 @@ class Message extends BaseModel
                         }
                         }
                     }
                     }
                 }
                 }
+
+                //判断是否给机器人客服发送消息
+                if ($param['toContactId'] == 0) { 
+                }
             }else{
             }else{
                 // 群聊必须群成员才能发送消息
                 // 群聊必须群成员才能发送消息
                 $group_id = explode('-', $param['toContactId'])[1] ?? '';
                 $group_id = explode('-', $param['toContactId'])[1] ?? '';