Commit 97a31205 authored by clone's avatar clone

关系处理

parent aaee822f
...@@ -322,9 +322,9 @@ class AppChat extends Basic ...@@ -322,9 +322,9 @@ class AppChat extends Basic
public function getChatRelation() public function getChatRelation()
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"target" => "user_2", "target" => "agent_5739", //当前用户
"is_user" => 1,//1用户2经纪人 "is_user" => 1,//0用户1经纪人
"relation_list" => '[{"r_id":"2","msg_id":3536},{"r_id":"8","msg_id":3524}]', "relation_list" => '[{"r_id":"2","msg_id":3536},{"r_id":"8","msg_id":3524}]',
);*/ );*/
if (!isset($params['target']) || !isset($params["is_user"])) { if (!isset($params['target']) || !isset($params["is_user"])) {
......
...@@ -204,7 +204,7 @@ class ChatService ...@@ -204,7 +204,7 @@ class ChatService
$this->verifyRelation($target, $from); $this->verifyRelation($target, $from);
$msg_id = $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from); $msg_id = $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush(); $rPush = new RPush();
// 消息接收人必须是数组 // 消息接收人必须是数组
$userExt = new ChatUserExt(); $userExt = new ChatUserExt();
...@@ -361,7 +361,7 @@ class ChatService ...@@ -361,7 +361,7 @@ class ChatService
if ($target_type != "users") { if ($target_type != "users") {
$group_id = $from; $group_id = $from;
} }
return $this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id); return $this->insetMsgExt($id, $type, $msg_content, $params["is_group"], $group_id);
} }
} }
...@@ -399,6 +399,7 @@ class ChatService ...@@ -399,6 +399,7 @@ class ChatService
*/ */
public function getRelationList($target, $is_user, $relation_list) public function getRelationList($target, $is_user, $relation_list)
{ {
//查询出所有关于我的聊天关系
$chatRelationModel = new ChatRelation(); $chatRelationModel = new ChatRelation();
$params["target"] = $target; $params["target"] = $target;
$params["from"] = $target; $params["from"] = $target;
...@@ -407,16 +408,20 @@ class ChatService ...@@ -407,16 +408,20 @@ class ChatService
$relationList = $chatRelationModel->getChatRelationInfo($params, $field); $relationList = $chatRelationModel->getChatRelationInfo($params, $field);
$result = []; $result = [];
$fields = "a.id,a.from_id,a.to_id,b.body,b.type,a.created_at"; $fields = "a.id,a.from_id,a.to_id,b.body,b.type,a.created_at";
$msgModel = new ChatMsg(); $msgModel = new ChatMsg();
foreach ($relationList as $key => $item) { foreach ($relationList as $key => $item) {
$result[$key]["id"] = $item["id"];//关系id
//对方的only_id
if ($item["from_id"] == $target) { if ($item["from_id"] == $target) {
$result[$key]["relation_id"] = $item["to_id"]; $result[$key]["relation_id"] = $item["to_id"];
} else { } else {
$result[$key]["relation_id"] = $item["from_id"]; $result[$key]["relation_id"] = $item["from_id"];
} }
if ($is_user == 1) { //显示不是当前传入用户的用户信息 对方只能是一个人 如果不是用户则是经纪人
if (!empty($item["user_phone"])) {
$result[$key]["name"] = empty($item["user_nick"]) ? $item["user_name"] : $item["user_nick"]; $result[$key]["name"] = empty($item["user_nick"]) ? $item["user_name"] : $item["user_nick"];
$result[$key]["img"] = empty($item["user_pic"]) ? $item["other_pic"] : $item["user_pic"]; $result[$key]["img"] = empty($item["user_pic"]) ? $item["other_pic"] : $item["user_pic"];
$result[$key]["phone"] = $item["user_phone"]; $result[$key]["phone"] = $item["user_phone"];
...@@ -425,14 +430,15 @@ class ChatService ...@@ -425,14 +430,15 @@ class ChatService
$result[$key]["img"] = $item["img"]; $result[$key]["img"] = $item["img"];
$result[$key]["phone"] = $item["phone"]; $result[$key]["phone"] = $item["phone"];
} }
$result[$key]["id"] = $item["id"];
$result[$key]["only_id"] = $item["only_id"]; //where
$select_["from"] = $item["from_id"]; $select_["from"] = $item["from_id"];
$select_["target"] = $item["to_id"]; $select_["target"] = $item["to_id"];
$chat_info = $msgModel->getChatHistory($select_, $fields, 1, 1);
if (!empty($relation_list)) { //获取最后一条消息记录
$chat_info = $msgModel->getChatHistory($select_, $fields, 1, 1);
if (!empty($relation_list)) {
if ($select_["target"] == $target) { if ($select_["target"] == $target) {
$where_["to_id"] = $select_["target"]; $where_["to_id"] = $select_["target"];
$where_["from_id"] = $select_["from"]; $where_["from_id"] = $select_["from"];
......
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