Commit eea7f83f authored by zhuwei's avatar zhuwei

开盘广场列表

parent 9bed56f8
......@@ -29,6 +29,20 @@ class Square extends Basic
}
public function getSquareList()
{
$params = $this->params;
$result= $this->s_square->getSquareList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
}
\ No newline at end of file
......@@ -31,4 +31,45 @@ class SquareService
}
}
public function getSquareList($params){
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//搜索 时间
if (!empty($params['start_date']) && empty($params['end_date'])) {
$get_params['Square.create_time'] = [ 'between time', [ $params['start_date'] . ' 00:00:00', $params['end_date'] . ' 23:59:59' ] ];
}
//城市
if (!empty($params['site_id'])) {
$get_params['Square.site_id'] = $params['site_id'];
}
//部门
if (!empty($params['district_id'])) {
$get_params['Square.district_id'] = $params['district_id'];
}
//文章标题
if (!empty($params['title'])) {
$get_params['Square.title'] = [ 'LIKE', '%' . $params['title'] . '%' ];
}
$field = 'Square.id,';//
$field .= 'Square.title,';//标题
$field .= 'Agent.name,';//发布人
$field .= 'Site.name as site_name,';//城市
$field .= 'District.district_name,';//部门
$field .= 'Square.create_time';//发布时间
$get_params['Square.status'] = 0;
$res = $this->m_square->getSquareList($pageNo, $pageSize, $field, $get_params);
$res_total = $this->m_square->getSquareListTotal($field, $get_params);
// foreach ($res as $key => $val) {
//
// }
return [ 'data' => $res, 'total' => $res_total ];
}
}
\ No newline at end of file
......@@ -37,6 +37,23 @@ class Square extends Basic
}
public function getSquareList()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
$result= $this->s_square->getSquareList($params);
if($result){
return $this->response("200", "成功",$result);
}else{
return $this->response("200", "成功",$result);
}
}
}
\ No newline at end of file
......@@ -44,25 +44,40 @@ class BSquare extends Model
}
public function getSquareList($pageNo,$pageSize,$field,$params)
{
$order = "Square.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right')
->where($params)
->limit($pageSize)
->page($pageNo)
->order($order)
->select();
//dump($this->getLastSql());
return $result;
}
public function getSquareListTotal($field,$params)
{
$order = "Square.create_time desc";
$result = Db::table($this->table)
->field($field)
->alias('Square')
->join('a_agents Agent', 'Agent.id = Square.agent_id', 'right')
->join('a_site Site', 'Site.id = Square.site_id', 'right')
->join('a_district District', 'District.id = Square.district_id', 'right')
->where($params)
->count();
//dump($this->getLastSql());
return $result;
}
// /**
// * 查询收藏数据
// */
// public function getCollectList($pageNo,$pageSize,$field,$params)
// {
// $order = "CollectUser.update_time desc";
// $result = Db::table($this->table)
// ->field($field)
// ->alias('CollectUser')
// ->join('g_houses Houses', 'CollectUser.house_id = Houses.id', 'right')
// ->where($params)
// ->limit($pageSize)
// ->page($pageNo)
// ->order($order)
// ->select();
// //dump($this->getLastSql());
// return $result;
// }
//
//
// /**
......
......@@ -442,6 +442,8 @@ Route::group('index', [
//开盘广场
'addSquare' => ['index/Square/addSquare', ['method' => 'GET|POST']],
'getSquareList' => ['index/Square/getSquareList', ['method' => 'GET|POST']],
]);
......@@ -848,6 +850,7 @@ Route::group('broker', [
//开盘广场
'addSquare' => ['api_broker/Square/addSquare', ['method' => 'GET|POST']],
'getSquareList' => ['api_broker/Square/getSquareList', ['method' => 'GET|POST']],
]);
......
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