Commit 6cff2598 authored by zw's avatar zw

liaotian

parent bccd9dd1
...@@ -323,7 +323,7 @@ class AppChat extends Basic ...@@ -323,7 +323,7 @@ class AppChat extends Basic
{ {
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"target" => "121" "target" => "agent_5775"
);*/ );*/
if (!isset($params['target'])) { if (!isset($params['target'])) {
return $this->response("300", "参数不全"); return $this->response("300", "参数不全");
......
...@@ -378,8 +378,10 @@ class ChatService ...@@ -378,8 +378,10 @@ class ChatService
$chatRelationModel = new ChatRelation(); $chatRelationModel = new ChatRelation();
$params["target"] = $target; $params["target"] = $target;
$params["from"] = $target; $params["from"] = $target;
$field = "id,to_id,from_id,create_time"; $field = "a.id,a.to_id,a.from_id,a.create_time,b.type,b.id as user_or_agent_id,b.only_id,
return $chatRelationModel->getChatRelation($params, $field); c.name as agent_name,c.img,d.user_name,d.user_phone,d.user_nick,d.user_pic,d.other_pic";
return $chatRelationModel->getChatRelationInfo($params, $field);
} }
/** /**
......
...@@ -56,6 +56,39 @@ class ChatRelation extends Model ...@@ -56,6 +56,39 @@ class ChatRelation extends Model
} }
/**
* 获取关系是否存在
* @param $params
* @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getChatRelationInfo($params, $field)
{
$where_ = $whereOr_ = [];
$only_id = $params["target"];
if (isset($params["target"])) {
$where_["a.to_id"] = $params["target"];
$whereOr_["a.from_id"] = $params["target"];
}
$where_["disable"] = 0;
$whereOr_["disable"] = 0;
return $this->field($field)
->alias("a")
->join("chat_user b","a.to_id !=$only_id and a.to_id=b.only_id or a.from_id=b.only_id","left")
->join("a_agents c","b.type = 1 and b.id = c.id","left")
->join("u_users d","b.type =2 and b.id=d.id","left")
->where($where_)
->whereOr(function ($query) use ($whereOr_) {
$query->where($whereOr_);
})
->select();
}
public function addChatRelation($params) public function addChatRelation($params)
{ {
$where_ = []; $where_ = [];
......
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