修改了已知问题
This commit is contained in:
@@ -20,7 +20,7 @@ namespace extend\chat\model;
|
||||
Gateway::sendToClient($client_id, json_encode(['msg' => 'type/operate_type/shop_id/token参数必传']));
|
||||
return;
|
||||
}
|
||||
|
||||
self::$user_info = self::getUser($message['token']);
|
||||
// 发送消息
|
||||
if($message['operate_type'] == 'sendMsg') {
|
||||
if (
|
||||
@@ -114,7 +114,6 @@ namespace extend\chat\model;
|
||||
|
||||
public static function init(string $client_id, array $message)
|
||||
{
|
||||
self::$user_info = self::getUser($message['token']);
|
||||
// 存入chat_user
|
||||
self::insertChatUser();
|
||||
$list_arr = [];
|
||||
@@ -185,11 +184,9 @@ namespace extend\chat\model;
|
||||
if($to_message_one && !$from_message_one) {
|
||||
$session_id = $to_message_one['session_id'];
|
||||
}
|
||||
// 加入未读计数
|
||||
if(!Db::name('chat_unread_count')->where(['user_id' => $message['to_id']])->find()) {
|
||||
Db::name('chat_unread_count')->where(['user_id' => $message['to_id'], 'session_id' => $session_id])->update(['count' => 1, 'updated_time' => d()]);
|
||||
}else {
|
||||
Db::name('chat_unread_count')->where(['user_id' => $message['to_id'], 'session_id' => $session_id])->inc('count')->update(['updated_time' => d()]);
|
||||
// 如果我给我发过消息并且他没给我发过消息
|
||||
if($from_message_one && !$to_message_one) {
|
||||
$session_id = $from_message_one['session_id'];
|
||||
}
|
||||
}elseif ($message['chat_type'] == 2) {
|
||||
// 群聊
|
||||
@@ -207,7 +204,6 @@ namespace extend\chat\model;
|
||||
$notice_data = [
|
||||
'from_id' => self::$user_info['uid'],
|
||||
'to_id' => $message['to_id'],
|
||||
'operate_type' => $message['operate_type'],
|
||||
'group_id' => $group_id,
|
||||
'chat_type' => $message['chat_type'],
|
||||
'msg_type' => $message['msg_type'],
|
||||
@@ -218,6 +214,7 @@ namespace extend\chat\model;
|
||||
'session_id' => $session_id,
|
||||
];
|
||||
$res = Db::name('chat_message')->insert($notice_data);
|
||||
$notice_data['operate_type'] = $message['operate_type'];
|
||||
if(!$res) {
|
||||
// 插入失败
|
||||
Gateway::sendToClient($client_id, self::sendGormat($message, [], 0));
|
||||
@@ -236,11 +233,16 @@ namespace extend\chat\model;
|
||||
$notice_data['nick_name'] = $chat_user['nick_name'];
|
||||
$str_uid = self::getUid($message['to_id'], $message['to_user_type']);
|
||||
// 更新对方会话列表
|
||||
ChatMessage::getconverlist($message['to_id'], $message['to_user_type']);
|
||||
// ChatMessage::getconverlist($message['to_id'], $message['to_user_type']);
|
||||
// 对方是否在线,在线发 不在线存起来等上线了发
|
||||
if(Gateway::isUidOnline($str_uid)) {
|
||||
// 加入未读计数
|
||||
if(!Db::name('chat_unread_count')->where(['user_id' => $message['to_id'], 'session_id' => $session_id])->find()) {
|
||||
Db::name('chat_unread_count')->insert(['user_id' => $message['to_id'], 'session_id' => $session_id, 'count' => 1, 'updated_time' => d()]);
|
||||
}else {
|
||||
Db::name('chat_unread_count')->where(['user_id' => $message['to_id'], 'session_id' => $session_id])->inc('count')->update(['updated_time' => d()]);
|
||||
}
|
||||
Gateway::sendToUid($str_uid, self::sendReceive($notice_data));
|
||||
return;
|
||||
}else {
|
||||
// 存消息
|
||||
Business::setRedisMessage($message['to_id'], $message['to_user_type'], $notice_data);
|
||||
@@ -255,7 +257,7 @@ namespace extend\chat\model;
|
||||
|
||||
// 找到群组中的人,挨个通知,退群的不通知,自己不通知
|
||||
$group_user = Db::name('chat_group_member')->where(['group_id' => $group_id, 'quit_time' => null, 'is_kicked' => 0])->select()->toArray();
|
||||
foreach ($group_user as $k => $grep) {
|
||||
foreach ($group_user as $k => $grep) {
|
||||
if($grep['user_id'] != self::$user_info['uid']) {
|
||||
$user_type = $grep['role']==1?2:1;
|
||||
$str_uid = self::getUid($grep['user_id'], $user_type);
|
||||
@@ -263,14 +265,13 @@ namespace extend\chat\model;
|
||||
if($grep['is_dist'] == 0) {
|
||||
if(Gateway::isUidOnline($str_uid)) {
|
||||
Gateway::sendToUid($str_uid, self::sendReceive($notice_data));
|
||||
return;
|
||||
}else {
|
||||
// 存消息
|
||||
Business::setRedisMessage($grep['user_id'], $user_type, $notice_data);
|
||||
}
|
||||
// 加入未读计数
|
||||
if(!Db::name('chat_unread_count')->where(['user_id' => $grep['user_id']])->find()) {
|
||||
Db::name('chat_unread_count')->where(['user_id' => $grep['user_id'], 'session_id' => $session_id])->update(['count' => 1, 'updated_time' => d()]);
|
||||
if(!Db::name('chat_unread_count')->where(['user_id' => $grep['user_id'], 'session_id' => $session_id])->find()) {
|
||||
Db::name('chat_unread_count')->insert(['count' => 1, 'updated_time' => d(), 'user_id' => $grep['user_id'], 'session_id' => $session_id]);
|
||||
}else {
|
||||
Db::name('chat_unread_count')->where(['user_id' => $grep['user_id'], 'session_id' => $session_id])->inc('count')->update(['updated_time' => d()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user