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
c45db7df
Commit
c45db7df
authored
Jul 20, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
0f89df04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
22 deletions
+31
-22
ChatService.php
application/chat/service/ChatService.php
+22
-21
ChatUser.php
application/model/ChatUser.php
+9
-1
No files found.
application/chat/service/ChatService.php
View file @
c45db7df
...
...
@@ -205,27 +205,29 @@ class ChatService
$msg_id
=
$this
->
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
);
$rPush
=
new
RPush
();
// 消息接收人必须是数组
$userExt
=
new
ChatUserExt
();
$where
[
'only_id'
]
=
$target
;
$m_user
=
new
ChatUser
();
$user_where
[
'only_id'
]
=
$from
;
$user_where
[
'only_id_or'
]
=
$target
;
$user_where
[
'status'
]
=
0
;
$user_arr
=
$m_user
->
getChatUserOne
(
'user_id'
,
$user_where
);
//0用户 1经纪人
if
(
strstr
(
$target
,
'user'
))
{
$where
[
'type'
]
=
2
;
//对用户发
}
elseif
(
strstr
(
$target
,
'agent'
))
{
$where
[
'type'
]
=
1
;
//对经纪人发
}
else
{
if
(
count
(
$user_arr
)
<
2
)
{
return
false
;
}
$m_user
=
new
ChatUser
();
$user_where
[
'only_id'
]
=
$from
;
$user_where
[
'status'
]
=
0
;
$user_arr
=
$m_user
->
getChatUserOne
(
'user_id'
,
$user_where
);
$user_id
=
empty
(
$user_arr
[
'user_id'
])
?
0
:
$user_arr
[
'user_id'
]
;
$user_id
=
0
;
$where
[
'type'
]
=
1
;
foreach
(
$user_arr
as
$item
)
{
if
(
$item
[
"only_id"
]
==
$from
)
{
$user_id
=
empty
(
$user_arr
[
'user_id'
])
?
0
:
$user_arr
[
'user_id'
];
}
else
{
$where
[
'type'
]
=
$item
[
"type"
];
}
}
$info
=
$userExt
->
getChatUserExtByUserId
(
$where
,
'a.id,a.ext_id,a.device_id,a.push_id,b.user_id'
);
if
(
count
(
$info
)
<=
0
)
{
...
...
@@ -248,13 +250,13 @@ class ChatService
*/
public
function
saveSendStatus
(
$response
,
$target
,
$from
,
$msg_content
)
{
try
{
//目前没有针对多人聊天
$status
=
$response
[
"code"
];
$this
->
insertPushLog
(
$from
,
$target
,
$msg_content
,
$status
,
$response
[
"msg"
]);
}
catch
(
Exception
$exception
)
{
try
{
//目前没有针对多人聊天
$status
=
$response
[
"code"
];
$this
->
insertPushLog
(
$from
,
$target
,
$msg_content
,
$status
,
$response
[
"msg"
]);
}
catch
(
Exception
$exception
)
{
//todo 暂不处理
}
}
}
...
...
@@ -350,8 +352,7 @@ class ChatService
*/
private
function
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
)
{
//todo
$params
[
"msg_type"
]
=
1
;
//目前只用到了环信的文本消息
$params
[
"msg_type"
]
=
1
;
$params
[
"to_id"
]
=
$target
;
$params
[
"from_id"
]
=
$from
;
$params
[
"is_group"
]
=
$target_type
==
"users"
?
0
:
1
;
...
...
application/model/ChatUser.php
View file @
c45db7df
...
...
@@ -62,9 +62,17 @@ class ChatUser extends Model
* @throws \think\exception\DbException
*/
public
function
getChatUserOne
(
$field
,
$params
)
{
$where_
=
$whereOr_
=
[];
if
(
isset
(
$params
[
"only_id"
])){
$where_
[
"only_id"
]
=
$params
[
"only_id"
];
}
if
(
isset
(
$params
[
"only_id_or"
])){
$whereOr_
[
"only_id"
]
=
$params
[
"only_id_or"
];
}
$data
=
$this
->
db
->
field
(
$field
)
->
where
(
$params
)
->
find
();
->
select
();
return
$data
;
}
...
...
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