Commit a3132feb authored by hujun's avatar hujun

增加字段

parent 56f1dfce
...@@ -652,17 +652,20 @@ class OfficeRoomService ...@@ -652,17 +652,20 @@ class OfficeRoomService
} }
/* /*
* 房源列表
*
* @param $params * @param $params
* @param int $is_total
* @return mixed * @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* User HuJun * User HuJun
* Date 19-6-2 下午2:26 * Date 19-6-3 上午10:31
*/ */
public function getRoomList($params) { public function getRoomList($params, $is_total = 0) {
$page_no = empty($params['pageNo']) ? 1 : $params['pageNo']; $page_no = empty($params['pageNo']) ? 1 : $params['pageNo'];
$page_size = empty($params['pageSize']) ? 15 : $params['pageSize']; $page_size = empty($params['pageSize']) ? 15 : $params['pageSize'];
$result['status'] = 'fail';
$result['msg'] = '';
$result['data'] = [];
$where = $this->buildParams($params); $where = $this->buildParams($params);
...@@ -685,47 +688,56 @@ class OfficeRoomService ...@@ -685,47 +688,56 @@ class OfficeRoomService
$agent_where['a.is_del'] = 0; $agent_where['a.is_del'] = 0;
} }
//盘方搜索 try {
if (!empty($agent_where)) { //盘方搜索
$agent_arr = $this->agent_room->getAgentsByRoomColumn('houses_id', $agent_where); if (!empty($agent_where)) {
$agent_arr = $this->agent_room->getAgentsByRoomColumn('houses_id', $agent_where);
if (empty($agent_arr)) { if (empty($agent_arr)) {
$data['data']['list'] = []; $result['status'] = 'successful';
$data['data']['total'] = 0; return $result;
return $this->response(200, '', $data); } else {
} else { $agent_str = implode(',', $agent_arr);
$agent_str = implode(',', $agent_arr); $where[] = ['EXP', "id in ({$agent_str})"];
$where[] = ['EXP', "id in ({$agent_str})"]; }
} }
} /*盘方 end*/
/*盘方 end*/
/*房东手机号搜索 start*/ /*房东手机号搜索 start*/
if ($params['landlord_phone'] != NULL) { if ($params['landlord_phone'] != NULL) {
if (strlen($params['landlord_phone']) != 11) { if (strlen($params['landlord_phone']) != 11) {
$result['msg'] = '房东手机不足11位'; $result['msg'] = '房东手机不足11位';
return $result; return $result;
} }
$landlord_where['phone'] = ['LIKE','%'.$params['landlord_phone'].'%']; $landlord_where['phone'] = ['LIKE','%'.$params['landlord_phone'].'%'];
$landlord_where['status'] = 0; $landlord_where['status'] = 0;
$landlord_arr = $this->landlord_phone->getList(1,1000, '', 'house_id', $landlord_where); $landlord_arr = $this->landlord_phone->getList(1,1000, '', 'house_id', $landlord_where);
if (empty($landlord_arr)) { if (empty($landlord_arr)) {
$result['status'] = 'successful'; $result['status'] = 'successful';
return $result; return $result;
} else { } else {
$landlord_house_id = []; $landlord_house_id = [];
foreach ($landlord_arr as $k=>$v) { foreach ($landlord_arr as $k=>$v) {
$landlord_house_id[] = $v['house_id']; $landlord_house_id[] = $v['house_id'];
}
$landlord_str = implode(',', $landlord_house_id);
$where[] = ['EXP', "id in ({$landlord_str})"];
} }
$landlord_str = implode(',', $landlord_house_id);
$where[] = ['EXP', "id in ({$landlord_str})"];
} }
/*房东手机号搜索 end*/
$field = 'a.id';
$result['data'] = $this->m_office_room->getRoomAgent($page_no, $page_size, $field, $where);
if ($is_total) {
$result['total'] = $this->m_office_room->getRoomAgentTotal($where);
}
}catch (\Exception $e) {
$result['msg'] = $e->getMessage();
} }
/*房东手机号搜索 end*/
$field = '';
$this->m_office_room->getRoomAgent($page_no, $page_size, $field, $where); return $result;
} }
/** /**
......
...@@ -261,4 +261,26 @@ class OfficeGRoom extends BaseModel ...@@ -261,4 +261,26 @@ class OfficeGRoom extends BaseModel
->page($page_no) ->page($page_no)
->select(); ->select();
} }
/**
* @param $page_no
* @param $page_size
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* User HuJun
* Date 19-6-2 下午1:57
*/
public function getRoomAgentTotal($where)
{
return $this->alias('a')
->join('office_g_room_to_agent b', 'a.id = b.house_id', 'left')
->join('a_agents b', 'b.agent_id = b.id', 'left')
->join('office_g_building c', 'a.building_id = c.id', 'left')
->where($where)
->count('a.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