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
8657770f
Commit
8657770f
authored
Feb 09, 2018
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user_name
parent
81d1c931
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
AppChat.php
application/chat/controller/AppChat.php
+10
-8
ChatService.php
application/chat/service/ChatService.php
+3
-2
RPush.php
application/chat/utils/RPush.php
+6
-4
No files found.
application/chat/controller/AppChat.php
View file @
8657770f
...
@@ -131,11 +131,12 @@ class AppChat extends Basic
...
@@ -131,11 +131,12 @@ class AppChat extends Basic
$params
=
$this
->
params
;
$params
=
$this
->
params
;
if
(
!
isset
(
$params
[
'target_type'
])
||
!
isset
(
$params
[
'target'
])
||
!
isset
(
$params
[
'type'
])
||
!
isset
(
$params
[
'msg_content'
])
if
(
!
isset
(
$params
[
'target_type'
])
||
!
isset
(
$params
[
'target'
])
||
!
isset
(
$params
[
'type'
])
||
!
isset
(
$params
[
'source'
])
||
!
isset
(
$params
[
'is_user'
])
||
!
isset
(
$params
[
'from'
]))
{
||
!
isset
(
$params
[
'
msg_content'
])
||
!
isset
(
$params
[
'
source'
])
||
!
isset
(
$params
[
'is_user'
])
||
!
isset
(
$params
[
'from'
]))
{
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_PARAM_NOT_EXIST
,
"请求参数错误"
);
}
}
/* $params = array(
/* $params = array(
'user_name' => 'cesh',
'msg_content' => 'ceshi666',
'msg_content' => 'ceshi666',
'target_type' => 'users',
'target_type' => 'users',
'source' => '1',
'source' => '1',
...
@@ -144,6 +145,7 @@ class AppChat extends Basic
...
@@ -144,6 +145,7 @@ class AppChat extends Basic
'is_user' => '0',
'is_user' => '0',
'target' => '18112347151',
'target' => '18112347151',
);*/
);*/
$user_name
=
isset
(
$params
[
'user_name'
])
?
$params
[
'user_name'
]
:
$params
[
'from'
];
//用户昵称
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target_type
=
$params
[
'target_type'
];
// 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$target
=
$params
[
'target'
];
//接受人 if target_type 群 者表示群id
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
$source
=
$params
[
'source'
];
//消息来源 1c端app 2b端app 3其他
...
@@ -155,7 +157,7 @@ class AppChat extends Basic
...
@@ -155,7 +157,7 @@ class AppChat extends Basic
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_TARGET_TYPE_ERROR
,
"错误的消息类型"
);
return
$this
->
response
(
ErrorCodeConst
::
ERROR_CODE_TARGET_TYPE_ERROR
,
"错误的消息类型"
);
}
}
$result
=
$this
->
_chat
->
sendMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$this
->
accessToken
);
$result
=
$this
->
_chat
->
sendMsg
(
$
user_name
,
$
target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$this
->
accessToken
);
if
(
$result
)
{
if
(
$result
)
{
return
$this
->
response
(
"200"
,
""
,
[
"msg"
=>
"消息发送成功"
]);
return
$this
->
response
(
"200"
,
""
,
[
"msg"
=>
"消息发送成功"
]);
}
else
{
}
else
{
...
@@ -233,11 +235,11 @@ class AppChat extends Basic
...
@@ -233,11 +235,11 @@ class AppChat extends Basic
$params
=
$this
->
params
;
$params
=
$this
->
params
;
/*$params['id']=4762;
/*$params['id']=4762;
$params['from']='b';*/
$params['from']='b';*/
if
(
!
isset
(
$params
[
'id'
])
||
!
isset
(
$params
[
'from'
])
)
{
if
(
!
isset
(
$params
[
'id'
])
||
!
isset
(
$params
[
'from'
]))
{
return
$this
->
response
(
"300"
,
"参数不全"
,
[
'remote_groupid'
=>
''
]);
return
$this
->
response
(
"300"
,
"参数不全"
,
[
'remote_groupid'
=>
''
]);
}
}
$id
=
$params
[
'id'
];
$id
=
$params
[
'id'
];
$from
=
$params
[
'from'
];
$from
=
$params
[
'from'
];
//主表查询商铺详细信息
//主表查询商铺详细信息
$HouseInfos
=
new
HouseInfos
();
$HouseInfos
=
new
HouseInfos
();
$HouseInfosre
=
$HouseInfos
->
getHousepusmessage
(
$id
);
$HouseInfosre
=
$HouseInfos
->
getHousepusmessage
(
$id
);
...
@@ -245,9 +247,9 @@ class AppChat extends Basic
...
@@ -245,9 +247,9 @@ class AppChat extends Basic
if
(
$HouseInfosre
)
{
if
(
$HouseInfosre
)
{
$data
[
'title'
]
=
$HouseInfosre
[
0
][
'title'
];
$data
[
'title'
]
=
$HouseInfosre
[
0
][
'title'
];
if
(
$from
==
'c'
){
if
(
$from
==
'c'
)
{
//副表查询c端显示名称
//副表查询c端显示名称
$HouseinfoExts
=
new
HouseinfoExts
();
$HouseinfoExts
=
new
HouseinfoExts
();
$HouseinfoExtsInfosre
=
$HouseinfoExts
->
getHouse_ext
(
$id
);
$HouseinfoExtsInfosre
=
$HouseinfoExts
->
getHouse_ext
(
$id
);
//dump($HouseinfoExtsInfosre);
//dump($HouseinfoExtsInfosre);
$data
[
'title'
]
=
$HouseinfoExtsInfosre
[
0
][
'foreign_name'
]
?
$HouseinfoExtsInfosre
[
0
][
'foreign_name'
]
:
'未知商铺'
;
$data
[
'title'
]
=
$HouseinfoExtsInfosre
[
0
][
'foreign_name'
]
?
$HouseinfoExtsInfosre
[
0
][
'foreign_name'
]
:
'未知商铺'
;
...
...
application/chat/service/ChatService.php
View file @
8657770f
...
@@ -131,6 +131,7 @@ class ChatService
...
@@ -131,6 +131,7 @@ class ChatService
/**
/**
* 发送消息
* 发送消息
* @param $user_name
* @param $target_type
* @param $target_type
* @param $target
* @param $target
* @param $source
* @param $source
...
@@ -141,7 +142,7 @@ class ChatService
...
@@ -141,7 +142,7 @@ class ChatService
* @param $accessToken
* @param $accessToken
* @return bool
* @return bool
*/
*/
public
function
sendMsg
(
$target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
public
function
sendMsg
(
$
user_name
,
$
target_type
,
$target
,
$source
,
$is_user
,
$type
,
$msg_content
,
$from
,
$accessToken
)
{
{
//fixme 之后扩展 此处有bug
//fixme 之后扩展 此处有bug
/* if ($type == 3) {
/* if ($type == 3) {
...
@@ -164,7 +165,7 @@ class ChatService
...
@@ -164,7 +165,7 @@ class ChatService
$rPush
=
new
RPush
();
$rPush
=
new
RPush
();
//todo 消息接收人必须是数据
//todo 消息接收人必须是数据
$rPush
->
send
(
$target_type
,
[
$target
],
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
$rPush
->
send
(
$
user_name
,
$
target_type
,
[
$target
],
$msg_content
,
$from
,
$type
,
$accessToken
,
[
$this
,
'saveSendStatus'
]);
//返回消息发送成功
//返回消息发送成功
return
true
;
return
true
;
}
}
...
...
application/chat/utils/RPush.php
View file @
8657770f
...
@@ -19,6 +19,7 @@ class RPush
...
@@ -19,6 +19,7 @@ class RPush
/**
/**
* 发送消息
* 发送消息
* @param $user_name
* @param $target_type
* @param $target_type
* @param $target
* @param $target
* @param $msg_content
* @param $msg_content
...
@@ -27,7 +28,7 @@ class RPush
...
@@ -27,7 +28,7 @@ class RPush
* @param $access_token
* @param $access_token
* @param $callback
* @param $callback
*/
*/
public
function
send
(
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
,
$callback
)
public
function
send
(
$
user_name
,
$
target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
,
$callback
)
{
{
//todo
//todo
if
(
Cache
::
get
(
'save_message_num'
)){
if
(
Cache
::
get
(
'save_message_num'
)){
...
@@ -43,13 +44,14 @@ class RPush
...
@@ -43,13 +44,14 @@ class RPush
Cache
::
set
(
'save_message_num'
,
0
);
Cache
::
set
(
'save_message_num'
,
0
);
}
}
$response
=
$this
->
sendRequestByCurl
(
$target_type
,
$target
,
$msg_content
,
$from
,
$type
,
$access_token
);
$response
=
$this
->
sendRequestByCurl
(
$
user_name
,
$
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
]);
}
}
/** curl参数拼凑
/** curl参数拼凑
* @param $user_name
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
* 给群组发送时数组元素是groupid
...
@@ -60,14 +62,14 @@ class RPush
...
@@ -60,14 +62,14 @@ class RPush
* @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
,
$type
,
$access_token
)
public
function
sendRequestByCurl
(
$
user_name
,
$
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
]
'ext'
=>
[
"msg_type"
=>
$type
,
"user_name"
=>
$user_name
]
);
);
$data
=
json_encode
(
$arr
);
$data
=
json_encode
(
$arr
);
$curl
=
new
\app\chat\utils\CurlUtil
();
$curl
=
new
\app\chat\utils\CurlUtil
();
...
...
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