Commit 5f8c1215 authored by zfc's avatar zfc

客方搜索

parent 5c0b7e5b
......@@ -3,6 +3,8 @@
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\index\controller\Agent;
use app\model\Agents;
use app\model\Users;
use app\model\UPhoneFollowPp;
......@@ -60,6 +62,34 @@ class Client extends Basic
return $this->response($this->code, $this->msg,$this->data);
}
/**经纪人搜索
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentSearch(){
$table= new Agents;
$data['msg'] = '';
$params = $this->request->param();
$search=$params['search'];
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field=['id','realname','phone'];
$where='level in(2,5) ';
if(!empty($search)){
$where.=" and realname like '%$search%' or phone like '%$search%' ";
$data['search']=$search;
}
$order="id desc";
$data['list']=$table->searchList($pageNo, $pageSize,$order,$field, $where);
$total=$table->searchTotal($where);
$data['total']= ceil($total / $pageSize);
$data['page']=$pageNo;
return $this->response(200,'成功',$data);
}
/**app 经纪人用户列表
* @throws \think\db\exception\DataNotFoundException
......@@ -98,11 +128,10 @@ class Client extends Basic
}
// echo $where;exit;
$order="id asc";
$order="id desc";
$data['list']=$table->getAgentUserTb($pageNo, $pageSize,$order,$field, $where);
$total=$table->getUserAgentTotal($where);
$total2 = intval($total / $pageSize);
$data['total']= $total2==0 ? 1 : $total2;
$data['total']= ceil($total / $pageSize);
$data['page']=$pageNo;
return $this->response(200,'成功',$data);
......@@ -148,8 +177,7 @@ class Client extends Basic
$order="id desc";
$data['list']=$table->getSearch($pageNo, $pageSize,$order,$field,$join, $where,$group);
$total=$table->getUserAgentTotal($where,$join);
$total2 = intval($total / $pageSize);
$data['total']= $total2==0 ? 1 : $total2;
$data['total'] =ceil($total / $pageSize);
$data['page']=$pageNo;
return $this->response(200,'成功',$data);
}
......
......@@ -9,14 +9,16 @@ class Agents extends Model
{
/**
* 查询经纪人
*
* @param type $pageNo
* @param type $pageSize
* @param type $order_
* @param type $field
* @param type $params
* @param type $house_id 查询该街铺和商铺的经纪人评论信息
* @return type
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param $params
* @param string $house_id
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUser($pageNo = 1, $pageSize = 15, $order_ = 'id desc', $field, $params, $house_id = '') {
if ($house_id == '') {
......@@ -44,12 +46,14 @@ class Agents extends Model
return $data;
}
/**
* 经纪人详情
*
* @param type $id
* @return boolean
* @param $id
* @return array|bool|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentsDetail($id) {
if ($id) {
......@@ -133,4 +137,35 @@ class Agents extends Model
return $data;
}
/**
* @param int $pageNo
* @param int $pageSize
* @param string $order_
* @param $field
* @param string $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function searchList($pageNo=1, $pageSize=15,$order_='id desc',$field, $where=''){
$r =$this->field($field)
->where($where)
->order($order_)
->limit($pageSize)
->page($pageNo)
->select();
return $r;
}
/**
* @param $params
* @return int|string
*/
public function searchTotal($params)
{
return $this->where($params)->count();
}
}
......@@ -208,7 +208,7 @@ Route::group('api', [
'agentUserTb' => [ 'api_broker/Client/agentUserTb', [ 'method' => 'get' ] ],//客户列表
'agentUserFollow' => [ 'api_broker/Client/agentUserFollow', [ 'method' => 'get' ] ],//客户列表
'agentSearch' => [ 'api_broker/Client/agentSearch', [ 'method' => 'get' ] ],//经纪人搜索
]);
Route::group('task',[
......
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