Commit 3224f5bd authored by zw's avatar zw

searchOrder bug

parent 6661df8f
......@@ -460,7 +460,7 @@ class AppChat extends Basic
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "id,addressee_id,type,message,house_id,create_time";
$field = "id,addressee_id,type,message,house_id,create_time,is_read";
//获取此经纪人的所有盘方楼盘id
......@@ -493,7 +493,7 @@ class AppChat extends Basic
$page_no = empty($params['page_no']) ? 1 : $params['page_no'];
$page_size = empty($params['page_size']) ? 15 : $params['page_size'];
$field = "id,addressee_id,type,message,user_id,create_time";
$field = "id,addressee_id,type,message,user_id,create_time,is_read";
//获取此经纪人的所有盘方楼盘id
......@@ -507,4 +507,35 @@ class AppChat extends Basic
}
/**
* 获取商铺消息和客户消息的未读消息个数,并修改已读消息状态
* @return \think\Response
*/
public function updateSystemMessageIsRead(){
$params = $this->params;
/* $params = array(
"agent_id" => 1,//经纪人id
"read_ids" => "1,2,3" //需要修改的消息id
);*/
if (empty($params['agent_id'])) {
return $this->response("101", "请求参数错误");
}
$msgModel = new MPushMessage();
//修改已读消息
if(!empty($params['read_ids'])){
$where_arr["id"] = array("in",$params["read_ids"]);
$update_arr["is_read"] = 1;
$msgModel->updateIsRead($where_arr,$update_arr);
}
$param["addressee_id"] = $params["agent_id"];
$param["type"] = 2;
//TODO 获取未读个数
$data["user_count"] = $msgModel->getListCountByWhere($param);
$param["type"] = 1;
$data["shop_count"] = $msgModel->getListCountByWhere($param);
return $this->response("200","success",$data);
}
}
......@@ -216,6 +216,16 @@ class MPushMessage
return $result;
}
/**
* @param string $field
* @param array $params
* @param int $page_no
* @param int $page_size
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getListByWhere(string $field, array $params,int $page_no = 1,int $page_size = 15)
{
return $this->db_
......@@ -226,4 +236,35 @@ class MPushMessage
->limit($page_size)
->select();
}
/**
* 获取未读个数
* @param array $params
* @return int|string
*/
public function getListCountByWhere(array $params)
{
return $this->db_
->where($params)
->count();
}
/** 批量更新已看记录
* @param array $where_arr
* @param array $update_arr
* @return array
*/
public function updateIsRead(array $where_arr,array $update_arr){
$result= [];
try {
$this->db_->where($where_arr)
->update($update_arr);
$result['code'] = true;
} catch (\Exception $e) {
$result['code'] = false;
$result['msg'] = $e->getMessage();
}
return $result;
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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