Commit 20665918 authored by clone's avatar clone

bug

parent e67d830e
......@@ -322,10 +322,10 @@ class AppChat extends Basic
public function getChatRelation()
{
$params = $this->params;
/* $params = array(
"target" => "agent_5739",
"is_user" => 1,//0用户1经纪人
"relation_list" => '[{"r_id":"13","msg_id":2868},{"r_id":"12","msg_id":2849}]',
/* $params = array(
"target" => "user_2",
"is_user" => 0,//0用户1经纪人
"relation_list" => '[{"r_id":"2","msg_id":3536},{"r_id":"8","msg_id":3524}]',
);*/
if (!isset($params['target']) || !isset($params["is_user"])) {
return $this->response("300", "参数不全");
......
......@@ -211,12 +211,12 @@ class ChatService
$where['only_id'] = $target;
if ($is_user) {
$where['type'] = 2;
$where['type'] = 2;
} else {
$where['type'] = 1;
$where['type'] = 1;
}
$info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id');
$info = $userExt->getChatUserExtByUserId($where, 'a.id,a.ext_id,a.device_id,a.push_id');
if (count($info) <= 0) {
return false;
......@@ -431,14 +431,21 @@ class ChatService
$chat_info = $msgModel->getChatHistory($select_, $fields, 1, 1);
if (!empty($relation_list)) {
$where_ = $select_;
if ($select_["target"] == $target) {
$where_["to_id"] = $select_["target"];
$where_["from_id"] = $select_["from"];
} else {
$where_["to_id"] = $select_["from"];
$where_["from_id"] = $select_["target"];
}
try {
$where_["id"] = array( "between", array( $relation_list[$item["id"]][0]["msg_id"], $chat_info[0]["id"] ) );
//计算未读消息个数
$unread_count = $msgModel->getTotalUnread($where_, "id");
//dump($unread_count);
$result[$key]["unread"] = $unread_count > 0 ? $unread_count-1 : 0;
$result[$key]["unread"] = $unread_count > 0 ? $unread_count - 1 : 0;
} catch (Exception $exception) {
$result[$key]["unread"] = 0;
}
......
......@@ -81,12 +81,12 @@ class ChatMsg extends Model
public function getTotalUnread($params, $field)
{
if (isset($params["from"])) {
$where_["a.from_id"] = $params["from"];
if (isset($params["to_id"])) {
$where_["a.to_id"] = $params["to_id"];
//$where_or["a.to_id"] = $params["from"];
}
if (isset($params["target"])) {
$where_["a.to_id"] = $params["target"];
if (isset($params["from_id"])) {
$where_["a.from_id"] = $params["from_id"];
//$where_or["a.from_id"] = $params["target"];
}
if (isset($params["id"])) {
......@@ -104,7 +104,6 @@ class ChatMsg extends Model
})*/
->order("a.created_at desc")
->count();
//echo $this->getLastSql();
return $data;
}
......
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