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
a1e588ac
Commit
a1e588ac
authored
Jan 23, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增组群
parent
ff5b8018
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
212 additions
and
18 deletions
+212
-18
AppChat.php
application/chat/controller/AppChat.php
+35
-0
Group.php
application/chat/controller/Group.php
+59
-0
ChatService.php
application/chat/service/ChatService.php
+11
-7
RPush.php
application/chat/utils/RPush.php
+12
-10
curl_cookie.txt
application/chat/utils/curl_cookie.txt
+1
-1
ChatMsg.php
application/model/ChatMsg.php
+41
-0
route.php
application/route.php
+1
-0
log.txt
log.txt
+52
-0
No files found.
application/chat/controller/AppChat.php
View file @
a1e588ac
...
@@ -15,6 +15,7 @@ use app\chat\extend\Basic;
...
@@ -15,6 +15,7 @@ use app\chat\extend\Basic;
use
app\chat\service\ChatService
;
use
app\chat\service\ChatService
;
use
app\chat\utils\RPush
;
use
app\chat\utils\RPush
;
use
app\extra\RedisPackage
;
use
app\extra\RedisPackage
;
use
app\model\ChatMsg
;
use
think\Cache
;
use
think\Cache
;
use
Think\Log
;
use
Think\Log
;
...
@@ -143,4 +144,38 @@ class AppChat extends Basic
...
@@ -143,4 +144,38 @@ class AppChat extends Basic
}
}
}
}
/**
* 查询历史和搜索历史
* @return \think\Response
*/
public
function
getChatHistory
()
{
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'target_type'
])
||
!
isset
(
$params
[
'from'
])
||
!
isset
(
$params
[
'target'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
/* $params = array(
'target_type' => 'users', // 消息类型 users 用户消息。chatgroups: 群消息,chatrooms: 聊天室消息
'from' => 'app_64', //发送人
'target' => '18112347151', //接受人
'page_no' => '1', //第几页
'page_size' => '15' //每页多少条
);*/
$page_no
=
empty
(
$params
[
'page_no'
])
?
1
:
$params
[
'page_no'
];
$page_size
=
empty
(
$params
[
'page_size'
])
?
15
:
$params
[
'page_size'
];
$field
=
"a.id,a.to_id,a.from_id,a.created_at,b.type,b.body"
;
$msgModel
=
new
ChatMsg
();
$history_result
=
$msgModel
->
getChatHistory
(
$params
,
$field
,
$page_no
,
$page_size
);
if
(
$history_result
)
{
return
$this
->
response
(
"200"
,
"request success"
,
$history_result
);
}
}
}
}
application/chat/controller/Group.php
0 → 100644
View file @
a1e588ac
<?php
namespace
app\chat\controller
;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/1/23
* Time : 13:47
* Intro:
*/
use
app\chat\extend\Basic
;
class
Group
extends
Basic
{
public
function
createGroupByOnlyId
()
{
//todo 组群创建 1.存表,2调用环信接口
}
public
function
updateGroup
()
{
//todo 修改组群信息 1.群信息完善到后台表 无需调用环信接口
}
public
function
delGroup
()
{
//todo 删除群组 1.改变我们group表的状态2.调用环信删群接口
}
/**
* 群组管理
*/
public
function
getGroupUser
()
{
//todo 获取群组成员/管理员 我们的数据库获取
}
public
function
addGroupUserByIds
()
{
//todo 添加群组成员 1.单个/多个到表中,2.调用环信接口更新进去
}
public
function
delGroupUserByIds
()
{
//todo 移除群组成员 1.单个或多个跟新到库, 2.调用环信接口更新
}
public
function
addGroupManage
()
{
//todo 添加群组管理员 1.单个更新到库, 2.调用环信接口更新
}
public
function
delGroupManage
()
{
//todo 移除群组管理员 1.单个更新到库, 2.调用环信接口更新
}
}
\ No newline at end of file
application/chat/service/ChatService.php
View file @
a1e588ac
...
@@ -143,7 +143,7 @@ class ChatService
...
@@ -143,7 +143,7 @@ class ChatService
$rPush
=
new
RPush
();
$rPush
=
new
RPush
();
//todo 消息接收人必须是数据
//todo 消息接收人必须是数据
// $rPush->send($target_type, [$target], $type, $msg_content, $from
, $accessToken, [ $this, 'saveSendStatus' ]);
$rPush
->
send
(
$target_type
,
[
$target
],
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
//返回消息发送成功
//返回消息发送成功
return
true
;
return
true
;
}
}
...
@@ -152,15 +152,19 @@ class ChatService
...
@@ -152,15 +152,19 @@ class ChatService
* 保存推送到环信的消息状态 往msg_status中插入数据
* 保存推送到环信的消息状态 往msg_status中插入数据
* @param $response
* @param $response
* @param $target
* @param $target
* @param $
sender
* @param $
from
* @param $msg_content
* @param $msg_content
*/
*/
public
function
saveSendStatus
(
$response
,
$target
,
$
sender
,
$msg_content
)
public
function
saveSendStatus
(
$response
,
$target
,
$
from
,
$msg_content
)
{
{
/* $response = json_decode($response, true);
$response
=
json_decode
(
$response
,
true
);
$response['time'] = date('Y-m-d H:i:s');
$status
=
$response
[
"data"
][
$target
[
0
]];
$status = $response['statusCode'] == RPush::PUSH_STATUS_SUCCESS ? MsgStatus::STATUS_SUCCESS : MsgStatus::STATUS_FAILURE;
if
(
$status
===
"success"
)
{
$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']);*/
//todo 保存成功
}
// $status = $response['statusCode'] == RPush::PUSH_STATUS_SUCCESS ? MsgStatus::STATUS_SUCCESS : MsgStatus::STATUS_FAILURE;
//$this->insertPushLog($sender, $target, $msg_content, $status, $response['statusMsg']);
}
}
/**
/**
...
...
application/chat/utils/RPush.php
View file @
a1e588ac
<?php
<?php
namespace
app\chat\utils
;
namespace
app\chat\utils
;
use
app\chat\consts\ConfigConst
;
use
app\chat\consts\ConfigConst
;
...
@@ -19,19 +20,19 @@ class RPush
...
@@ -19,19 +20,19 @@ class RPush
* 发送消息
* 发送消息
* @param $target_type
* @param $target_type
* @param $target
* @param $target
* @param $type
* @param $msg_content
* @param $msg_content
* @param $from
* @param $from
* @param $type
* @param $access_token
* @param $access_token
* @param $callback
* @param $callback
*/
*/
public
function
send
(
$target_type
,
$target
,
$
type
,
$msg_content
,
$from
,
$access_token
,
$callback
)
public
function
send
(
$target_type
,
$target
,
$
msg_content
,
$from
,
$type
,
$access_token
,
$callback
)
{
{
//todo 这里做算法优化,环信接口有限制,每个时间段最多能推送多少请求
//todo 这里做算法优化,环信接口有限制,每个时间段最多能推送多少请求
$response
=
$this
->
sendRequestByCurl
(
$target_type
,
$target
,
$msg_content
,
$from
,
$access_token
);
$response
=
$this
->
sendRequestByCurl
(
$target_type
,
$target
,
$msg_content
,
$from
,
$
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
]);
}
}
...
@@ -42,32 +43,33 @@ class RPush
...
@@ -42,32 +43,33 @@ class RPush
* @param $type //目前只有文本的消息
* @param $type //目前只有文本的消息
* @param $msg_content
* @param $msg_content
* @param $from
* @param $from
* @param $type
* @param $access_token
* @param $access_token
* @return \app\chat\utils\CurlResponse|bool
* @return \app\chat\utils\CurlResponse|bool
*/
*/
public
function
sendRequestByCurl
(
$target_type
,
$target
,
$msg_content
,
$from
,
$access_token
)
public
function
sendRequestByCurl
(
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
)
{
{
$arr
=
array
(
$arr
=
array
(
'target_type'
=>
$target_type
,
'target_type'
=>
$target_type
,
'target'
=>
$target
,
'target'
=>
$target
,
'msg'
=>
[
"type"
=>
"txt"
,
"msg"
=>
$msg_content
],
'msg'
=>
[
"type"
=>
"txt"
,
"msg"
=>
$msg_content
],
'from'
=>
$from
,
'from'
=>
$from
,
'ext'
=>
[
"msg_type"
=>
$type
]
);
);
$data
=
json_encode
(
$arr
);
$data
=
json_encode
(
$arr
);
echo
$data
;
echo
"-------------"
;
$curl
=
new
\app\chat\utils\CurlUtil
();
$curl
=
new
\app\chat\utils\CurlUtil
();
$curl
->
headers
=
[
$curl
->
headers
=
[
"Accept"
=>
"application/json"
,
"Accept"
=>
"application/json"
,
"Content-Type"
=>
"application/json;charset=utf-8"
,
"Content-Type"
=>
"application/json;charset=utf-8"
,
'Authorization'
=>
"Bearer "
.
$access_token
,
'Authorization'
=>
"Bearer "
.
$access_token
,
];
];
$curl
->
options
=
[
$curl
->
options
=
[
"CURLOPT_SSL_VERIFYPEER"
=>
0
,
"CURLOPT_SSL_VERIFYPEER"
=>
0
,
"CURLOPT_SSL_VERIFYHOST"
=>
2
,
"CURLOPT_SSL_VERIFYHOST"
=>
2
,
];
];
$url
=
$this
->
buildSendUrl
();
$url
=
$this
->
buildSendUrl
();
$response
=
$curl
->
post
(
$url
,
$data
);
$response
=
$curl
->
post
(
$url
,
$data
);
Log
::
record
(
'info -------------'
,
json_encode
(
$response
)
);
Log
::
record
(
'info -------------'
.
json_encode
(
$response
),
"info"
);
return
$response
;
return
$response
;
}
}
...
...
application/chat/utils/curl_cookie.txt
View file @
a1e588ac
...
@@ -2,4 +2,4 @@
...
@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1516
419232
rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516
687414
rememberMe deleteMe
application/model/ChatMsg.php
View file @
a1e588ac
...
@@ -38,4 +38,44 @@ class ChatMsg extends Model
...
@@ -38,4 +38,44 @@ class ChatMsg extends Model
return
0
;
return
0
;
}
}
/**
* @param $params
* @param $field
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection
*/
public
function
getChatHistory
(
$params
,
$field
,
$page_no
,
$page_size
)
{
if
(
isset
(
$params
[
"from"
]))
{
$where_
[
"a.from_id"
]
=
$params
[
"from"
];
$where_or
[
"a.to_id"
]
=
$params
[
"from"
];
}
if
(
isset
(
$params
[
"target"
]))
{
$where_
[
"a.to_id"
]
=
$params
[
"target"
];
$where_or
[
"a.from_id"
]
=
$params
[
"target"
];
}
if
(
isset
(
$params
[
"is_group"
]))
{
$where_
[
"a.is_group"
]
=
$params
[
"is_group"
];
}
if
(
isset
(
$params
[
"body"
]))
{
$where_
[
"b.body"
]
=
array
(
'like'
,
"%"
.
trim
(
$params
[
"body"
])
.
"%"
);
}
$where_
[
"a.is_del"
]
=
0
;
$data
=
$this
->
field
(
$field
)
->
alias
(
"a"
)
->
join
(
'chat_msg_ext b'
,
'a.id = b.msg_id'
,
'LEFT'
)
->
where
(
$where_
)
->
whereOr
(
function
(
$query
)
use
(
$where_or
)
{
$query
->
where
(
$where_or
);
})
->
order
(
"a.created_at desc"
)
->
limit
(
$page_size
)
->
page
(
$page_no
)
->
select
();
return
$data
;
}
}
}
\ No newline at end of file
application/route.php
View file @
a1e588ac
...
@@ -142,6 +142,7 @@ Route::group('chat', [
...
@@ -142,6 +142,7 @@ Route::group('chat', [
'index'
=>
[
'chat/AppChat/index'
,
[
'method'
=>
'get'
]
],
'index'
=>
[
'chat/AppChat/index'
,
[
'method'
=>
'get'
]
],
'userChat'
=>
[
'chat/AppChat/userChat'
,
[
'method'
=>
'post|get'
]
],
'userChat'
=>
[
'chat/AppChat/userChat'
,
[
'method'
=>
'post|get'
]
],
'pushMsg'
=>
[
'chat/AppChat/pushMsg'
,
[
'method'
=>
'post|get'
]
],
'pushMsg'
=>
[
'chat/AppChat/pushMsg'
,
[
'method'
=>
'post|get'
]
],
'getChatHistory'
=>
[
'chat/AppChat/getChatHistory'
,
[
'method'
=>
'post|get'
]
],
]);
]);
Route
::
group
(
'task'
,[
Route
::
group
(
'task'
,[
...
...
log.txt
View file @
a1e588ac
...
@@ -284,3 +284,55 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
...
@@ -284,3 +284,55 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
</Response>
request body = <TemplateSMS>
<to>15032323232</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>4355</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=157B3CA0CF0C1D232FE6D6758A6F9E77
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756254444</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8064</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=EA2BC31B5B5662AD292223DC686FA26D
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756253333</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7687</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=00F01FFDBFD51AA503BB5585E4D2DC21
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>13112341234</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>8858</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=873B52C43862749A39926C652B5834DC
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
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