Commit 99181dda authored by hujun's avatar hujun

user name

parent ed0d6d26
...@@ -222,24 +222,37 @@ class ChatService ...@@ -222,24 +222,37 @@ class ChatService
$user_id = 0; $user_id = 0;
$where['type'] = 1; $where['type'] = 1;
$user_type = 1; $user_type = 1;
foreach ($user_arr as $item) { foreach ($user_arr as $item) {
if ($item["only_id"] == $from) { if ($item["only_id"] == $from) {
$user_id = empty($user_arr['user_id']) ? 0 : $user_arr['user_id']; $user_id = empty($item['user_id']) ? 0 : $item['user_id'];
} else { } else {
$where['type'] = $item["type"]; $where['type'] = $item["type"];
$user_type = $item["type"]; $user_type = $item["type"];
} }
} }
$info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id,b.user_id'); $info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id,b.user_id');
if (count($info) <= 0) { if (count($info) <= 0) {
return false; return false;
} }
if ($user_type == 1) {
$user_data = $this->userModel->getUserById('user_phone', $user_id);
$user_info['id'] = $user_id;
$user_info['phone'] = $user_data['user_phone'];
} else {
$agent_data = $this->agentsV2Model->getAgentInfo('phone', $user_id);
$user_info['id'] = $user_id;
$user_info['phone'] = $agent_data['phone'];
}
$push_id = []; $push_id = [];
foreach ($info as $item) { foreach ($info as $item) {
array_push($push_id, $item["push_id"]); array_push($push_id, $item["push_id"]);
} }
$rPush->send($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, [ $this, 'saveSendStatus' ], $push_id, $msg_id, $user_id); $rPush->send($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, [ $this, 'saveSendStatus' ], $push_id, $msg_id, $user_info);
return true; return true;
} }
......
...@@ -29,9 +29,9 @@ class RPush ...@@ -29,9 +29,9 @@ class RPush
* @param $callback * @param $callback
* @param $push_id * @param $push_id
* @param $msg_id * @param $msg_id
* @param $user_id * @param $user_info
*/ */
public function send($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $callback, $push_id, $msg_id, $user_id) public function send($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $callback, $push_id, $msg_id, $user_info)
{ {
//todo //todo
if (Cache::get('save_message_num')) { if (Cache::get('save_message_num')) {
...@@ -47,7 +47,7 @@ class RPush ...@@ -47,7 +47,7 @@ class RPush
Cache::set('save_message_num', 0); Cache::set('save_message_num', 0);
} }
$response = $this->sendRequestByCurl($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $push_id, $msg_id, $user_id); $response = $this->sendRequestByCurl($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $push_id, $msg_id, $user_info);
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 ]);
} }
...@@ -63,10 +63,10 @@ class RPush ...@@ -63,10 +63,10 @@ class RPush
* @param $type * @param $type
* @param $push_id * @param $push_id
* @param $message_id * @param $message_id
* @param $user_id * @param $user_info
* @return array * @return array
*/ */
public function sendRequestByCurl($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $push_id, $message_id, $user_id) public function sendRequestByCurl($user_name, $target_type, $target, $msg_content, $from, $user_type, $type, $push_id, $message_id, $user_info)
{ {
$title = "收到一条消息"; $title = "收到一条消息";
...@@ -88,9 +88,11 @@ class RPush ...@@ -88,9 +88,11 @@ class RPush
'from_id' => $from, 'from_id' => $from,
'created_at' => date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'message_id' => $message_id, 'message_id' => $message_id,
'user_id' => $user_id 'user_id' => $user_info['id'],
'phone' => $user_info['phone']
] ]
); );
$payload = json_encode($msg_bin); $payload = json_encode($msg_bin);
$pushMessageToIgt = new GeTuiUtils(); $pushMessageToIgt = new GeTuiUtils();
......
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