Commit 2de8f48f authored by zhuwei's avatar zhuwei

1

parent 50dca805
......@@ -313,209 +313,6 @@ class User extends Basic
}
public function searchUserV2()
{
$params = $this->params;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
#接口调用类型 0:客户搜索 1:全部客户 2:我的客户
$app_request_source_type = isset($params["app_request_source_type"]) && is_numeric($params["app_request_source_type"])? $params["app_request_source_type"] : 1;
$conditions = [];
switch ($app_request_source_type) {
case 0:
$pageNo = 1;
$pageSize = 50;
if (isset($params['id'])) {
$conditions['id'] = $params['id'];
}
if (isset($params['user_name'])) {
if (strlen($params['user_name']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_name'] = array( "like", "%" . trim($params['user_name']) . "%" );
}
if (isset($params['user_nick'])) {
if (strlen($params['user_nick']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_nick'] = array( "like", "%" . trim($params['user_nick']) . "%" );
}
if (isset($params['user_phone'])) {
if (!is_numeric($params['user_phone'])) {
return $this->response(101, '请输入正确手机号');
}
if (strlen($params['user_phone']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_phone'] = array( "like", "%" . trim($params['user_phone']) . "%" );
}
//具体业态搜索
if (isset($params['concrete_industry']) ) {
if (strlen($params['concrete_industry']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['concrete_industry'] = [ 'LIKE', '%' . $params['concrete_industry'] . '%' ];
}
break;
case 2:
$user_id_str = $this->getUserIDList($params['agent_id']);
$conditions['id'] = ['in', $user_id_str];
if (isset($params['user_status'])) {
$conditions['user_status'] = $params['user_status'];
}
if(isset($params['entrust_type']) && is_numeric($params['entrust_type'])){
//委托类型
$conditions['entrust_type'] =$params['entrust_type'];
}
break;
default:
if (isset($params['user_status'])) {
$conditions['user_status'] = $params['user_status'];
}
if (isset($params['user_name'])) {
if (strlen($params['user_name']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_name'] = array( "like", "%" . trim($params['user_name']) . "%" );
}
if (isset($params['user_nick'])) {
if (strlen($params['user_nick']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_nick'] = array( "like", "%" . trim($params['user_nick']) . "%" );
}
if (isset($params['user_phone'])) {
if (!is_numeric($params['user_phone'])) {
return $this->response(101, '请输入正确手机号');
}
if (strlen($params['user_phone']) > 20) {
return $this->response(101, '输入内容长度超限');
}
$conditions['user_phone'] = array( "like", "%" . trim($params['user_phone']) . "%" );
}
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 ) );
} else if ($area_start >= 0 && $area_end < 0) { //100米以上不用传结束面积
$conditions['area_demand'] = array( 'egt', $area_start );
}
$price_start = isset($params['money_start']) ? $params['money_start'] : -1;
$price_end = isset($params['money_end']) ? $params['money_end'] : -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'])) {
$start_time = date('Y-m-d H:i:s', $params['start_time']);
$end_time = date('Y-m-d H:i:s', $params['end_time']);
$conditions['create_time'] = array( 'between', array( $start_time, $end_time ) );
}
if (isset($params['status'])) {
$conditions['status'] = $params['status'];
}
//是否vip客户 1是 0否
if (isset($params['is_vip']) ) {
$conditions['vip'] = $params['is_vip'];
}
//全部客户列表 排除排除纯房东客户
$conditions['user_label'] = array( "neq", 2 );
//根据时间搜索,要能搜到保护期客户
if(!isset($conditions['create_time'])){
//排除排除保护期内的客户 将截止日期大于当前时间的数据排除掉
$time_now = date('Y-m-d H:i:s');
$conditions['protect_time'] = array('lt',$time_now);
}
//客户站点
if (isset($params['site_id']) ) {
$conditions['site_ids'] = [ 'LIKE', '%' . $params['site_id'] . '%' ];
}else{
$conditions['site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
}
//委托类型
if(isset($params['entrust_type']) && is_numeric($params['entrust_type'])){
$conditions['entrust_type'] =$params['entrust_type'];
}
}
$field = "id as user_id,sex,user_name,city,user_phone,user_status,agent_id,create_time,industry_type,
price_demand,area_demand,vip,user_label,source_intro,site_ids,entrust_type,concrete_industry";
$return_user_list = $this->userModel->selectUserList($field, $conditions, $pageNo, $pageSize, "id desc");
if (empty($return_user_list)) {
return $this->response("200", "此条件没有找到数据");
}
// 将经纪人所在城市的客户拍前面
if (($app_request_source_type == 0) && (!isset($params["agent_id"]))) {
$return_user_list = $this->userSequenceByCity($return_user_list,$params['site_id']);
}
$clientService = new ClientService();
$user_service = new UserService();
foreach ($return_user_list as $k => $v) {
/*判断是否纯房东 0:否 1:是 start*/
$is_single_homeowner = 0;
if ($v['user_label'] == 2) {
//source 41纯房东
$is_single_homeowner = 1;
}
$return_user_list[$k]['is_single_homeowner'] = $is_single_homeowner;
/*判断是否纯房东 end*/
$is_show = $clientService->dialTotal($v["user_id"]);
$return_user_list[$k]['sign_call'] = $is_show ? 0 : 1;
//查询客户是否在保护期内 0:保护期内 1:超过保护期
$is_outstrip_twenty_four_hours = $user_service->isUserProtect($v["user_id"]);
$return_user_list[$k]['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
$return_user_list[$k]['is_can_look'] = $user_service->isUserAgentDirector($v["agent_id"], $this->agentId);
$return_user_list[$k]['user_phone'] = substr_replace($return_user_list[$k]['user_phone'], '****', 3, 4);
$return_user_list[$k]['site_ids_name'] = $user_service->userSiteName($v["site_ids"]);
$return_user_list[$k]['user_name'] = $v['user_name'] && $v['entrust_type'] == 0 ?"{$v['concrete_industry']},{$v['user_name']}":$v['user_name'];
}
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($this->agentId);
$data['user_date'] = $return_user_list;
$data['total_page'] = count($return_user_list);
return $this->response("200", 'request success', $data);
}
/**
......
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