Commit 55d9b61e authored by clone's avatar clone

bug

parent f8195f19
......@@ -322,10 +322,10 @@ class AppChat extends Basic
public function getChatRelation()
{
$params = $this->params;
/* $params = array(
/* $params = array(
"target" => "agent_5739",
"is_user" => 0,//0用户1经纪人
"relation_list" => '[ { "r_id" : 12, "msg_id" : 111}, { "r_id" : 11, "msg_id" : 111}]',
"is_user" => 1,//0用户1经纪人
"relation_list" => '[{"r_id":"13","msg_id":2868},{"r_id":"12","msg_id":2849}]',
);*/
if (!isset($params['target']) || !isset($params["is_user"])) {
return $this->response("300", "参数不全");
......
......@@ -430,7 +430,8 @@ class ChatService
$where_["id"] = array( "between", array( $relation_list[$item["id"]][0]["msg_id"], $chat_info[0]["id"] ) );
//计算未读消息个数
$unread_count = $msgModel->getTotalUnread($where_, "id");
$result[$key]["unread"] = $unread_count;
//dump($unread_count);
$result[$key]["unread"] = $unread_count > 0 ? $unread_count-1 : 0;
} catch (Exception $exception) {
$result[$key]["unread"] = 0;
}
......
......@@ -63,7 +63,7 @@ class ChatMsg extends Model
}
$where_["a.is_del"] = 0;
$data = $this->db->field($field)
$data = $this->db->field($field)
->alias("a")
->join('chat_msg_ext b', 'a.id = b.msg_id', 'LEFT')
->where($where_)
......@@ -78,7 +78,8 @@ class ChatMsg extends Model
return $data;
}
public function getTotalUnread($params, $field){
public function getTotalUnread($params, $field)
{
if (isset($params["from"])) {
$where_["a.from_id"] = $params["from"];
......@@ -89,11 +90,12 @@ class ChatMsg extends Model
$where_or["a.from_id"] = $params["target"];
}
if (isset($params["id"])) {
$where_["a.id"] = $params["id"];
$where_["a.id"] = $params["id"];
$where_or["a.id"] = $params["id"];
}
$where_["a.is_del"] = 0;
$data = $this->db->field($field)
$data = $this->db->field($field)
->alias("a")
->join('chat_msg_ext b', 'a.id = b.msg_id', 'LEFT')
->where($where_)
......@@ -102,6 +104,7 @@ 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