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

user_name

parent 9d906ca5
...@@ -134,11 +134,12 @@ class AppChat extends Basic ...@@ -134,11 +134,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',
...@@ -147,6 +148,7 @@ class AppChat extends Basic ...@@ -147,6 +148,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其他
...@@ -158,7 +160,7 @@ class AppChat extends Basic ...@@ -158,7 +160,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 {
...@@ -238,11 +240,11 @@ class AppChat extends Basic ...@@ -238,11 +240,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);
...@@ -250,9 +252,9 @@ class AppChat extends Basic ...@@ -250,9 +252,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'] : '未知商铺';
......
...@@ -129,6 +129,7 @@ class ChatService ...@@ -129,6 +129,7 @@ class ChatService
/** /**
* 发送消息 * 发送消息
* @param $user_name
* @param $target_type * @param $target_type
* @param $target * @param $target
* @param $source * @param $source
......
...@@ -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();
......
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