Commit 741a45cc authored by clone's avatar clone

客户搜索

parent 94311b2f
......@@ -3,6 +3,7 @@
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\model\Users;
use think\Request;
/**
......@@ -14,9 +15,12 @@ use think\Request;
*/
class User extends Basic
{
private $userModel;
public function __construct($request = null)
{
parent::__construct($request);
$this->userModel = new Users();
}
/**
......@@ -47,7 +51,9 @@ class User extends Basic
return $this->response("200", "request success", $result);
}
public function searchUser(){
public function searchUser()
{
$params = $this->params;
$params = array(
"yetai" => "休闲娱乐",
......@@ -57,25 +63,49 @@ class User extends Basic
"money_end" => 10000,//租金
"start_time" => "2018-05-25",
"end_time" => "2018-05-30",
"pageNo" => "1",
"pageNo" => 1,
"pageSize" => 15
);
$params = $this->params;
$field = "a.id,a.agent_id,a.title,a.address,a.city,disc,a.disccircles,a.sales,a.yetai,a.room_area,a.room_area2,
a.shangpu_type,a.is_test,a.room_num_left,a.shangpu_tags,a.carefully_chosen,a.price,a.rent_type,b.foreign_name,b.address_detail_c,
b.foreign_advantage";
$field = "id as user_id,sex,user_nick,user_phone,user_status,agent_id,create_time,industry_type,price_demand,area_demand";
$conditions = [];
if (empty($params['site_area'])) {
return $this->response("101", "请求来源不能为空");
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
if (isset($params['title'])) {
$conditions['b.foreign_name'] = array( "like", "%" . trim($params['title']) . "%" );
if (isset($params['yetai'])) {
$conditions['industry_type'] = array( "like", "%" . trim($params['yetai']) . "%" );
}
$area_start = isset($params['area_start']) ? $params['area_start'] : -1;
$area_end = isset($params['area_end']) ? $params['area_end'] : -1;
if ($area_start >= 0 && $area_end >= 0) { //面积
$conditions['area_demand'] = array( 'between', array( $area_start, $area_end ) );
$conditions['area_demand'] = array( 'between', array( $area_start, $area_end ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['area_demand'] = array( 'egt', $area_start );
$conditions['area_demand'] = array( 'egt', $area_start );
}
$price_start = isset($params['money_start']) ? $params['money_start'] : -1;
$price_end = isset($params['end_time']) ? $params['end_time'] : -1;
if ($price_start >= 0 && $price_end >= 0) { //金额
$conditions['price_demand'] = array( 'between', array( $price_start, $price_end ) );
} else if ($price_start >= 0 && $price_end < 0) {
$conditions['price_demand'] = array( 'egt', $price_start );
}
if (isset($params['start_time']) && isset($params['end_time'])) {
$conditions['create_time'] = array( 'between', array( $params['start_time'], $params['end_time'] ) );
}
$userList = $this->userModel->selectUserList($field, $conditions,$pageNo, $pageSize, "id desc");
if (empty($userList)) {
return $this->response("200", "此条件没有找到数据");
}
return $this->response("200", 'request success', $userList);
}
}
\ No newline at end of file
......@@ -413,6 +413,17 @@ class Users extends Model
->select();
}
public function selectUserList($field,$params,$pageNo,$pageSize,$order = "id desc"){
$result = $this->field($field)
->where($params)
->order($order)
->page($pageNo)
->limit($pageSize)
->select();
echo $this->getLastSql();
return $result;
}
/**
* 数据转换 返回用户信息
* @param $params
......
......@@ -454,6 +454,7 @@ Route::group('broker', [
//user
'returnSearchCondition' => [ 'api_broker/User/returnSearchCondition', [ 'method' => 'get' ] ], //客户搜索条件
'searchUser' => [ 'api_broker/User/searchUser', [ '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