Commit 462401b0 authored by hujun's avatar hujun

商铺列表优化

parent 9aa586a6
This diff is collapsed.
...@@ -272,21 +272,30 @@ class GHouses extends BaseModel ...@@ -272,21 +272,30 @@ class GHouses extends BaseModel
*/ */
public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '') public function getHouseListDish($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field = '', $params = '', $agents_id = '')
{ {
$data = $this->field($field)->alias('a') // $data = $this->field($field)->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left') // ->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
->join('a_agents c', 'b.agents_id=c.id', 'left') // ->join('a_agents c', 'b.agents_id=c.id', 'left')
->join('g_houses_ext d', 'a.id=d.house_id', 'left') // ->join('g_houses_ext d', 'a.id=d.house_id', 'left')
// ->where($params)
// ->order($order_)
// ->limit($pageSize)
// ->page($pageNo)
// ->group('a.id')
// ->select();
$data = $this->field($field)
->where($params) ->where($params)
->order($order_) ->order($order_)
->limit($pageSize) ->limit($pageSize)
->page($pageNo) ->page($pageNo)
->group('a.id')
->select(); ->select();
$house_id = array();
$house_id = [];
$house_follow_up = new GHousesFollowUp(); $house_follow_up = new GHousesFollowUp();
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$house_id[$k] = $v['id']; $house_id[$k] = $v['id'];
$v->create_time = date('Y-m-d', strtotime($v->create_time)); $v->create_time = date('Y-m-d', strtotime($v->create_time));
$data[$k]['last_follow_up'] = $house_follow_up->where('house_id',$v['id'])->value('create_time'); $data[$k]['last_follow_up'] = $house_follow_up->where('house_id',$v['id'])->value('create_time');
} }
...@@ -340,14 +349,15 @@ class GHouses extends BaseModel ...@@ -340,14 +349,15 @@ class GHouses extends BaseModel
*/ */
public function getHouseListDishTotal($params = '') public function getHouseListDishTotal($params = '')
{ {
$data = $this->alias('a') // $data = $this->alias('a')
->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left') // ->join('g_houses_to_agents b', 'a.id=b.houses_id', 'left')
->join('a_agents c', 'b.agents_id=c.id', 'left') // ->join('a_agents c', 'b.agents_id=c.id', 'left')
->join('g_houses_ext d', 'a.id=d.house_id', 'left') // ->join('g_houses_ext d', 'a.id=d.house_id', 'left')
->where($params) // ->where($params)
->group('a.id') // ->group('a.id')
->count(); // ->count();
return $data; // return $data;
return $this->where($params)->count();
} }
/** /**
...@@ -764,6 +774,9 @@ class GHouses extends BaseModel ...@@ -764,6 +774,9 @@ class GHouses extends BaseModel
if (isset($params["create_time"])) { if (isset($params["create_time"])) {
$where_["create_time"] = $params["create_time"]; $where_["create_time"] = $params["create_time"];
} }
if (isset($params['landlord_phone'])) {
$where_["landlord_phone"] = $params['landlord_phone'];
}
$result = Db::table($this->table) $result = Db::table($this->table)
->field($field) ->field($field)
->where($where_) ->where($where_)
...@@ -772,11 +785,17 @@ class GHouses extends BaseModel ...@@ -772,11 +785,17 @@ class GHouses extends BaseModel
return $result; return $result;
} }
/** /**
* 获取新增楼盘数据 * 获取新增楼盘数据
*
* @param $params * @param $params
* @param $field
* @param $page_no
* @param $page_size
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getAddHouseList($params, $field, $page_no, $page_size) public function getAddHouseList($params, $field, $page_no, $page_size)
{ {
......
...@@ -200,6 +200,20 @@ class GHousesToAgents extends BaseModel ...@@ -200,6 +200,20 @@ class GHousesToAgents extends BaseModel
return $result; return $result;
} }
/**
* @param $field
* @param $params
* @return array
*/
public function getAgentsHouseField($field, $params)
{
return $this->field($field)
->alias("a")
->join("a_agents b", "a.agents_id = b.id", "left")
->where($params)
->column($field);
}
/** /**
* 楼盘对应的经纪人信息 * 楼盘对应的经纪人信息
* *
...@@ -250,14 +264,15 @@ class GHousesToAgents extends BaseModel ...@@ -250,14 +264,15 @@ class GHousesToAgents extends BaseModel
* *
* @param $house_id * @param $house_id
* @param int $type * @param int $type
* @return array|\PDOStatement|string|\think\Model * @param string $field
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentList($house_id, $type = 1) public function getAgentList($house_id, $type = 1, $field = 'b.id,device_id,b.name,b.phone')
{ {
return $this->field('b.id,device_id,b.name,b.phone') return $this->field($field)
->alias('a') ->alias('a')
->join('a_agents b', 'a.agents_id = b.id', 'left') ->join('a_agents b', 'a.agents_id = b.id', 'left')
->where('houses_id', $house_id) ->where('houses_id', $house_id)
......
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