Commit 0269ee40 authored by zhuwei's avatar zhuwei

客户详情

parent f93a0df4
......@@ -427,7 +427,9 @@ class Broker extends Basic
$orderLog = new OrderLogService();
$records = new GOperatingRecords();
$records_result = $records->user_history($user_id);
$param_['user_id'] = $user_id;
$records_result = $records->user_history($param_);
$data['user_info'] = $user_res;
$data['user_date'] = $orderLog->selectListByUserId($user_id, '');
$data['user_history'] = $records_result;
......@@ -444,6 +446,50 @@ class Broker extends Basic
if ($res && ($res[0]['status'] == 1)) {//如果存在
$data["is_collect"] = 1;
}
$param_['type'] = 5;
$records_invite_result = $records->user_history($param_);
$data['user_invite_history'] = $records_invite_result;
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期
/*$ser = new UserExpiredTimeService();
$res = $ser->getExpiredTimeByUser($v["user_id"]);
$data['data']['list'][$k]['is_outstrip_twenty_four_hours'] = $res ? 0 : 1 ;*/
$is_outstrip_twenty_four_hours = 0;
if ((time() - strtotime($user_res['u_create_time'])) > (60 * 60 * 24)) {
$is_outstrip_twenty_four_hours = 1;
}
$data['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
//todo 查询客户邀请人 1 邀请人是客户还是经纪人 2 经纪人:邀请人姓名,手机号 客户:姓名 id
/*引荐人来源 10:会员 20:b端经纪人*/
if ($user_res['referrer_source'] == 0) {
$user_invite_info = [];
} elseif ($user_res['referrer_source'] == 10) {
$userArr = $user->selectUser($user_res['referrer_id'], "id,user_phone");
if (!$userArr) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_res['referrer_source'];
$user_invite_info['user_phone'] = $userArr['user_phone'];
$user_invite_info['id'] = $userArr['id'];
}
} else {
$model = new AAgents();
$result = $model->searchAgentsByKeyword("id,name,phone", [ "id" => $user_res['referrer_id'] ]);
if (!$result) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_res['referrer_source'];
$user_invite_info['name'] = $result[0]['name'];
$user_invite_info['phone'] = $result[0]['phone'];
}
}
$data['user_invite_info'] = $user_invite_info;
return $this->response("200", "success!", $data);
}
......
......@@ -29,7 +29,8 @@ class Remark extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function followUpList(){
public function followUpList()
{
if (!$this->request->isAjax()) {
return view('remark_follow_index');
}
......@@ -45,16 +46,16 @@ class Remark 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['create_time'] = ['> time', $last_month. ' 00:00:00'];
$where['create_time'] = [ '> time', $last_month . ' 00:00:00' ];
} else {
$where['create_time'] = ['> time', $this->params['start_date']. ' 00:00:00'];
$where['create_time'] = [ '> time', $this->params['start_date'] . ' 00:00:00' ];
}
} else {
$where['create_time'] = ['> time', $last_month. ' 00:00:00'];
$where['create_time'] = [ '> time', $last_month . ' 00:00:00' ];
}
if (!empty($this->params['end_date']) && empty($this->params['start_date'])) {
$where['create_time'] = ['< time', $this->params['end_date']. ' 23:59:59'];;
$where['create_time'] = [ '< time', $this->params['end_date'] . ' 23:59:59' ];;
}
if (!empty($this->params['end_date']) && !empty($this->params['start_date'])) {
......@@ -63,11 +64,11 @@ class Remark extends Basic
} else {
$start_date = $this->params['start_date'];
}
$where['create_time'] = ['between',[$start_date.' 00:00:00',$this->params['end_date']. ' 23:59:59']];
$where['create_time'] = [ 'between', [ $start_date . ' 00:00:00', $this->params['end_date'] . ' 23:59:59' ] ];
}
if (!empty($this->params['content'])) {
$where['content'] = ['LIKE',"%{$this->params['content']}%"];
$where['content'] = [ 'LIKE', "%{$this->params['content']}%" ];
}
//跟进人名字
......@@ -75,7 +76,7 @@ class Remark extends Basic
if (mb_strlen($this->params['remark_name']) < 2) {
return $this->response(101, '名字长度不足2位');
}
$agent_where['name'] = ['LIKE', '%'.$this->params['remark_name'].'%'];
$agent_where['name'] = [ 'LIKE', '%' . $this->params['remark_name'] . '%' ];
}
//跟进人手机号
......@@ -115,36 +116,36 @@ class Remark extends Basic
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['agent_id'] = ['in', $agent_id];
$where['agent_id'] = [ 'in', $agent_id ];
}
}
$field = 'id,user_id,create_time,content,user_status,labels_id,agent_id as f_agent_id';
$data['data']['list'] = $u_phone_follow->getFollowList($pageNo, $pageSize, $order_ = 'id desc', $field, $where);
foreach ($data['data']['list'] as $k=>$v) {
// dump($v);
foreach ($data['data']['list'] as $k => $v) {
// dump($v);
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期
/*$ser = new UserExpiredTimeService();
$res = $ser->getExpiredTimeByUser($v["user_id"]);
$data['data']['list'][$k]['is_outstrip_twenty_four_hours'] = $res ? 0 : 1 ;*/
$is_outstrip_twenty_four_hours = 0;
if((time() - strtotime($v['u_create_time'])) > (60*60*24)){
if ((time() - strtotime($v['u_create_time'])) > (60 * 60 * 24)) {
$is_outstrip_twenty_four_hours = 1;
}
$data['data']['list'][$k]['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
$data['data']['list'][$k]['user_phone'] = substr_replace($data['data']['list'][$k]['user_phone'],'****',3,4);
$data['data']['list'][$k]['user_phone'] = substr_replace($data['data']['list'][$k]['user_phone'], '****', 3, 4);
}
$data['data']['total'] = $u_phone_follow->getFollowTotal($where);
return $this->response(200,'成功',$data);
return $this->response(200, '成功', $data);
}
/**
......@@ -153,21 +154,22 @@ class Remark extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function contentList(){
$table= new Remarks;
public function contentList()
{
$table = new Remarks;
$data['status'] = 200;
$data['msg'] = '';
$params = $this->request->param();
$applyId=$params['apply_id'];
if($applyId){
$applyId = $params['apply_id'];
if ($applyId) {
//条件
$field='id,apply_id,shopuser_id,content,house_id,created,admin,';
$where="isinstatus=1 and content like '%【跟进】%' and apply_id='{$applyId}'";
$field = 'id,apply_id,shopuser_id,content,house_id,created,admin,';
$where = "isinstatus=1 and content like '%【跟进】%' and apply_id='{$applyId}'";
$data['list'] = $table->field($field)->where($where)->select();
}else{
return $this->response(100,'失败,没有apply_id',$data);
} else {
return $this->response(100, '失败,没有apply_id', $data);
}
return $this->response(200,'成功',$data);
return $this->response(200, '成功', $data);
}
/**
......@@ -186,7 +188,7 @@ class Remark extends Basic
);*/
if (empty($params['user_id'])) {
return $this->response(101,'客户信息错误');
return $this->response(101, '客户信息错误');
}
$searchdate = $params['searchdate'];
......@@ -196,18 +198,18 @@ class Remark extends Basic
$UPhoneFollowPp = new UPhoneFollowPp();
// 查询电话跟进数据
$UPhoneFollowPp_res = $UPhoneFollowPp->select_useraction_search($user_id,$searchdate);
$UPhoneFollowPp_res = $UPhoneFollowPp->select_useraction_search($user_id, $searchdate);
foreach($UPhoneFollowPp_res as $k=>$v){
foreach ($UPhoneFollowPp_res as $k => $v) {
$table = new AAgents();
$Agents_res = $table->Agents_res($v['agent_id']);
$UPhoneFollowPp_res[$k]['agentinfo'] = $Agents_res?$Agents_res['store_name'].'-'.$Agents_res['name']:'未知';
$UPhoneFollowPp_res[$k]['user_pic'] = AGENTHEADERIMGURL.$Agents_res['img'];
$UPhoneFollowPp_res[$k]['agentinfo'] = $Agents_res ? $Agents_res['store_name'] . '-' . $Agents_res['name'] : '未知';
$UPhoneFollowPp_res[$k]['user_pic'] = AGENTHEADERIMGURL . $Agents_res['img'];
$UPhoneFollowPp_res[$k]['label'] = '';
//电话跟进标签
if($v['labels_id']){
$table= new ULabels();
if ($v['labels_id']) {
$table = new ULabels();
$table_res = $table->get_labelsname($v['labels_id']);
$UPhoneFollowPp_res[$k]['label'] = $table_res[0]['name'];
}
......@@ -216,12 +218,12 @@ class Remark extends Basic
$user = new Users();
$user_res = $user->useraction_search_user_res($user_id, 1);
$user_res['user_phone'] = hide_customer_phone($user_res['user_phone']);
$user_res['user_pic'] = HEADERIMGURL.$user_res['user_pic'];
$user_res['user_pic'] = HEADERIMGURL . $user_res['user_pic'];
$table = new AAgents();
$Agents_res = $table->Agents_res($user_res['agent_id']);
$user_res['agentinfo'] = $Agents_res?$Agents_res['name'].'/'.$Agents_res['phone']:'未知';
$user_res['agentinfo'] = $Agents_res ? $Agents_res['name'] . '/' . $Agents_res['phone'] : '未知';
//判断客户是否超过24小时保护期间 0:保护器内 1:超过保护期
......@@ -230,34 +232,37 @@ class Remark extends Basic
$data['data']['list'][$k]['is_outstrip_twenty_four_hours'] = $res ? 0 : 1 ;*/
$is_outstrip_twenty_four_hours = 0;
if((time() - strtotime($user_res['u_create_time'])) > (60*60*24)){
if ((time() - strtotime($user_res['u_create_time'])) > (60 * 60 * 24)) {
$is_outstrip_twenty_four_hours = 1;
}
$user_res['is_outstrip_twenty_four_hours'] = $is_outstrip_twenty_four_hours;
$records = new GOperatingRecords();
$records_result = $records->user_history($user_id);
$param_['user_id'] = $user_id;
$records_result = $records->user_history($param_);
$param_['type'] = 5;
$records_invite_result = $records->user_history($param_);
//todo 查询客户邀请人 1 邀请人是客户还是经纪人 2 经纪人:邀请人姓名,手机号 客户:姓名 id
/*引荐人来源 10:会员 20:b端经纪人*/
if($user_res['referrer_source']== 0){
$user_invite_info=[];
}elseif($user_res['referrer_source']== 10){
if ($user_res['referrer_source'] == 0) {
$user_invite_info = [];
} elseif ($user_res['referrer_source'] == 10) {
$userArr = $user->selectUser($user_res['referrer_id'], "id,user_phone");
if(!$userArr){
$user_invite_info=[];
}else{
if (!$userArr) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_res['referrer_source'];
$user_invite_info['user_phone'] = $userArr['user_phone'];
$user_invite_info['id'] = $userArr['id'];
}
}else{
} else {
$model = new AAgents();
$result = $model->searchAgentsByKeyword("id,name,phone", [ "id" => $user_res['referrer_id'] ]);
if(!$result){
$user_invite_info=[];
}else{
if (!$result) {
$user_invite_info = [];
} else {
$user_invite_info['referrer_source'] = $user_res['referrer_source'];
$user_invite_info['name'] = $result[0]['name'];
$user_invite_info['phone'] = $result[0]['phone'];
......@@ -268,6 +273,7 @@ class Remark extends Basic
'user_info' => $user_res,
'user_date' => $UPhoneFollowPp_res,
'user_history' => $records_result,
'user_invite_history' => $records_invite_result,
'user_invite_info' => $user_invite_info,
]
);
......@@ -278,7 +284,8 @@ class Remark extends Basic
*
* @return \think\Response
*/
public function select_by_phone() {
public function select_by_phone()
{
$phone = trim($this->params['phone']);
$table = new Agents();
$Agents_res = $table->select_by_phone($phone);
......@@ -294,9 +301,9 @@ class Remark extends Basic
$params = $this->params;
// if (!isset($params['user_id'])) {
// return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
// }
// if (!isset($params['user_id'])) {
// return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
// }
$searchdate = $params['searchdate'];
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
......@@ -305,7 +312,7 @@ class Remark extends Basic
$UPhoneFollowPp = new UPhoneFollowPp();
// 查询电话跟进数据
$UPhoneFollowPp_res=$UPhoneFollowPp->phone_up_list($pagesize,$pagenum);
$UPhoneFollowPp_res = $UPhoneFollowPp->phone_up_list($pagesize, $pagenum);
//dump($UPhoneFollowPp_res);
/*dump($total);
var_dump($user_res);
......@@ -332,11 +339,11 @@ class Remark extends Basic
}*/
$UPhoneFollowPp = new UPhoneFollowPp();
$total =$UPhoneFollowPp->phone_up_list_count();
$total = $UPhoneFollowPp->phone_up_list_count();
//dump($total);
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
//dump($total);
return $this->response("200", "success!", ['user_date'=>$UPhoneFollowPp_res,'pagenum'=>$pagenum,'total'=>$total]);
return $this->response("200", "success!", [ 'user_date' => $UPhoneFollowPp_res, 'pagenum' => $pagenum, 'total' => $total ]);
}
......
......@@ -55,17 +55,18 @@ class GOperatingRecords extends BaseModel
* @param $user_id
* @return array|false|\PDOStatement|string|\think\Collection
*/
public function user_history($user_id)
public function user_history($param)
{
if (empty($user_id)) {
if (empty($param['user_id'])) {
return [];
}
try {
$data = $this->field('name,remark,create_time')
->where('user_id',$user_id)
->where($param)
->order('create_time', 'desc')
->select();
//echo $this->getLastSql();
} catch (\Exception $e) {
$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