Commit 706eadd7 authored by clone's avatar clone

bug

parent 83a8ac97
......@@ -321,8 +321,8 @@ class AppChat extends Basic
public function getChatRelation()
{
$params = $this->params;
/* $params = array(
"target" => "agent_5775",
/* $params = array(
"target" => "agent_5739",
"is_user"=> 0,//0用户1经纪人
);*/
if (!isset($params['target']) || !isset($params["is_user"])) {
......
......@@ -415,10 +415,30 @@ class ChatService
$result[$key]["img"] = $item["img"];
$result[$key]["phone"] = $item["phone"];
}
$result[$key]["only_id"] = $item["only_id"];
$select_["from"] = $item["from_id"];
$select_["target"] = $item["to_id"];
$result[$key]["chat_info"] = $msgModel->getChatHistory($select_, $fields, 1, 1);
$result[$key]["only_id"] = $item["only_id"];
$select_["from"] = $item["from_id"];
$select_["target"] = $item["to_id"];
$chat_info = $msgModel->getChatHistory($select_, $fields, 1, 1);
if (count($chat_info) > 0) {
$result[$key]["chat_info"] = $chat_info[0];
} else {
unset($result[$key]);
}
}
return $this->sortByTime(array_values($result));
}
private function sortByTime($result)
{
for ($i = 0; $i < count($result); $i++) {
for ($j = $i + 1; $j < count($result); $j++) {
if (strtotime($result[$j]["chat_info"]["created_at"]) - strtotime($result[$i]["chat_info"]["created_at"]) > 0) {
$temp = $result[$j];
$result[$j] = $result[$i];
$result[$i] = $temp;
}
}
}
return $result;
}
......
......@@ -86,8 +86,9 @@ class ChatRelation extends Model
->whereOr(function ($query) use ($whereOr_) {
$query->where($whereOr_);
})
->group("a.to_id,a.from_id")
->select();
echo $this->getLastSql();
//echo $this->getLastSql();
return $date;
}
......
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