Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
26c76d0b
Commit
26c76d0b
authored
Nov 26, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聊天相互登录设备
parent
43e4b9ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
15 deletions
+70
-15
Broker.php
application/api_broker/controller/Broker.php
+14
-14
ChatService.php
application/chat/service/ChatService.php
+56
-1
No files found.
application/api_broker/controller/Broker.php
View file @
26c76d0b
...
@@ -190,20 +190,20 @@ class Broker extends Basic
...
@@ -190,20 +190,20 @@ class Broker extends Basic
$redis_
->
set
(
"agent_city_"
.
$agents_data
[
'id'
],
$site_city
[
0
][
'city'
]);
$redis_
->
set
(
"agent_city_"
.
$agents_data
[
'id'
],
$site_city
[
0
][
'city'
]);
$redis_
->
set
(
"agent_site_id_"
.
$agents_data
[
'id'
],
$agents_data
[
'site_id'
]);
$redis_
->
set
(
"agent_site_id_"
.
$agents_data
[
'id'
],
$agents_data
[
'site_id'
]);
/*处理多个手机登录聊天*/
//
/*处理多个手机登录聊天*/
$m_chat_ext
=
new
ChatUserExt
();
//
$m_chat_ext = new ChatUserExt();
$bind_where
[
'is_forbidden'
]
=
0
;
//
$bind_where['is_forbidden'] = 0;
$bind_where
[
'user_id'
]
=
$agents_data
[
'id'
];
//
$bind_where['user_id'] = $agents_data['id'];
$bind_where
[
'type'
]
=
1
;
//
$bind_where['type'] = 1;
$del_bind_id
=
$m_chat_ext
->
getChatUserExtByUserId
(
$bind_where
,
'a.id,a.push_id'
,
100
);
//
$del_bind_id = $m_chat_ext->getChatUserExtByUserId($bind_where, 'a.id,a.push_id', 100);
if
(
count
(
$del_bind_id
)
>
0
)
{
//
if (count($del_bind_id) > 0) {
foreach
(
$del_bind_id
as
$v
)
{
//
foreach ($del_bind_id as $v) {
if
(
$v
[
'push_id'
]
!=
$params
[
"push_id"
])
{
//
if ($v['push_id'] != $params["push_id"]) {
$m_chat_ext
->
updateDate
([
'is_forbidden'
=>
1
],
[
'id'
=>
$v
[
'id'
]]);
//
$m_chat_ext->updateDate(['is_forbidden'=>1], ['id'=>$v['id']]);
}
//
}
}
//
}
}
//
}
/*处理多个手机登录聊天*/
//
/*处理多个手机登录聊天*/
return
$this
->
response
(
200
,
$data
[
'msg'
],
$data
[
'data'
]);
return
$this
->
response
(
200
,
$data
[
'msg'
],
$data
[
'data'
]);
}
}
...
...
application/chat/service/ChatService.php
View file @
26c76d0b
...
@@ -86,7 +86,7 @@ class ChatService
...
@@ -86,7 +86,7 @@ class ChatService
//todo 保存或更新push_id
//todo 保存或更新push_id
//todo 1.判断设备id +id 的数据是否存在,存在并且push_id和提交的不同则修改,否者新增
//todo 1.判断设备id +id 的数据是否存在,存在并且push_id和提交的不同则修改,否者新增
if
(
$id
>
0
&&
$device_id
&&
$push_id
)
{
if
(
$id
>
0
&&
$device_id
&&
$push_id
)
{
$this
->
savePushId
(
$id
,
$device_id
,
$push_id
);
$this
->
savePushId
V2
(
$id
,
$device_id
,
$push_id
);
}
}
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
}
}
...
@@ -139,6 +139,61 @@ class ChatService
...
@@ -139,6 +139,61 @@ class ChatService
return
true
;
return
true
;
}
}
/**
* @param $chat_user_id
* @param $device_id
* @param $push_id
* @return bool
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private
function
savePushIdV2
(
$chat_user_id
,
$device_id
,
$push_id
)
{
//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'
);
$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
)
{
$this
->
chatUserExtModel
->
addChatUserExt
([
'is_forbidden'
=>
1
],
$v
[
'id'
]);
}
}
else
{
if
(
$v
[
'ext_id'
]
==
$chat_user_id
)
{
$this
->
chatUserExtModel
->
addChatUserExt
([
'is_forbidden'
=>
0
],
$v
[
'id'
]);
$current_user_id
=
$chat_user_id
;
}
}
}
if
(
empty
(
$current_user_id
))
{
//todo 当前用户没有使用过该设备,新增
$params
[
"ext_id"
]
=
$chat_user_id
;
$params
[
"device_id"
]
=
$device_id
;
$params
[
"push_id"
]
=
$push_id
;
$params
[
"is_forbidden"
]
=
0
;
$result
=
$this
->
chatUserExtModel
->
addChatUserExt
(
$params
);
}
}
else
{
//todo 保存或更新push_id
$params
[
"ext_id"
]
=
$chat_user_id
;
$params
[
"device_id"
]
=
$device_id
;
$params
[
"push_id"
]
=
$push_id
;
$params
[
"is_forbidden"
]
=
0
;
$result
=
$this
->
chatUserExtModel
->
addChatUserExt
(
$params
);
}
if
(
!
$result
)
{
return
false
;
}
return
true
;
}
/**
/**
* 生成唯一id
* 生成唯一id
* @param $userId integer 用户id
* @param $userId integer 用户id
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment