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
d1a6752d
Commit
d1a6752d
authored
Jul 16, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
c597f1dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
32 deletions
+44
-32
ChatService.php
application/chat/service/ChatService.php
+31
-20
RPush.php
application/chat/utils/RPush.php
+13
-12
No files found.
application/chat/service/ChatService.php
View file @
d1a6752d
...
@@ -217,7 +217,7 @@ class ChatService
...
@@ -217,7 +217,7 @@ class ChatService
foreach
(
$info
as
$item
)
{
foreach
(
$info
as
$item
)
{
array_push
(
$target
,
$item
[
"push_id"
]);
array_push
(
$target
,
$item
[
"push_id"
]);
}
}
$rPush
->
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
$rPush
->
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$is_user
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
return
true
;
return
true
;
}
}
...
@@ -230,14 +230,14 @@ class ChatService
...
@@ -230,14 +230,14 @@ class ChatService
*/
*/
public
function
saveSendStatus
(
$response
,
$target
,
$from
,
$msg_content
)
public
function
saveSendStatus
(
$response
,
$target
,
$from
,
$msg_content
)
{
{
/* $response = json_decode($response, true);
/* $response = json_decode($response, true);
//目前没有针对多人聊天
//目前没有针对多人聊天
$status = isset($response["data"][$target[0]]) ? $response["data"][$target[0]] : "faild";
$status = isset($response["data"][$target[0]]) ? $response["data"][$target[0]] : "faild";
$error_reason = "";
$error_reason = "";
if ($status != "success") {
if ($status != "success") {
$error_reason = "环信发送异常";
$error_reason = "环信发送异常";
}
}
$this->insertPushLog($from, $target[0], $msg_content, $status, $error_reason);*/
$this->insertPushLog($from, $target[0], $msg_content, $status, $error_reason);*/
}
}
...
@@ -341,7 +341,7 @@ class ChatService
...
@@ -341,7 +341,7 @@ class ChatService
$params
[
"is_user"
]
=
$is_user
;
$params
[
"is_user"
]
=
$is_user
;
$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
());
//dump($params);
//dump($params);
$msgModel
=
new
ChatMsg
();
$msgModel
=
new
ChatMsg
();
$id
=
$msgModel
->
addChatMsg
(
$params
);
$id
=
$msgModel
->
addChatMsg
(
$params
);
...
@@ -377,11 +377,11 @@ class ChatService
...
@@ -377,11 +377,11 @@ class ChatService
}
}
}
}
/**
*
获取聊天列表
/**
获取聊天列表
* @param $target
* @param $target
* @return
false|\PDOStatement|string|\think\Collection
* @return
array
* @throws \think\db\exception\DataNotFoundException
*
*
@throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @throws \think\exception\DbException
*/
*/
...
@@ -394,15 +394,26 @@ class ChatService
...
@@ -394,15 +394,26 @@ class ChatService
c.name as agent_name,c.img,d.user_name,d.user_phone,d.user_nick,d.user_pic,d.other_pic"
;
c.name as agent_name,c.img,d.user_name,d.user_phone,d.user_nick,d.user_pic,d.other_pic"
;
$relationList
=
$chatRelationModel
->
getChatRelationInfo
(
$params
,
$field
);
$relationList
=
$chatRelationModel
->
getChatRelationInfo
(
$params
,
$field
);
$result
=
[];
//dump($relationList);
//dump($relationList);
$fields
=
"a.id,a.from_id,a.to_id,b.body,a.created_at"
;
$fields
=
"a.id,a.from_id,a.to_id,b.body,a.created_at"
;
$msgModel
=
new
ChatMsg
();
$msgModel
=
new
ChatMsg
();
foreach
(
$relationList
as
$key
=>
$item
)
{
foreach
(
$relationList
as
$key
=>
$item
)
{
$select_
[
"from"
]
=
$item
[
"from_id"
];
if
(
$item
[
"from_id"
]
==
$target
)
{
$select_
[
"target"
]
=
$item
[
"to_id"
];
$result
[
$key
][
"relation_id"
]
=
$item
[
"to_id"
];
$relationList
[
$key
][
"chat_info"
]
=
$msgModel
->
getChatHistory
(
$select_
,
$fields
,
1
,
1
);
}
else
{
$result
[
$key
][
"relation_id"
]
=
$item
[
"from_id"
];
}
$result
[
$key
][
"id"
]
=
$item
[
"id"
];
$result
[
$key
][
"type"
]
=
$item
[
"type"
];
$result
[
$key
][
"id"
]
=
$item
[
"id"
];
$result
[
$key
][
"id"
]
=
$item
[
"id"
];
$select_
[
"from"
]
=
$item
[
"from_id"
];
$select_
[
"target"
]
=
$item
[
"to_id"
];
$result
[
$key
][
"chat_info"
]
=
$msgModel
->
getChatHistory
(
$select_
,
$fields
,
1
,
1
);
}
}
return
$re
lationLis
t
;
return
$re
sul
t
;
}
}
/**
/**
...
...
application/chat/utils/RPush.php
View file @
d1a6752d
...
@@ -24,11 +24,12 @@ class RPush
...
@@ -24,11 +24,12 @@ class RPush
* @param $target
* @param $target
* @param $msg_content
* @param $msg_content
* @param $from
* @param $from
* @param $is_user
* @param $type
* @param $type
* @param $access_token
* @param $access_token
* @param $callback
* @param $callback
*/
*/
public
function
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
,
$callback
)
public
function
send
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$
is_user
,
$
type
,
$access_token
,
$callback
)
{
{
//todo
//todo
if
(
Cache
::
get
(
'save_message_num'
))
{
if
(
Cache
::
get
(
'save_message_num'
))
{
...
@@ -44,7 +45,7 @@ class RPush
...
@@ -44,7 +45,7 @@ class RPush
Cache
::
set
(
'save_message_num'
,
0
);
Cache
::
set
(
'save_message_num'
,
0
);
}
}
$response
=
$this
->
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
);
$response
=
$this
->
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$
is_user
,
$
type
,
$access_token
);
call_user_func_array
([
$callback
[
0
],
$callback
[
1
]
],
[
$response
,
$target
,
$from
,
$msg_content
]);
call_user_func_array
([
$callback
[
0
],
$callback
[
1
]
],
[
$response
,
$target
,
$from
,
$msg_content
]);
}
}
...
@@ -61,10 +62,10 @@ class RPush
...
@@ -61,10 +62,10 @@ class RPush
* @param $access_token
* @param $access_token
* @return array
* @return array
*/
*/
public
function
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
)
public
function
sendRequestByCurl
(
$user_name
,
$target_type
,
$target
,
$msg_content
,
$from
,
$
is_user
,
$
type
,
$access_token
)
{
{
$title
=
"收到一条消息"
;
$title
=
"收到一条消息"
;
// $arr = array(
// $arr = array(
// 'target_type' => $target_type,
// 'target_type' => $target_type,
// 'target' => $target,
// 'target' => $target,
...
@@ -74,24 +75,24 @@ class RPush
...
@@ -74,24 +75,24 @@ class RPush
// );
// );
$payload
=
json_encode
(
array
(
$payload
=
json_encode
(
array
(
'title'
=>
$title
,
'title'
=>
$title
,
'content'
=>
$msg_content
,
'content'
=>
$msg_content
,
'type'
=>
'chat'
,
'type'
=>
'chat'
,
'url'
=>
''
,
'url'
=>
''
,
'name'
=>
$title
,
'name'
=>
$title
,
'imageUrl'
=>
''
,
'imageUrl'
=>
''
,
'id'
=>
0
,
'id'
=>
0
,
'target'
=>
$target
,
'target'
=>
$target
,
'from'
=>
$from
,
'from'
=>
$from
,
'is_user'
=>
$is_user
,
'msg_type'
=>
1
,
// 1文本 2图片3楼盘
'msg_type'
=>
1
,
// 1文本 2图片3楼盘
'ext'
=>
[
"user_name"
=>
$user_name
]
'ext'
=>
[
"user_name"
=>
$user_name
]
));
));
$pushMessageToIgt
=
new
GeTuiUtils
();
$pushMessageToIgt
=
new
GeTuiUtils
();
$push_arr
=
$target
;
$push_arr
=
$target
;
return
$pushMessageToIgt
->
pushMessageToIgt
(
$push_arr
,
$title
,
$payload
);
return
$pushMessageToIgt
->
pushMessageToIgt
(
$push_arr
,
$title
,
$payload
);
/* $curl = new \app\chat\utils\CurlUtil();
/* $curl = new \app\chat\utils\CurlUtil();
$curl->headers = [
$curl->headers = [
...
...
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