Browse Source

作者修改优化bug等、、、

master
wanghongjun 6 months ago
parent
commit
92247ed88d
  1. 5
      app/enterprise/controller/Friend.php
  2. 3
      app/enterprise/controller/Group.php
  3. 4
      app/enterprise/controller/Im.php
  4. 6
      app/enterprise/model/User.php
  5. 4
      app/manage/controller/Index.php
  6. 18
      app/worker/Events.php

5
app/enterprise/controller/Friend.php

@ -42,6 +42,9 @@ class Friend extends BaseController
{ {
$param = $this->request->param(); $param = $this->request->param();
$user_id=$param['user_id'] ?? 0; $user_id=$param['user_id'] ?? 0;
if(!$user_id){
return warning(lang('system.notNull'));
}
if($user_id==$this->uid){ if($user_id==$this->uid){
return warning(lang('friend.notAddOwn')); return warning(lang('friend.notAddOwn'));
} }
@ -137,7 +140,7 @@ class Friend extends BaseController
} }
} }
return success(''); return success(lang('system.success'));
} }

3
app/enterprise/controller/Group.php

@ -69,7 +69,8 @@ class Group extends BaseController
$qrUrl=getMainHost().'/scan/g/'.$token; $qrUrl=getMainHost().'/scan/g/'.$token;
$group['id']=$groupId; $group['id']=$groupId;
$group['qrUrl']=$qrUrl; $group['qrUrl']=$qrUrl;
$group['qrExpire']=date('m月d日',$expire); //$group['qrExpire']=date('m月d日',$expire);
$group['qrExpire']=date('m-d',$expire);
$group['userInfo']=$userInfo; $group['userInfo']=$userInfo;
$group['ownerName']=$userInfo['realname']; $group['ownerName']=$userInfo['realname'];
$group['groupUserCount']=$userCount; $group['groupUserCount']=$userCount;

4
app/enterprise/controller/Im.php

@ -822,12 +822,12 @@ class Im extends BaseController
$param = $this->request->param(); $param = $this->request->param();
$id = $param['id']; $id = $param['id'];
if(!$this->globalConfig['chatInfo']['dbDelMsg']){ if(!$this->globalConfig['chatInfo']['dbDelMsg']){
return warning(lang('system.noAuth')); return warning(lang('system.notAuth'));
} }
$message = Message::where(['id' => $id])->find(); $message = Message::where(['id' => $id])->find();
if ($message) { if ($message) {
if($message['from_user']!=$this->userInfo['user_id']){ if($message['from_user']!=$this->userInfo['user_id']){
return warning(lang('system.noAuth')); return warning(lang('system.notAuth'));
} }
Message::where(['id' => $id])->find()->delete(); Message::where(['id' => $id])->find()->delete();
// 如果是最后一条消息,需要将上一条设置为最后一条 // 如果是最后一条消息,需要将上一条设置为最后一条

6
app/enterprise/model/User.php

@ -132,6 +132,12 @@ class User extends BaseModel
if($csUid){ if($csUid){
$userList[]=$csUid; $userList[]=$csUid;
} }
// 如果我有客服权限,就查询客服的好友
$cus=self::where(['cs_uid'=>$user_id])->column('user_id');
if($cus){
$userList=array_merge($userList,$cus);
}
$userList = array_unique($userList);
$list = self::where($map)->where('user_id', 'in', $userList)->field($field)->select(); $list = self::where($map)->where('user_id', 'in', $userList)->field($field)->select();
} }
$list_chart = chartSort($list, 'realname', false, 'index'); $list_chart = chartSort($list, 'realname', false, 'index');

4
app/manage/controller/Index.php

@ -38,7 +38,7 @@ class Index extends BaseController
// 清理消息 // 清理消息
public function clearMessage(){ public function clearMessage(){
if($this->userInfo['user_id']!=1){ if($this->userInfo['user_id']!=1){
return warning('system.noAuth'); return warning('system.notAuth');
} }
$res = Message::where(['status'=>1])->select(); $res = Message::where(['status'=>1])->select();
foreach ($res as $resMsg) { foreach ($res as $resMsg) {
@ -79,7 +79,7 @@ class Index extends BaseController
public function publishNotice(){ public function publishNotice(){
$userInfo=$this->userInfo; $userInfo=$this->userInfo;
if($userInfo['user_id']!=1){ if($userInfo['user_id']!=1){
return warning('system.noAuth'); return warning('system.notAuth');
} }
$param=$this->request->param(); $param=$this->request->param();
$msgId=$param['msgId'] ?? 0; $msgId=$param['msgId'] ?? 0;

18
app/worker/Events.php

@ -41,6 +41,7 @@ class Events
'type' => 'init', 'type' => 'init',
'client_id' => $client_id 'client_id' => $client_id
))); )));
self::onlineStatistics();
} }
/** /**
* 有消息时 * 有消息时
@ -113,11 +114,13 @@ class Events
self::closeClient($client_id); self::closeClient($client_id);
} }
$_SESSION['user_id']=$userInfo['user_id']; $_SESSION['user_id']=$userInfo['user_id'];
self::sendStatus($client_id); self::sendStatus($client_id);
} }
//断开连接 //断开连接
protected static function closeClient($client_id){ protected static function closeClient($client_id){
self::onlineStatistics();
$_SESSION['user_id']=null; $_SESSION['user_id']=null;
Gateway::closeClient($client_id); Gateway::closeClient($client_id);
} }
@ -136,7 +139,22 @@ class Events
'data' => ['id'=>$user_id,'is_online'=>0] 'data' => ['id'=>$user_id,'is_online'=>0]
))); )));
} }
self::onlineStatistics();
}
public static function onlineStatistics()
{
// 通知后台在线用户数和在线设备数
$data=[
'type' => 'statistics',
'time' => time(),
'data' => [
'onlineCount'=>Gateway::getAllUidCount() ?? 0,
'clientCount'=>Gateway::getAllClientCount() ?? 0,
]
];
Gateway::sendToGroup('admin-manage', json_encode($data));
Gateway::sendToUid(1, json_encode($data));
} }
} }

Loading…
Cancel
Save