Commit 0c1d0966 authored by zhuwei's avatar zhuwei

1

parent 53b5851b
......@@ -200,6 +200,7 @@ class User extends Basic
$pageNo = 1;
$pageSize = 50;
}
$conditions['entrust_type'] = isset($params["entrust_type"]) ? $params["entrust_type"] : 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,user_label,source_intro,site_ids";
$return_user_list = $this->userModel->selectUserList($field, $conditions, $pageNo, $pageSize, "id desc");
......@@ -549,6 +550,7 @@ class User extends Basic
$where['site_ids'] = [ 'LIKE', '%' . $this->siteId . '%' ];
}
$where['entrust_type'] = isset($params["entrust_type"]) ? $params["entrust_type"] : 0;
$field = 'id,user_nick,agent_id,vip,create_time';
$user = new Users();
......@@ -587,198 +589,25 @@ class User extends Basic
}
}
$where = [];
$where['city'] = trim($this->city);
$field = 'max(id) as max_id';
$order = 'id asc';
$max_id = $user->getLastOrNextUserID($where, $field, $order, $type, 0,1);
$field = 'MIN(id) as min_id';
$min_id = $user->getLastOrNextUserID($where, $field, $order, $type,0,1);
return $this->response("200", "success!", [
'user_id' => $user_res[0]['id'],
'max_user_id' => $max_id[0]['max_id'],
'min_user_id' => $min_id[0]['min_id'] ]
);
}
/**
* 客户详情上一页下一页接口 (客户跟进列表)
* @return \think\Response
* 朱伟 2018-08-07
*/
public function getLastOrNextUserIDPhoneFollowPu()
{
header('Access-Control-Allow-Origin:*');
$params = $this->params;
/*$params = array(
"id" => 1956,
"agent_id" => 9,
"type" => "next",
);*/
$checkResult = $this->validate($params, "UserValidate.getLastOrNextUserIDPhoneFollowPu");
if (true !== $checkResult) {
return $this->response("300", $checkResult);
}
$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' ];
} else {
$where['a.create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ];
}
} else {
$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' ];;
}
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
if (strtotime($last_month) > strtotime($this->params['start_date'])) {
$start_date = $last_month;
} else {
$start_date = $this->params['start_date'];
}
$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']}%" ];
}
//跟进人名字
if (!empty($this->params['remark_name'])) {
if (mb_strlen($this->params['remark_name']) < 2) {
return $this->response(101, '名字长度不足2位');
}
$agent_where['name'] = [ 'LIKE', '%' . $this->params['remark_name'] . '%' ];
}
//跟进人手机号
if (!empty($this->params['remark_phone'])) {
$agent_where['a.phone'] = $this->params['remark_phone'];
}
//跟进人门店
if (!empty($this->params['remark_store_id'])) {
$agent_where['a.store_id'] = $this->params['remark_store_id'];
}
//跟进人部门
if (!empty($this->params['remark_district_id'])) {
$agent_where['a.district_id'] = $this->params['remark_district_id'];
}
if (!empty($this->params['province'])) {
$where['a.province'] = $this->params['province'];
}
// if (!empty($this->params['city'])) {
// $where['a.city'] = $this->params['city'];
// }
if (!empty($this->params['disc'])) {
$where['a.disc'] = $this->params['disc'];
}
if (!empty($this->params['user_id'])) {
$where['a.user_id'] = $this->params['user_id'];
}
if (!empty($agent_where)) {
$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); //处理经纪人空数据
} else {
$agent_id = [];
foreach ($agent_id_arr as $K => $v) {
$agent_id[] = $v['id'];
}
$where['a.agent_id'] = [ 'in', $agent_id ];
}
}
if ($params['type'] == 'last') {
$where['a.id'] = [ 'gt', $params['id'] ];
$order = 'a.id asc';
} else {
$where['a.id'] = [ 'lt', $params['id'] ];
$order = 'a.id desc';
}
$field = 'a.id,a.user_id,b.user_nick,b.user_nick,b.agent_id,b.vip,b.create_time';
$model = new UPhoneFollowUp($this->siteId);
$model_res = $model->getLastOrNextUserIDPhoneFollowP($where, $field, $limit = 1, $order);
if (!$model_res) {
return $this->response("201", "查无数据", [ 'id' => $params['id'] ]);
}
// 判断当天被拨打是否超过5次
$model_agent = new AAgents();
$result = $model_agent->searchAgentsByKeyword("id,name,phone", [ "id" => $params["agent_id"] ]);
$call = new CallPhoneService();
$gresult = $call->getBindNum($model_res['user_phone'], $result[0]['phone']);
$clientService = new ClientService();
if (!$clientService->dialTotal($model_res[0]['user_id']) && $gresult == 0) {
return $this->response("201", "当天被拨打超过5次", [ 'id' => $model_res[0]['id'] ]);
}
//如果非客方
if ($model_res[0]['agent_id'] != $params['agent_id']) {
// 判断是否vip客户,如果是 只有是当前经纪人自己的客户才能查看
//vip客户 0:否 1:是
$where = [];
$where['city'] = trim($this->city);
$where['entrust_type'] = isset($params["entrust_type"]) ? $params["entrust_type"] : 0;
$vip_services = new VipService();
$examine_vip = $vip_services->vip($params['agent_id']);
$order = 'id asc';
$field = 'max(id) as max_id';
if (($model_res[0]['vip'] == 1)) {
if (($examine_vip == 1)) {
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'] ]);
}
}
//dump($model_res);exit();
$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'])) {
$start_date = $last_month;
} else {
$start_date = $this->params['start_date'];
}
$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);
//dump($model_res);exit();
$max_id = $user->getLastOrNextUserID($where, $field, $order, $type, 0, 1);
$field = 'MIN(id) as min_id';
$min_id = $user->getLastOrNextUserID($where, $field, $order, $type, 0, 1);
return $this->response("200", "success!", [
'id' => $model_res[0]['id'],
'user_id' => $model_res[0]['user_id'],
'user_id' => $user_res[0]['id'],
'max_user_id' => $max_id[0]['max_id'],
'min_user_id' => $min_id[0]['min_id'] ]
);
}
/**
* 获取用户主要信息
* @return \think\Response
......
......@@ -841,7 +841,6 @@ Route::group('broker', [
'returnSearchCondition' => ['api_broker/User/returnSearchCondition', ['method' => 'get']], //客户搜索条件
'searchUser' => ['api_broker/User/searchUser', ['method' => 'get|post']], //客户搜索
'getLastOrNextUserID' => ['api_broker/User/getLastOrNextUserID', ['method' => 'get|post']], //
'getLastOrNextUserIDPhoneFollowPu' => ['api_broker/User/getLastOrNextUserIDPhoneFollowPu', ['method' => 'get|post']], //
'superviseListNew' => ['api_broker/Supervise/superviseList', ['method' => 'POST|GET']], //监督执行列表
'addSupervise' => ['api_broker/Supervise/addSupervise', ['method' => 'POST|GET']], //新增-监督执行
......
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