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
51874410
Commit
51874410
authored
Jul 07, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备id绑定
parent
900ca3c1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
8 deletions
+96
-8
ChatService.php
application/chat/service/ChatService.php
+25
-6
ChatUser.php
application/model/ChatUser.php
+4
-2
ChatUserExt.php
application/model/ChatUserExt.php
+67
-0
No files found.
application/chat/service/ChatService.php
View file @
51874410
...
@@ -20,6 +20,7 @@ use app\model\ChatMsgStatus;
...
@@ -20,6 +20,7 @@ use app\model\ChatMsgStatus;
use
app\model\ChatRelation
;
use
app\model\ChatRelation
;
use
app\model\ChatUser
;
use
app\model\ChatUser
;
use
app\model\ChatUserExt
;
use
app\model\HouseInfos
;
use
app\model\HouseInfos
;
use
app\model\Users
;
use
app\model\Users
;
use
http\Exception
;
use
http\Exception
;
...
@@ -51,6 +52,7 @@ class ChatService
...
@@ -51,6 +52,7 @@ class ChatService
$this
->
userModel
=
new
Users
();
$this
->
userModel
=
new
Users
();
$this
->
agentsModel
=
new
Agents
();
$this
->
agentsModel
=
new
Agents
();
$this
->
chatUserModel
=
new
ChatUser
();
$this
->
chatUserModel
=
new
ChatUser
();
$this
->
chatUserExtModel
=
new
ChatUserExt
();
$this
->
agentsV2Model
=
new
AAgents
();
$this
->
agentsV2Model
=
new
AAgents
();
}
}
...
@@ -80,16 +82,34 @@ class ChatService
...
@@ -80,16 +82,34 @@ class ChatService
if
(
!
$only_id
)
{
if
(
!
$only_id
)
{
return
[
"code"
=>
"101"
,
"msg"
=>
"没有找到用户信息"
];
return
[
"code"
=>
"101"
,
"msg"
=>
"没有找到用户信息"
];
}
else
{
}
else
{
$this
->
insertChatUser
(
$source
,
$user_id
,
$mobile
,
$only_id
);
$id
=
$this
->
insertChatUser
(
$source
,
$user_id
,
$mobile
,
$only_id
);
}
//todo 保存或更新push_id
//todo 保存或更新push_id
if
(
$id
>
0
)
{
$this
->
savePushId
(
$id
,
$device_id
,
$push_id
);
}
}
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
return
[
"code"
=>
200
,
"only_id"
=>
$only_id
];
}
}
}
}
private
function
savePushId
(){
//todo
/**
* @param $chat_user_id
* @param $device_id
* @param $push_id
* @return bool
*/
private
function
savePushId
(
$chat_user_id
,
$device_id
,
$push_id
){
//todo 保存或更新push_id
$params
[
"ext_id"
]
=
$chat_user_id
;
$params
[
"device_id"
]
=
$device_id
;
$params
[
"push_id"
]
=
$push_id
;
$params
[
"is_forbidden"
]
=
0
;
$params
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"updated_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$this
->
chatUserExtModel
->
addChatUserExt
(
$params
);
return
true
;
}
}
/**
/**
...
@@ -381,8 +401,7 @@ class ChatService
...
@@ -381,8 +401,7 @@ class ChatService
$params
[
"last_login_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"last_login_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"created_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"created_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"updated_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"updated_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$this
->
chatUserModel
->
addChatUser
(
$params
);
return
$this
->
chatUserModel
->
addChatUser
(
$params
);
return
true
;
}
}
...
...
application/model/ChatUser.php
View file @
51874410
...
@@ -35,12 +35,13 @@ class ChatUser extends Model
...
@@ -35,12 +35,13 @@ class ChatUser extends Model
{
{
Db
::
startTrans
();
Db
::
startTrans
();
try
{
try
{
$this
->
save
(
$params
);
$
res
=
$
this
->
save
(
$params
);
Db
::
commit
();
Db
::
commit
();
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
Db
::
rollback
();
$res
=
0
;
}
}
return
$res
;
}
}
}
}
\ No newline at end of file
application/model/ChatUserExt.php
0 → 100644
View file @
51874410
<?php
/**
* Created by PhpStorm.
* User: fuju
* Date: 2018/7/7
* Time: 11:28
*/
namespace
app\model
;
class
ChatUserExt
extends
BaseModel
{
// 设置当前模型对应的完整数据表名称
protected
$table
=
'chat_user_ext'
;
protected
$db
;
public
function
__construct
()
{
$this
->
db
=
Db
(
$this
->
table
);
}
/**
* @param $params
* @param string $field
* @return mixed
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public
function
getChatUserExt
(
$params
,
$field
=
"id,ext_id,push_id,is_forbidden"
)
{
$where_
=
[];
if
(
isset
(
$params
[
'is_forbidden'
]))
{
$where_
[
'is_forbidden'
]
=
$params
[
'is_forbidden'
];
}
else
{
$where_
[
'is_forbidden'
]
=
0
;
}
if
(
isset
(
$params
[
'ext_id'
]))
{
$where_
[
'ext_id'
]
=
$params
[
'ext_id'
];
}
$data
=
$this
->
db
->
field
(
$field
)
->
where
(
$where_
)
->
select
();
return
$data
;
}
/**
* @param $params
* @return false|int
*/
public
function
addChatUserExt
(
$params
)
{
Db
::
startTrans
();
try
{
$res
=
$this
->
save
(
$params
);
Db
::
commit
();
}
catch
(
\Exception
$e
)
{
Db
::
rollback
();
$res
=
0
;
}
return
$res
;
}
}
\ No newline at end of file
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