更新会话列表
This commit is contained in:
@@ -51,8 +51,6 @@ class ChatMessage extends BaseModel
|
|||||||
}else {
|
}else {
|
||||||
$lastMsg = '';
|
$lastMsg = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($session['chat_type'] == 1) {
|
if($session['chat_type'] == 1) {
|
||||||
$chat_user = Db::name('chat_user')->where(['user_id' => $session['group_id']])->field('nick_name,avatar')->find();
|
$chat_user = Db::name('chat_user')->where(['user_id' => $session['group_id']])->field('nick_name,avatar')->find();
|
||||||
$avatar = $chat_user['avatar'];
|
$avatar = $chat_user['avatar'];
|
||||||
@@ -89,11 +87,30 @@ class ChatMessage extends BaseModel
|
|||||||
$data[$i]['group_id'] = $group_id;
|
$data[$i]['group_id'] = $group_id;
|
||||||
$i ++;
|
$i ++;
|
||||||
}
|
}
|
||||||
// Redis::set('usermsg:list:' . $user_type . ':' . $uid, json_encode($data));
|
Redis::setEx('usermsg:list:' . $user_type . ':' . $uid, 30 * 86400, json_encode($data));
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 更新会话列表
|
||||||
|
public static function updateConverList($uid, $user_type, $session_id)
|
||||||
|
{
|
||||||
|
$is_update = false;
|
||||||
|
$list_json = Redis::get('usermsg:list:' . $user_type . ':' . $uid);
|
||||||
|
if($list_json) {
|
||||||
|
$list_arr = json_decode($list_json, true);
|
||||||
|
foreach ($list_arr as $k => $list) {
|
||||||
|
if($list['session_id'] == $session_id) {
|
||||||
|
$is_update = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($is_update) {
|
||||||
|
self::getconverlist($uid, $user_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function getUserIsQuit($uid, $group_id)
|
public static function getUserIsQuit($uid, $group_id)
|
||||||
{
|
{
|
||||||
// $auit = Db::name('')->where()->find();
|
// $auit = Db::name('')->where()->find();
|
||||||
|
|||||||
@@ -282,6 +282,8 @@ namespace extend\chat\model;
|
|||||||
Db::name('chat_unread_count')->where(['user_id' => $grep['user_id'], 'session_id' => $session_id])->inc('count')->update(['updated_time' => d()]);
|
Db::name('chat_unread_count')->where(['user_id' => $grep['user_id'], 'session_id' => $session_id])->inc('count')->update(['updated_time' => d()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 更新对方会话列表
|
||||||
|
ChatMessage::updateConverList($grep['user_id'], $user_type, $session_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use support\Redis;
|
|||||||
|
|
||||||
class Business
|
class Business
|
||||||
{
|
{
|
||||||
// 存消息
|
// 存消息 未读消息保存30天 30天以后自动删除
|
||||||
public static function setRedisMessage($uid, $user_type, $data, $open_id = '')
|
public static function setRedisMessage($uid, $user_type, $data, $open_id = '')
|
||||||
{
|
{
|
||||||
$str_uid = Base::getUid($uid, $user_type);
|
$str_uid = Base::getUid($uid, $user_type);
|
||||||
@@ -19,11 +19,11 @@ class Business
|
|||||||
if($sent) {
|
if($sent) {
|
||||||
$sent = json_decode($sent, true);
|
$sent = json_decode($sent, true);
|
||||||
$sent[count($sent)] = $set_info_str;
|
$sent[count($sent)] = $set_info_str;
|
||||||
Redis::set($set_str, json_encode($sent));
|
Redis::setEx($set_str, 30 * 86400, json_encode($sent));
|
||||||
}else {
|
}else {
|
||||||
Redis::set($set_str, json_encode([$set_info_str]));
|
Redis::setEx($set_str, 30 * 86400, json_encode([$set_info_str]));
|
||||||
}
|
}
|
||||||
Redis::set($set_info_str, json_encode($data));
|
Redis::setEx($set_info_str, 30 * 86400, json_encode($data));
|
||||||
|
|
||||||
|
|
||||||
if($open_id) {
|
if($open_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user