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
1dff8307
Commit
1dff8307
authored
Dec 28, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
savePushIdV3
parent
dabae6f9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
1 deletion
+56
-1
ChatService.php
application/chat/service/ChatService.php
+56
-1
No files found.
application/chat/service/ChatService.php
View file @
1dff8307
...
...
@@ -86,7 +86,7 @@ class ChatService
//todo 保存或更新push_id
//todo 1.判断设备id +id 的数据是否存在,存在并且push_id和提交的不同则修改,否者新增
if
(
$id
>
0
&&
$device_id
&&
$push_id
)
{
$this
->
savePushIdV
2
(
$id
,
$device_id
,
$push_id
,
$source
);
$this
->
savePushIdV
3
(
$id
,
$device_id
,
$push_id
,
$source
);
}
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
}
...
...
@@ -205,6 +205,61 @@ class ChatService
return
true
;
}
/**
* @param $chat_user_id
* @param $device_id
* @param $push_id
* @param $type
* @return bool
* @throws Exception
* @throws \think\exception\DbException
*/
private
function
savePushIdV3
(
$chat_user_id
,
$device_id
,
$push_id
,
$type
)
{
//todo 根据设备来判断使用设备用户,
$where
[
'push_id'
]
=
$push_id
;
$where
[
'type'
]
=
$type
;
$info
=
$this
->
chatUserExtModel
->
getChatUserExtByUserId
(
$where
,
'a.id,b.user_id,a.ext_id,a.device_id,a.push_id,a.is_forbidden'
,
500
);
$result
=
false
;
if
(
count
(
$info
)
>
0
)
{
$current_user_id
=
0
;
foreach
(
$info
as
$k
=>
$v
)
{
if
(
$v
[
'ext_id'
]
!=
$chat_user_id
)
{
$this
->
chatUserExtModel
->
updateDate
([
'is_forbidden'
=>
1
],
[
'id'
=>
$v
[
'id'
]]);
}
else
{
$current_user_id
=
$chat_user_id
;
if
(
$current_user_id
&&
$v
[
'is_forbidden'
]
==
1
)
{
$this
->
chatUserExtModel
->
updateDate
([
'is_forbidden'
=>
0
],
[
'id'
=>
$v
[
'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
* @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