Commit 83f6c7cd authored by clone's avatar clone Committed by hujun

user_name

parent 9d906ca5
......@@ -134,11 +134,12 @@ class AppChat extends Basic
$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'])) {
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, "请求参数错误");
}
/* $params = array(
'user_name' => 'cesh',
'msg_content' => 'ceshi666',
'target_type' => 'users',
'source' => '1',
......@@ -147,6 +148,7 @@ class AppChat extends Basic
'is_user' => '0',
'target' => '18112347151',
);*/
$user_name = isset($params['user_name']) ? $params['user_name'] : $params['from'];//用户昵称
$target_type = $params['target_type']; // 消息类型 users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
$target = $params['target']; //接受人 if target_type 群 者表示群id
$source = $params['source']; //消息来源 1c端app 2b端app 3其他
......@@ -158,7 +160,7 @@ class AppChat extends Basic
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) {
return $this->response("200", "", [ "msg" => "消息发送成功" ]);
} else {
......@@ -238,7 +240,7 @@ class AppChat extends Basic
$params = $this->params;
/*$params['id']=4762;
$params['from']='b';*/
if (!isset($params['id']) || !isset($params['from']) ) {
if (!isset($params['id']) || !isset($params['from'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$id = $params['id'];
......@@ -250,7 +252,7 @@ class AppChat extends Basic
if ($HouseInfosre) {
$data['title'] = $HouseInfosre[0]['title'];
if ($from == 'c'){
if ($from == 'c') {
//副表查询c端显示名称
$HouseinfoExts = new HouseinfoExts();
$HouseinfoExtsInfosre = $HouseinfoExts->getHouse_ext($id);
......
......@@ -129,6 +129,7 @@ class ChatService
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $source
......
......@@ -19,6 +19,7 @@ class RPush
/**
* 发送消息
* @param $user_name
* @param $target_type
* @param $target
* @param $msg_content
......@@ -27,7 +28,7 @@ class RPush
* @param $access_token
* @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
if(Cache::get('save_message_num')){
......@@ -43,13 +44,14 @@ class RPush
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 ]);
}
/** curl参数拼凑
* @param $user_name
* @param $target_type users 给用户发消息。chatgroups: 给群发消息,chatrooms: 给聊天室发消息
* @param $target 注意这里需要用数组,数组长度建议不大于20,即使只有一个用户,也要用数组 ['u1'],给用户发送时数组元素是用户名,
* 给群组发送时数组元素是groupid
......@@ -60,14 +62,14 @@ class RPush
* @param $access_token
* @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(
'target_type' => $target_type,
'target' => $target,
'msg' => [ "type" => "txt", "msg" => $msg_content ],
'from' => $from,
'ext' => [ "msg_type" => $type ]
'ext' => [ "msg_type" => $type ,"user_name"=>$user_name]
);
$data = json_encode($arr);
$curl = new \app\chat\utils\CurlUtil();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment