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
8cf2aff0
Commit
8cf2aff0
authored
Jan 19, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chat build
parent
19ca4f31
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
42 deletions
+96
-42
ErrorCodeConst.php
application/chat/consts/ErrorCodeConst.php
+2
-6
AppChat.php
application/chat/controller/AppChat.php
+31
-10
ChatService.php
application/chat/service/ChatService.php
+22
-23
RPush.php
application/chat/utils/RPush.php
+0
-1
RegisterUtil.php
application/chat/utils/RegisterUtil.php
+0
-1
curl_cookie.txt
application/chat/utils/curl_cookie.txt
+1
-1
route.php
application/route.php
+1
-0
log.txt
log.txt
+39
-0
No files found.
application/chat/consts/ErrorCodeConst.php
View file @
8cf2aff0
...
...
@@ -12,10 +12,5 @@ class ErrorCodeConst
{
//聊天
const
ERROR_CODE_PARAM_NOT_EXIST
=
110001
;
const
ERROR_CODE_NOT_FRIENDS
=
170002
;
const
ERROR_CODE_ALREADY_FRIENDS
=
170003
;
const
ERROR_CODE_REMARK_TOO_LONG
=
170004
;
const
ERROR_CODE_PARAM_ILLEGAL
=
170005
;
const
ERROR_CODE_MSG_NOT_EXIST
=
170006
;
const
ERROR_CODE_IS_NOT_ONLINE
=
170007
;
const
ERROR_CODE_TARGET_TYPE_ERROR
=
110002
;
}
\ No newline at end of file
application/chat/controller/AppChat.php
View file @
8cf2aff0
...
...
@@ -69,12 +69,12 @@ class AppChat extends Basic
public
function
userChat
()
{
/* $params = array(
"user_id" =>
2
,
"mobile" => "1
8205625020
",
"user_id" =>
1
,
"mobile" => "1
5720682761
",
"source" => 2 //1经纪人 2用户
);*/
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'user_id'
])
||
!
isset
(
$params
[
'mobile'
])
||
!
isset
(
$params
[
'source'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
...
...
@@ -90,24 +90,45 @@ class AppChat extends Basic
}
else
{
return
$this
->
response
(
"101"
,
$only_arr
[
"msg"
]);
}
}
/**
* c端根据经纪人的手机号获取唯一id
* @return \think\Response
*/
public
function
getAgentOnlyId
()
{
//todo
return
$this
->
response
(
"200"
,
"success"
,
""
);
}
/**
* 发送消息接口
* @return \think\Response
*/
public
function
pushMsg
()
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'target_type'
])
||
!
isset
(
$params
[
'target'
])
||
!
isset
(
$params
[
'type'
])
||
!
isset
(
$params
[
'msg_content'
])
||
!
isset
(
$params
[
'source'
])
||
!
isset
(
$params
[
'is_user'
])
||
!
isset
(
$params
[
'from'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target
=
$params
[
'target'
];
//发送人 if target_type 群 者表示群id
$type
=
$params
[
'type'
];
//消息类型 1文字 2图片
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
$is_user
=
$params
[
'is_user'
];
//发送人是否是会员 0是1经济人
$type
=
$params
[
'type'
];
//消息类型 1文字 2图片 3楼盘
$msg_content
=
$params
[
'msg_content'
];
$from
=
$params
[
'from'
];
//消息发送人
if
(
!
$target_type
||
!
$target
||
!
$type
||
!
$msg_content
||
!
$from
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
if
(
$target_type
!=
"users"
&&
$target_type
!=
"chatgroups"
&&
$target_type
!=
"chatrooms"
)
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_TARGET_TYPE_ERROR
,
"错误的消息类型"
);
}
$result
=
$this
->
_chat
->
sendMsg
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$this
->
accessToken
);
$result
=
$this
->
_chat
->
sendMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$this
->
accessToken
);
if
(
count
(
$result
)
>
0
)
{
return
$this
->
response
(
"200"
,
[
"msg"
=>
"消息发送成功"
]);
}
...
...
application/chat/service/ChatService.php
View file @
8cf2aff0
...
...
@@ -29,7 +29,7 @@ class ChatService
const
MSG_TYPE_CHAT_GROUPS
=
"chatgroups"
;
//给群发消息
const
MSG_TYPE_CHAT_CHAT_ROOMS
=
"chatrooms"
;
//给聊天室发消息
const
SOURCE_TYPE_APP
=
'
app
_'
;
// 用户 c端
const
SOURCE_TYPE_APP
=
'
user
_'
;
// 用户 c端
const
SOURCE_TYPE_AGENT
=
'agent_'
;
//经纪人 b端
...
...
@@ -125,29 +125,18 @@ class ChatService
* 发送消息
* @param $target_type
* @param $target
* @param $source
* @param $is_user
* @param $type
* @param $msg_content
* @param $from
* @param $accessToken
* @return bool
*/
public
function
sendMsg
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$accessToken
)
public
function
sendMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
{
switch
(
$target_type
)
{
case
self
::
MSG_TYPE_USERS
:
//todo 判断用户是否存在
break
;
case
self
::
MSG_TYPE_CHAT_GROUPS
:
//todo 判断组群是否存在
break
;
case
self
::
MSG_TYPE_CHAT_CHAT_ROOMS
:
//todo 判断聊天室是否存在
break
;
default
:
return
[
"code"
=>
101
,
"msg"
=>
"消息类型错误"
];
}
//todo
$this
->
insertMsg
();
$this
->
insertMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
);
$rPush
=
new
RPush
();
$rPush
->
send
(
$target_type
,
$target
,
$type
,
$msg_content
,
$from
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
//返回消息发送成功
...
...
@@ -171,17 +160,27 @@ class ChatService
/**
* 保存用户发送的消息
* @param $
sender
* @param $
receiver
* @param $
group_id
* @param $
msg_content
* @param $
target_type
* @param $
target
* @param $
source
* @param $
is_user
* @param $type
* @param $msg_
filename
* @param $
msg_file_url
* @param $msg_
content
* @param $
from
*/
private
function
insertMsg
(
$
sender
,
$receiver
,
$group_id
,
$msg_content
,
$type
,
$msg_filename
,
$msg_file_url
)
private
function
insertMsg
(
$
target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
)
{
//todo
$params
[
"msg_type"
]
=
1
;
//目前只用到了环信的文本消息
$params
[
"to_id"
]
=
$target
;
$params
[
"from_id"
]
=
$from
;
$params
[
"is_group"
]
=
$target_type
==
"users"
?
0
:
1
;
$params
[
"account_type"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"source"
]
=
$source
;
$params
[
"is_user"
]
=
$is_user
;
$params
[
"created_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$params
[
"updated_at"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$this
->
chatUserModel
->
addChatUser
(
$params
);
}
/** 获取聊天记录
...
...
application/chat/utils/RPush.php
View file @
8cf2aff0
...
...
@@ -52,7 +52,6 @@ class RPush
'msg'
=>
[
"type"
=>
$type
,
"msg"
=>
$msg_content
],
'from'
=>
$from
,
);
$data
=
json_encode
(
$arr
);
$curl
=
new
\app\chat\utils\CurlUtil
();
...
...
application/chat/utils/RegisterUtil.php
View file @
8cf2aff0
...
...
@@ -30,7 +30,6 @@ class RegisterUtil
'username'
=>
$username
,
'password'
=>
$password
,
);
$data
=
json_encode
(
$arr
);
$curl
=
new
CurlUtil
();
...
...
application/chat/utils/curl_cookie.txt
View file @
8cf2aff0
...
...
@@ -2,4 +2,4 @@
# http://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
a1.easemob.com FALSE / FALSE 1516
264437
rememberMe deleteMe
a1.easemob.com FALSE / FALSE 1516
352505
rememberMe deleteMe
application/route.php
View file @
8cf2aff0
...
...
@@ -141,6 +141,7 @@ Route::group('api', [
Route
::
group
(
'chat'
,
[
'index'
=>
[
'chat/AppChat/index'
,
[
'method'
=>
'get'
]
],
'userChat'
=>
[
'chat/AppChat/userChat'
,
[
'method'
=>
'post|get'
]
],
'sendMsg'
=>
[
'chat/AppChat/sendMsg'
,
[
'method'
=>
'post|get'
]
],
]);
Route
::
group
(
'task'
,[
...
...
log.txt
View file @
8cf2aff0
...
...
@@ -206,3 +206,42 @@ response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756258888</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7572</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=1566AAB75F25B6DD28A4902FA26AEC0F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756259999</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>3479</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=DE9865EE495BD9B0D85EDAF249CDA24F
response body = <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response>
<statusCode>160053</statusCode>
<statusMsg>IP鉴权失败</statusMsg>
</Response>
request body = <TemplateSMS>
<to>18756257777</to>
<appId>8a216da85f5c89b1015f7718e2b90a63</appId>
<templateId>214759</templateId>
<datas><data>7094</data><data>5分钟</data></datas>
</TemplateSMS>
request url = https://app.cloopen.com:8883/2013-12-26/Accounts/8a48b55153eae51101540e763d3b3888/SMS/TemplateSMS?sig=7977CEC21F534DD1E5D675D792595DC9
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