Commit 4cbe4b68 authored by hujun's avatar hujun Committed by zw

聊天推送

parent c8024fc2
......@@ -86,7 +86,7 @@ class ChatService
//todo 保存或更新push_id
//todo 1.判断设备id +id 的数据是否存在,存在并且push_id和提交的不同则修改,否者新增
if ($id > 0 && $device_id && $push_id) {
$this->savePushIdV2($id, $device_id, $push_id);
$this->savePushIdV2($id, $device_id, $push_id, $chatUser[0]['type']);
}
return [ "code" => 200, "only_id" => $only_id ];
}
......@@ -143,29 +143,30 @@ class ChatService
* @param $chat_user_id
* @param $device_id
* @param $push_id
* @param $type
* @return bool
* @throws \think\Exception
* @throws Exception
* @throws \think\exception\DbException
*/
private function savePushIdV2($chat_user_id, $device_id, $push_id)
private function savePushIdV2($chat_user_id, $device_id, $push_id, $type)
{
//todo 根据设备来判断使用设备用户,
$where['device_id'] = $device_id;
$where['push_id'] = $push_id;
$info = $this->chatUserExtModel->getChatUserExt($where, 'id,ext_id,device_id,push_id,is_forbidden');
$where['type'] = $type;
$info = $this->chatUserExtModel->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id,a.is_forbidden', 100);
$result = false;
if (count($info) > 0) {
$current_user_id = 0;
foreach ($info as $k=>$v) {
if ($v['is_forbidden'] == 0) {
if ($v['ext_id'] != $chat_user_id) {
if ($v['ext_id'] != $chat_user_id && $push_id == $v['push_id']) {
$this->chatUserExtModel->addChatUserExt(['is_forbidden'=>1], $v['id']);
} else {
$current_user_id = $chat_user_id;
}
} else {
if ($v['ext_id'] == $chat_user_id && $current_user_id != $chat_user_id) {
if ($v['ext_id'] == $chat_user_id && $push_id == $v['push_id']) {
$this->chatUserExtModel->addChatUserExt(['is_forbidden'=>0], $v['id']);
$current_user_id = $chat_user_id;
}
......@@ -179,15 +180,6 @@ class ChatService
$params["push_id"] = $push_id;
$params["is_forbidden"] = 0;
$result = $this->chatUserExtModel->addChatUserExt($params);
} else {
$old_device_where['ext_id'] = $current_user_id;
$old_device_where['is_forbidden'] = 0;
$old_device_where['push_id'] = ['<>', $push_id];
$info = $this->chatUserExtModel->getChatUserExt($where, 'id');
foreach ($info as $k2=>$v2) {
$this->chatUserExtModel->addChatUserExt(['is_forbidden'=> 1], $v2['id']);
}
}
} else {
//todo 保存或更新push_id
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment