Commit 5297f22d authored by clone's avatar clone

bug

parent 936276b9
......@@ -64,23 +64,23 @@ class User extends Basic
public function searchUser()
{
$params = $this->params;
/*$params = array(
"user_status" => 0,//客户状态(0:求租;1:已租;-1:无效)
"yetai" => "休闲娱乐",
"area_start" => 1,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1,//租金 price2
"money_end" => 10000,//租金
"start_time" => "2016-05-25",
"end_time" => "2018-05-30",
"id" => 1,
"user_name" => "12312",
"user_phone" => "138171212",
"pageNo" => 1,
"agent_id" => 5741,//传经纪人id代表我得客户
"pageSize" => 15,
"status" => 0,
);*/
/*$params = array(
"user_status" => 0,//客户状态(0:求租;1:已租;-1:无效)
"yetai" => "休闲娱乐",
"area_start" => 1,//面积起始范围 room_area2
"area_end" => 65,//面积结束范围
"money_start" => 1,//租金 price2
"money_end" => 10000,//租金
"start_time" => "2016-05-25",
"end_time" => "2018-05-30",
"id" => 1,
"user_name" => "12312",
"user_phone" => "138171212",
"pageNo" => 1,
"agent_id" => 5741,//传经纪人id代表我得客户
"pageSize" => 15,
"status" => 0,
);*/
$field = "id as user_id,sex,user_name,city,user_phone,user_status,agent_id,create_time,industry_type,price_demand,area_demand,vip";
$conditions = [];
......@@ -88,7 +88,7 @@ class User extends Basic
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$conditions["city"] = trim($this->city)?trim($this->city):'上海市';
$conditions["city"] = trim($this->city) ? trim($this->city) : '上海市';
if (isset($params['user_status'])) {
$conditions['user_status'] = $params['user_status'];
......@@ -150,36 +150,26 @@ class User extends Basic
if (empty($userList)) {
return $this->response("200", "此条件没有找到数据");
}
$list = [];
if (isset($params["agent_id"]) || isset($params["id"]) || isset($params["user_phone"])) {
$list = $userList;
} else {
$clientService = new ClientService();
foreach ($userList as $k => $v) {
$is_show = $clientService->dialTotal($v["user_id"]);
if ($is_show) {
array_push($list, $v);
}
}
}
foreach ($list as $k => $v) {
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期
/* $ser = new UserExpiredTimeService();
$res = $ser->getExpiredTimeByUser($v["user_id"]);
$list[$k]['is_outstrip_twenty_four_hours']=$res ? 0 : 1 ;*/
$clientService = new ClientService();
foreach ($userList as $k => $v) {
$sign_call = 0;
$is_show = $clientService->dialTotal($v["user_id"]);
if ($is_show) {
$sign_call = 1;
}
$is_outstrip_twenty_four_hours = 0;
if((time() - strtotime($v['create_time'])) > (60*60*24)){
if ((time() - strtotime($v['create_time'])) > (60 * 60 * 24)) {
$is_outstrip_twenty_four_hours = 1;
}
$list[$k]['is_outstrip_twenty_four_hours']=$is_outstrip_twenty_four_hours;
$userList[$k]['sign_call'] = $sign_call;
$userList[$k]['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
}
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($this->agentId);
$data['user_date'] = $list;
$data['user_date'] = $userList;
$data['total_page'] = count($userList);
return $this->response("200", 'request success', $data);
}
......@@ -215,20 +205,20 @@ class User extends Basic
$where['a.status'] = -1;
}
} else {
$where['a.status'] = ['<>', 1];
$where['a.status'] = [ '<>', 1 ];
}
//客户手机号
if (!empty($params['phone'])) {
$if_search_user = true;
//$where[0] = ['EXP','a.user_phone LIKE "%'.$this->params['phone'].'%" or a.user_nick LIKE "%'.$this->params['phone'].'%"'];
$where['a.user_phone'] = ['LIKE','%'.$params['phone'].'%'];
$where['a.user_phone'] = [ 'LIKE', '%' . $params['phone'] . '%' ];
}
if (!empty($params['user_nick'])) {
$if_search_user = true;
//$where[0] = ['EXP','a.user_phone LIKE "%'.$this->params['phone'].'%" or a.user_nick LIKE "%'.$this->params['phone'].'%"'];
$where['a.user_name'] = ['LIKE','%'.$params['user_nick'].'%'];
$where['a.user_name'] = [ 'LIKE', '%' . $params['user_nick'] . '%' ];
}
//是否公客
......@@ -236,63 +226,63 @@ class User extends Basic
if ($params['public_user'] == 1) {
$where['a.agent_id'] = 0;
} else {
$where['a.agent_id'] = ['>', 0];
$where['a.agent_id'] = [ '>', 0 ];
}
}
//邀请人
if (!empty($params['invite_phone'])) {
$where['a.referrer_id'] = ['NOT NULL']; //覆盖上面的值
$referrer_id = $this->userModel->findUserByPhone('id', $params['invite_phone']);
$where['a.referrer_id'] = $referrer_id['id'];//覆盖上面的值
$where['a.referrer_id'] = [ 'NOT NULL' ]; //覆盖上面的值
$referrer_id = $this->userModel->findUserByPhone('id', $params['invite_phone']);
$where['a.referrer_id'] = $referrer_id['id'];//覆盖上面的值
$where['referrer_source'] = 10;
$type = 1;
$type = 1;
}
//创建开始时间
if (!empty($params['start_date']) && empty($params['end_date'])) {
$where['a.create_time'] = ['> time', $params['start_date'] . '00:00:00'];
}elseif (!empty($params['end_date']) && empty($params['start_date'])) {
$where['a.create_time'] = ['< time', $params['end_date'] . '23:59:59'];
}elseif (!empty($params['start_date']) && !empty($params['end_date'])) {
$where['a.create_time'] = ['between time', [$params['start_date']. ' 00:00:00', $params['end_date'] . ' 23:59:59']];
}else{
$where['a.create_time'] = [ '> time', $params['start_date'] . '00:00:00' ];
} elseif (!empty($params['end_date']) && empty($params['start_date'])) {
$where['a.create_time'] = [ '< time', $params['end_date'] . '23:59:59' ];
} elseif (!empty($params['start_date']) && !empty($params['end_date'])) {
$where['a.create_time'] = [ 'between time', [ $params['start_date'] . ' 00:00:00', $params['end_date'] . ' 23:59:59' ] ];
} else {
if (empty($params['id']) && empty($params['phone'])) {
$time_ = date('Y-m-d H:i:s', strtotime("-1 day"));
$time_ = date('Y-m-d H:i:s', strtotime("-1 day"));
$where['a.create_time'] = array( 'lt', $time_ );
}
}
//跟进结束时间
if (!empty($params['follow_start']) && empty($params['follow_end'])) {
$where['b.create_time'] = ['> time',$params['follow_start']. ' 00:00:00'];
$type = 2;
$where['b.create_time'] = [ '> time', $params['follow_start'] . ' 00:00:00' ];
$type = 2;
}
//跟进时间
if (!empty($params['follow_end']) && empty($params['follow_start'])) {
$where['b.create_time'] = ['< time',$params['follow_end']. ' 23:59:59'];
$type = 2;
$where['b.create_time'] = [ '< time', $params['follow_end'] . ' 23:59:59' ];
$type = 2;
}
//跟进时间
if (!empty($params['follow_start']) && !empty($params['follow_end'])) {
$where['b.create_time'] = ['between time', [$params['follow_start']. ' 00:00:00', $params['follow_end'] . ' 23:59:59']];
$type = 2;
$where['b.create_time'] = [ 'between time', [ $params['follow_start'] . ' 00:00:00', $params['follow_end'] . ' 23:59:59' ] ];
$type = 2;
}
//客户编号
if (!empty($params['id'])) {
$if_search_user = true;
$where['a.id'] = $params['id'];
$where['a.id'] = $params['id'];
}
//是否登录过
if (!empty($params['login_status']) && $params['login_status'] != -1) {
if ($params['login_status'] == 1) {
$where[] = ['EXP', 'a.first_login_time IS NOT NULL OR a.last_login_time IS NOT NULL'];
$where[] = [ 'EXP', 'a.first_login_time IS NOT NULL OR a.last_login_time IS NOT NULL' ];
} else {
$where['a.first_login_time'] = ['NULL'];
$where['a.first_login_time'] = [ 'NULL' ];
}
}
......@@ -303,18 +293,18 @@ class User extends Basic
//注册时间
if (!empty($params['registration_start']) && empty($params['registration_end'])) {
$where['a.registration_time'] = ['< time',$params['registration_start']. ' 23:59:59'];
$where['a.registration_time'] = [ '< time', $params['registration_start'] . ' 23:59:59' ];
}
//注册时间
if (!empty($params['registration_end']) && empty($params['registration_start'])) {
$where['a.registration_time'] = ['< time',$params['registration_end']. ' 23:59:59'];
$where['a.registration_time'] = [ '< time', $params['registration_end'] . ' 23:59:59' ];
}
//注册时间
if (!empty($params['registration_start']) && !empty($params['registration_end'])) {
$where['a.registration_time'] = ['between time', [$params['registration_start']. ' 00:00:00', $params['registration_end'] . ' 23:59:59']];
$type = 2;
$where['a.registration_time'] = [ 'between time', [ $params['registration_start'] . ' 00:00:00', $params['registration_end'] . ' 23:59:59' ] ];
$type = 2;
}
//业态
......@@ -326,13 +316,16 @@ class User extends Basic
if (!empty($params['area_type'])) {
switch ($params['area_type']) {
case 1 :
$where['a.area_demand'] = ['<=', 30];break;
$where['a.area_demand'] = [ '<=', 30 ];
break;
case 2 :
$where['a.area_demand'] = ['between', [30,60]];break;
$where['a.area_demand'] = [ 'between', [ 30, 60 ] ];
break;
case 4 :
$where['a.area_demand'] = ['between', [60,100]];break;
$where['a.area_demand'] = [ 'between', [ 60, 100 ] ];
break;
default :
$where['a.area_demand'] = ['>', 100];
$where['a.area_demand'] = [ '>', 100 ];
}
}
......@@ -340,16 +333,18 @@ class User extends Basic
if (!empty($params['price_type'])) {
switch ($params['price_type']) {
case 1 :
$where['a.price_demand'] = ['<=', 10000];break;
$where['a.price_demand'] = [ '<=', 10000 ];
break;
case 2 :
$where['a.price_demand'] = ['between', [10000,30000]];break;
$where['a.price_demand'] = [ 'between', [ 10000, 30000 ] ];
break;
default :
$where['a.price_demand'] = ['>', 30000];
$where['a.price_demand'] = [ '>', 30000 ];
}
}
if (!empty($params['invite_agent_phone'])) {
$type = 4;
$type = 4;
$where['b.phone'] = $params['invite_agent_phone'];
}
......@@ -372,31 +367,31 @@ class User extends Basic
//客方门店
if (!empty($params['store_id']) && empty($params['referrer_store_id'])) {
$where['b.store_id'] = $params['store_id'];
$type = 3;
$type = 3;
}
//邀请人门店
if (!empty($params['referrer_store_id']) && empty($params['store_id'])) {
$where['b.store_id'] = $params['referrer_store_id'];
$type = 4;
$where['b.store_id'] = $params['referrer_store_id'];
$type = 4;
}
//客方部门
if (!empty($params['district_id']) && $params['district_id'] != -1 && empty($params['referrer_district_id'])) {
$where['b.district_id'] = $params['district_id'];
$type = 3;
$type = 3;
}
//邀请人部门
if (!empty($params['referrer_district_id']) && empty($params['district_id'])) {
$where['b.district_id'] = $params['referrer_district_id'];
$type = 4;
$type = 4;
}
//客方手机号
if (!empty($params['user_agent'])) {
$where['b.phone'] = $params['user_agent'];
$type = 3;
$type = 3;
}
if (!empty($params['first_login_start'])) {
......@@ -408,7 +403,7 @@ class User extends Basic
}
if (!empty($params['first_login_start']) && !empty($params['first_login_end'])) {
$where['a.first_login_time'] = ['between time', [$params['first_login_start'] . ' 00:00:00', $where['a.first_login_time'] = $params['first_login_end'] . ' 23:59:59']];
$where['a.first_login_time'] = [ 'between time', [ $params['first_login_start'] . ' 00:00:00', $where['a.first_login_time'] = $params['first_login_end'] . ' 23:59:59' ] ];
}
if (isset($params['vip']) && $params['vip'] != -1) {
......@@ -425,9 +420,9 @@ class User extends Basic
if (!empty($params['city'])) {
$where['a.city'] = $params['city'];
}else{
} else {
// 判断是 杭州还是上海
$where['a.city'] = trim($this->city)? trim($this->city) :'上海市';
$where['a.city'] = trim($this->city) ? trim($this->city) : '上海市';
}
if (!empty($params['disc'])) {
......@@ -435,8 +430,6 @@ class User extends Basic
}
if ($params['type'] == 'last') {
$where['id'] = [ 'gt', $params['user_id'] ];
$order = 'id asc';
......@@ -447,35 +440,35 @@ class User extends Basic
}
$field = 'id,user_nick,agent_id,vip,create_time';
$user = new Users();
$user_res = $user->getLastOrNextUserID($where, $field, $limit = 1, $order,$type);
$user_res = $user->getLastOrNextUserID($where, $field, $limit = 1, $order, $type);
if (!$user_res) {
return $this->response("201", "查无数据", ['user_id'=>$params['user_id']]);
return $this->response("201", "查无数据", [ 'user_id' => $params['user_id'] ]);
}
// 判断当天被拨打是否超过5次
$clientService = new ClientService();
if (!$clientService->dialTotal($user_res[0]['id'])) {
return $this->response("201", "当天被拨打超过5次", ['user_id'=>$user_res[0]['id']]);
return $this->response("201", "当天被拨打超过5次", [ 'user_id' => $user_res[0]['id'] ]);
}
//如果非客方
if($user_res[0]['agent_id'] != $params['agent_id']){
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
if ($user_res[0]['agent_id'] != $params['agent_id']) {
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
$vip_services = new VipService();
$examine_vip= $vip_services->vip($params['agent_id']);
$examine_vip = $vip_services->vip($params['agent_id']);
if (($user_res[0]['vip'] == 1)) {
if (($examine_vip == 1)) {
return $this->response("201", "vip 非客方", ['user_id'=>$user_res[0]['id']]);
}
}
if (($user_res[0]['vip'] == 1)) {
if (($examine_vip == 1)) {
return $this->response("201", "vip 非客方", [ 'user_id' => $user_res[0]['id'] ]);
}
}
// 判断是否24小时保护期内
if((time() - strtotime($user_res[0]['create_time'])) < (60*60*24)){
return $this->response("201", "24小时保护期内", ['user_id'=>$user_res[0]['id']]);
}
// 判断是否24小时保护期内
if ((time() - strtotime($user_res[0]['create_time'])) < (60 * 60 * 24)) {
return $this->response("201", "24小时保护期内", [ 'user_id' => $user_res[0]['id'] ]);
}
}
$where = [];
......@@ -515,20 +508,19 @@ class User extends Basic
// );
$last_month = date("Y-m-d", strtotime("-1 month"));
if (!empty($this->params['start_date']) && empty($this->params['end_date'])) {
if (strtotime($last_month) > strtotime($this->params['start_date'])) {
$where['a.create_time'] = ['> time', $last_month. ' 00:00:00'];
$where['a.create_time'] = [ '> time', $last_month . ' 00:00:00' ];
} else {
$where['a.create_time'] = ['> time', $this->params['start_date']. ' 00:00:00'];
$where['a.create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ];
}
} else {
$where['a.create_time'] = ['> time', $last_month. ' 00:00:00'];
$where['a.create_time'] = [ '> time', $last_month . ' 00:00:00' ];
}
if (!empty($this->params['end_date']) && empty($this->params['start_date'])) {
$where['a.create_time'] = ['< time', $this->params['end_date']. ' 23:59:59'];;
$where['a.create_time'] = [ '< time', $this->params['end_date'] . ' 23:59:59' ];;
}
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
......@@ -537,11 +529,11 @@ class User extends Basic
} else {
$start_date = $this->params['start_date'];
}
$where['a.create_time'] = ['between',[$start_date.' 00:00:00',$this->params['end_date']. ' 23:59:59']];
$where['a.create_time'] = [ 'between', [ $start_date . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ];
}
if (!empty($this->params['content'])) {
$where['a.content'] = ['LIKE',"%{$this->params['content']}%"];
$where['a.content'] = [ 'LIKE', "%{$this->params['content']}%" ];
}
//跟进人名字
......@@ -549,7 +541,7 @@ class User extends Basic
if (mb_strlen($this->params['remark_name']) < 2) {
// return $this->response(101, '名字长度不足2位');
}
$agent_where['a.name'] = ['LIKE', '%'.$this->params['remark_name'].'%'];
$agent_where['a.name'] = [ 'LIKE', '%' . $this->params['remark_name'] . '%' ];
}
//跟进人手机号
......@@ -584,36 +576,36 @@ class User extends Basic
}
if (!empty($agent_where)) {
$m_agent = new AAgents();
$m_agent = new AAgents();
$agent_id_arr = $m_agent->getAgentById('id', $agent_where);
if (empty($agent_id_arr)) {
$data['data']['list'] = [];
return $this->response(200,'', $data); //处理经纪人空数据
return $this->response(200, '', $data); //处理经纪人空数据
} else {
$agent_id = [];
foreach ($agent_id_arr as $K=>$v) {
foreach ($agent_id_arr as $K => $v) {
$agent_id[] = $v['id'];
}
$where['a.agent_id'] = ['in', $agent_id];
$where['a.agent_id'] = [ 'in', $agent_id ];
}
}
if ($params['type'] == 'last') {
$where['a.id'] = [ 'gt', $params['id'] ];
$order = 'a.id asc';
$order = 'a.id asc';
} else {
$where['a.id'] = [ 'lt', $params['id'] ];
$order = 'a.id desc';
$order = 'a.id desc';
}
$field = 'a.id,a.user_id,b.user_nick,b.agent_id,b.vip,b.create_time';
$field = 'a.id,a.user_id,b.user_nick,b.agent_id,b.vip,b.create_time';
$model = new UPhoneFollowPp();
$model_res = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = 1, $order);
if (!$model_res) {
return $this->response("201", "查无数据", ['id'=>$params['id']]);
return $this->response("201", "查无数据", [ 'id' => $params['id'] ]);
}
// 判断当天被拨打是否超过5次
......@@ -623,26 +615,26 @@ class User extends Basic
// }
//如果非客方
if($model_res[0]['agent_id'] != $params['agent_id']){
if ($model_res[0]['agent_id'] != $params['agent_id']) {
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
$vip_services = new VipService();
$examine_vip= $vip_services->vip($params['agent_id']);
$examine_vip = $vip_services->vip($params['agent_id']);
if (($model_res[0]['vip'] == 1)) {
if (($examine_vip == 1)) {
return $this->response("201", "vip 非客方", ['id'=>$model_res[0]['id']]);
return $this->response("201", "vip 非客方", [ 'id' => $model_res[0]['id'] ]);
}
}
// 判断是否24小时保护期内
if((time() - strtotime($model_res[0]['create_time'])) < (60*60*24)){
return $this->response("201", "24小时保护期内", ['id'=>$model_res[0]['id']]);
if ((time() - strtotime($model_res[0]['create_time'])) < (60 * 60 * 24)) {
return $this->response("201", "24小时保护期内", [ 'id' => $model_res[0]['id'] ]);
}
}
// dump($model_res);exit();
$where = [];
$where = [];
// $where['city'] = trim($this->city);
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
if (strtotime($last_month) > strtotime($this->params['start_date'])) {
......@@ -650,13 +642,13 @@ class User extends Basic
} else {
$start_date = $this->params['start_date'];
}
$where['a.create_time'] = ['between',[$start_date.' 00:00:00',$this->params['end_date']. ' 23:59:59']];
$where['a.create_time'] = [ 'between', [ $start_date . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ];
}
$field = 'max(a.id) as max_id';
$order = 'a.id asc';
$max_id = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = '', $order);
$field = 'MIN(a.id) as min_id';
$min_id = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = '', $order);
$field = 'max(a.id) as max_id';
$order = 'a.id asc';
$max_id = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = '', $order);
$field = 'MIN(a.id) as min_id';
$min_id = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = '', $order);
//dump($model_res);exit();
return $this->response("200", "success!", [
'id' => $model_res[0]['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