Commit fa3c9174 authored by clone's avatar clone

被拨打10次不显示

parent 7ad5dbb3
......@@ -3,6 +3,7 @@
namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\api_broker\service\ClientService;
use app\api_broker\service\PushMessageService;
use app\model\AAgents;
use app\model\ULabels;
......@@ -24,7 +25,7 @@ class Client extends Basic
protected $user;
protected $data = [];
protected $code = 200;
protected $msg = '';
protected $msg = '';
function __construct($request = null)
{
......@@ -32,7 +33,8 @@ class Client extends Basic
$this->user = new Users();
}
public function selectUser(){
public function selectUser()
{
}
......@@ -44,7 +46,8 @@ class Client extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function editClient() {
public function editClient()
{
header('Access-Control-Allow-Origin:*');
if (empty($this->params['user_name'])) {
......@@ -64,15 +67,15 @@ class Client extends Basic
//是否修改客方
if ($this->params['agents_id'] != $user_agent_id['agent_id']) {
$agent = new AAgents();
$agent = new AAgents();
$agent_data = $agent->getAgentInfo('name,phone', $this->params['agents_id']);
$remark = '修改为'.$agent_data['name'].'-'.$agent_data['phone'];
$remark = '修改为' . $agent_data['name'] . '-' . $agent_data['phone'];
$push = new PushMessageService();
$push = new PushMessageService();
$ccr_agent_data = $agent->getAgentInfo('name,phone', $this->params['ccr_id']);
$content = "【{$ccr_agent_data['name']}-{$ccr_agent_data['phone']}修改了{$user_agent_id['user_name']}(id:{$user_agent_id['id']})客方】";
$content = "【{$ccr_agent_data['name']}-{$ccr_agent_data['phone']}修改了{$user_agent_id['user_name']}(id:{$user_agent_id['id']})客方】";
$push->pushMessageById($user_agent_id['agent_id'], '客方修改', $content, 'user_info', $user_agent_id['id']);
$this->operating_records($this->params['ccr_id'], $type=3, $remark,0,$this->params['id']);
$this->operating_records($this->params['ccr_id'], $type = 3, $remark, 0, $this->params['id']);
}
} else {
$table = new AAgents();
......@@ -81,23 +84,26 @@ class Client extends Basic
$data['start'] = $this->user->edit($this->params);
if ($data['start'] > 0) {
$data['id']= $this->user->id;
$agent_data = $table->getAgentInfo('name,phone',$this->params['agents_id']);
$remark = '新增为'. $agent_data['name'].'-'.$agent_data['phone'];
$this->operating_records($this->params['ccr_id'], $type=3, $remark,0,$data['id']);
$data['id'] = $this->user->id;
$agent_data = $table->getAgentInfo('name,phone', $this->params['agents_id']);
$remark = '新增为' . $agent_data['name'] . '-' . $agent_data['phone'];
$this->operating_records($this->params['ccr_id'], $type = 3, $remark, 0, $data['id']);
}
}
switch ($data['start']) {
case -1 :
$this->code = 101;
$this->msg = '该用户已存在';break;
$this->msg = '该用户已存在';
break;
case -2 :
$this->code = 101;
$this->msg = '此号码为虚拟号码';break;
$this->msg = '此号码为虚拟号码';
break;
case -3 :
$this->code = 101;
$this->msg = '没有新增VIP权限';break;
$this->msg = '没有新增VIP权限';
break;
}
} else {
......@@ -119,31 +125,32 @@ class Client extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentSearch(){
public function agentSearch()
{
header('Access-Control-Allow-Origin:*');
$agent = new AAgents();
$agent = new AAgents();
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where = 'status <> 2';
$where = 'status <> 2';
if ($this->params['search']) {
$where .= ' AND concat(phone,name) like "%'.$this->params['search'].'%"';
$where .= ' AND concat(phone,name) like "%' . $this->params['search'] . '%"';
}
if ($this->params['level']) {
$where .= ' AND level in ('.$this->params['level'].')';
$where .= ' AND level in (' . $this->params['level'] . ')';
}
if ($where) {
$field = 'id,name as realname,phone';
$data['list'] = $agent->getList($pageNo, $pageSize, 'id DESC', $field, '',$where);
$total = $agent->getTotal($where);
$field = 'id,name as realname,phone';
$data['list'] = $agent->getList($pageNo, $pageSize, 'id DESC', $field, '', $where);
$total = $agent->getTotal($where);
$data['total'] = ceil($total / $pageSize);
$data['page'] = $pageNo;
$msg = '成功';
$msg = '成功';
} else {
$msg = '没有经纪人信息';
}
......@@ -157,73 +164,72 @@ class Client extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentUserTb(){
public function agentUserTb()
{
header('Access-Control-Allow-Origin:*');
$table = new Users;
$table = new Users;
$data['msg'] = '';
$time = date("Y-m-d H:i:s",time());//当前时间
$params = $this->request->param();
$time = date("Y-m-d H:i:s", time());//当前时间
$params = $this->request->param();
/*$params['type'] = 0;
$params['agent_id'] = '5741';*/
if(empty($params['agent_id'])){
return $this->response(100,'参数不全');
if (empty($params['agent_id'])) {
return $this->response(100, '参数不全');
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$type = $params['type']? $params['type'] : 0;
$type = $params['type'] ? $params['type'] : 0;
//条件
//time_minute_diff 时间差(分)48小时内增加的【拥有经纪人】的客户为--受保护客户
$field = ['id as user_id','user_name','user_phone','agent_id','referrer_id','create_time',"TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff",'vip'];
$field = [ 'id as user_id', 'user_name', 'user_phone', 'agent_id', 'referrer_id', 'create_time', "TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff", 'vip' ];
$where = " agent_id in({$params['agent_id']}) and user_status={$type}";
if(!empty($params['search'])){
if (!empty($params['search'])) {
//搜索客户--可以搜索自己的客户and 不在保护期的客户
// $where = " (agent_id in(0,{$params['agent_id']}) or agent_id is null or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880 )
// and ( user_nick like '%{$params['search']}%' or user_phone like '%{$params['search']}%' ) ";
$where = "agent_id in({$params['agent_id']} )
$where = "agent_id in({$params['agent_id']} )
and ( user_name like '%{$params['search']}%' or user_phone like '%{$params['search']}%' ) ";
$data['search'] = $params['search'];
}
$data['list'] = $table->getAgentUserTb($pageNo, $pageSize,'id desc',$field, $where);
$total = $table->getMyUserCount($where);
$data['list'] = $table->getAgentUserTb($pageNo, $pageSize, 'id desc', $field, $where);
$total = $table->getMyUserCount($where);
$data['total'] = ceil($total / $pageSize);
$data['page'] = $pageNo;
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($params['agent_id']);
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($params['agent_id']);
return $this->response(200,'成功',$data);
return $this->response(200, '成功', $data);
}
/**搜索客户跟进
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentUserFollow(){
public function agentUserFollow()
{
header('Access-Control-Allow-Origin:*');
$table= new UPhoneFollowPp;
$table = new UPhoneFollowPp;
$data['msg'] = '';
$params = $this->request->param();
$time=date("Y-m-d H:i:s",time());//当前时间
$search=$params['search'];
if(empty($params['agent_id'])){
return $this->response(100,'参数不全');
$params = $this->request->param();
$time = date("Y-m-d H:i:s", time());//当前时间
$search = $params['search'];
if (empty($params['agent_id'])) {
return $this->response(100, '参数不全');
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field=['f.id',
$field = [ 'f.id',
'f.user_id',
'f.agent_id',
'f.content',
......@@ -234,20 +240,20 @@ class Client extends Basic
"TIMESTAMPDIFF(MINUTE,f.create_time,'{$time}')as time_minute_diff"
];
//$where="(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 2880 ) ";
$where="(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 0 ) ";
if(!empty($search)){
$where.=" and f.content like '%$search%' ";
$data['search']=$search;
$where = "(u.agent_id in(0,{$params['agent_id']}) or f.user_id is null or TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}') > 0 ) ";
if (!empty($search)) {
$where .= " and f.content like '%$search%' ";
$data['search'] = $search;
}
$group=" f.id ";
$join=[['agents a','a.id=f.agent_id','left'],
['u_users u','u.id=f.user_id','left'],];
$order="id desc";
$data['list']=$table->getSearch($pageNo, $pageSize,$order,$field,$join, $where,$group);
$total=$table->getUserAgentTotal($where,$join);
$data['total'] =ceil($total / $pageSize);
$data['page']=$pageNo;
return $this->response(200,'成功',$data);
$group = " f.id ";
$join = [ [ 'agents a', 'a.id=f.agent_id', 'left' ],
[ 'u_users u', 'u.id=f.user_id', 'left' ], ];
$order = "id desc";
$data['list'] = $table->getSearch($pageNo, $pageSize, $order, $field, $join, $where, $group);
$total = $table->getUserAgentTotal($where, $join);
$data['total'] = ceil($total / $pageSize);
$data['page'] = $pageNo;
return $this->response(200, '成功', $data);
}
......@@ -259,25 +265,25 @@ class Client extends Basic
* @throws \think\exception\DbException
*/
public function getULabelsListApp() {
public function getULabelsListApp()
{
header('Access-Control-Allow-Origin:*');
$result['code'] = 200;
$result['msg'] = '';
$table = New ULabels;
$where['type'] = 1;
$result['data']['list'] = $table->uleList($where);
$result['code'] = 200;
$result['msg'] = '';
$table = New ULabels;
$where['type'] = 1;
$result['data']['list'] = $table->uleList($where);
return $this->response($result['code'], $result['msg'], $result['data']);
}
/**
* 全部客户
*/
public function all_user() {
public function all_user()
{
header('Access-Control-Allow-Origin:*');
$Two_days_ago = date("Y-m-d h:i:s",strtotime("-2 day"));
$params = $this->params;
$params = $this->params;
#测试数据
// $params['phone_or_name'] = '666' ;
......@@ -291,94 +297,87 @@ class Client extends Basic
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
$phone_or_name = empty($params['phone_or_name']) ? "" : trim($params['phone_or_name']);
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = 15;
$user_id = $params['user_id'];
$type = $params['type'];
$search_type = $params['search_type'];#无:'';客户电话:0;客户姓名:1;跟进:2 ; 编号:3;
$phone_or_name = empty($params['phone_or_name']) ? "" : trim($params['phone_or_name']);
$pagenum = isset($params['pagenum']) ? $params['pagenum'] : 1;
$pagesize = 15;
$user_id = $params['user_id'];
$type = $params['type'];
$search_type = $params['search_type'];#无:'';客户电话:0;客户姓名:1;跟进:2 ; 编号:3;
if($search_type == '0')
{
if ($search_type == '0') {
//客户电话
$conditions['user_phone'] = ['LIKE', '%'.$phone_or_name.'%'];
} elseif ($search_type == '1'){//客户
$conditions['user_name'] = ['LIKE', '%'.$phone_or_name.'%'];
} elseif ($search_type == '3'){//客户
$conditions['id'] = $phone_or_name;
$conditions['user_phone'] = [ 'LIKE', '%' . $phone_or_name . '%' ];
} elseif ($search_type == '1') {//客户
$conditions['user_name'] = [ 'LIKE', '%' . $phone_or_name . '%' ];
} elseif ($search_type == '3') {//客户
$conditions['id'] = $phone_or_name;
}
if ($search_type != '2')
{
if ($search_type != '2') {
//全部客户
if($search_type == ''){
if($type == '0')
{//求租:0 ;已租:1 数据库0:求租;1:已租;-1:无效
$conditions['user_status'] = 0;
}else{
$conditions['user_status'] = 1;
if ($search_type == '') {
if ($type == '0') {//求租:0 ;已租:1 数据库0:求租;1:已租;-1:无效
$conditions['user_status'] = 0;
} else {
$conditions['user_status'] = 1;
}
}
$user = new Users();
$conditions['status'] = ['<', 2];
$user_res = $user->all_user($conditions,$pagesize,$pagenum);
$total = $user->all_user_count($conditions);
}else{
$user = new Users();
$conditions['status'] = [ '<', 2 ];
$user_res = $user->all_user($conditions, $pagesize, $pagenum);
$total = $user->all_user_count($conditions);
} else {
//跟进
$UPhoneFollowPp = new UPhoneFollowPp();
$user_res = $UPhoneFollowPp->all_user_search($phone_or_name,$pagesize,$pagenum);
$total = $UPhoneFollowPp->all_user_search_count($phone_or_name);
$UPhoneFollowPp = new UPhoneFollowPp();
$user_res = $UPhoneFollowPp->all_user_search($phone_or_name, $pagesize, $pagenum);
$total = $UPhoneFollowPp->all_user_search_count($phone_or_name);
}
if($search_type!='2')
{
$clientService = new ClientService();
if ($search_type != '2') {
//全部客户数据处理
foreach($user_res as $k=>$v)
{
$label = [];
$user_res[$k]['user_name'] = $v['user_name']?$v['user_name']:'未知';
if($user_id == $v['agent_id'])
{
foreach ($user_res as $k => $v) {
$label = [];
$user_res[$k]['user_name'] = $v['user_name'] ? $v['user_name'] : '未知';
if ($user_id == $v['agent_id']) {
$label[] = '我的';
}
/*if((strtotime(date("Y-m-d h:i:s")) - strtotime($v['create_time'])) < 172800)
{
$label[] = '保护期内';
}*/
$is_show = $clientService->dialTotal($v["user_id"]);
if (!$is_show) {
unset($user_res[$k]);
}
//无效客户不显示标签
if($v['user_status'] != -1){
$user_res[$k]['label'] = implode(',',$label);
if ($v['user_status'] != -1) {
$user_res[$k]['label'] = implode(',', $label);
}
}
}else{//跟进数据处理
foreach($user_res as $k=>$v)
{
$user_res[$k]['time']=tranTime($v['create_time']);
$table= new AAgents();
$Agents_res = $table->Agents_res($v['agent_id']);
} else {//跟进数据处理
foreach ($user_res as $k => $v) {
$user_res[$k]['time'] = tranTime($v['create_time']);
$table = new AAgents();
$Agents_res = $table->Agents_res($v['agent_id']);
//dump($Agents_res);
$user_res[$k]['agentinfo'] =$Agents_res ? $Agents_res['name'].'-'.$Agents_res['name'] : '未知';
$user_res[$k]['agentshopname'] =$Agents_res['store_name'] ? $Agents_res['store_name'] : '';
$user_res[$k]['realname'] =$Agents_res['name'] ? $Agents_res['name'] : '';
$user_res[$k]['user_pic'] =AGENTHEADERIMGURL.$Agents_res['img'];
$user_res[$k]['agentinfo'] = $Agents_res ? $Agents_res['name'] . '-' . $Agents_res['name'] : '未知';
$user_res[$k]['agentshopname'] = $Agents_res['store_name'] ? $Agents_res['store_name'] : '';
$user_res[$k]['realname'] = $Agents_res['name'] ? $Agents_res['name'] : '';
$user_res[$k]['user_pic'] = AGENTHEADERIMGURL . $Agents_res['img'];
}
}
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
$data['user_date'] = $user_res;
$data['pagenum'] = $pagenum;
$data['total'] = $total;
$data['user_date'] = array_merge($user_res);
$data['pagenum'] = $pagenum;
$data['total'] = $total;
$data['search_type'] = $search_type;
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($params['user_id']);
$vip_services = new VipService();
$data['examine_vip'] = $vip_services->vip($params['user_id']);
return $this->response("200", "success!", $data);
}
/**
* 邀请记录
*
......@@ -387,26 +386,27 @@ class Client extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function inviteList() {
public function inviteList()
{
$data['status'] = 101;
$data['data'] = array();
$data['msg'] = '';
if (empty($this->agentId)) {
return $this->response($data['status'],'id is null');
return $this->response($data['status'], 'id is null');
}
$params = $this->params;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where['status'] = 0;
$where['referrer_id'] = $this->agentId;
$params = $this->params;
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$where['status'] = 0;
$where['referrer_id'] = $this->agentId;
$where['referrer_source'] = 20;
$fields = 'user_nick,user_phone,user_pic,other_pic,registration_time as create_time';
$data['data'] = $this->user->getUserForInviteList($pageNo, $pageSize,$where, $fields);
$fields = 'user_nick,user_phone,user_pic,other_pic,registration_time as create_time';
$data['data'] = $this->user->getUserForInviteList($pageNo, $pageSize, $where, $fields);
foreach ($data['data'] as $k=>$v) {
$data['data'][$k]['user_pic'] = !empty($v['user_pic']) ? HEADERIMGURL.$v['user_pic'] : $v['other_pic'] ;
$data['data'][$k]['user_phone'] = hide_customer_phone($v['user_phone']);
foreach ($data['data'] as $k => $v) {
$data['data'][$k]['user_pic'] = !empty($v['user_pic']) ? HEADERIMGURL . $v['user_pic'] : $v['other_pic'];
$data['data'][$k]['user_phone'] = hide_customer_phone($v['user_phone']);
$data['data'][$k]['create_time'] = date('Y-m-d', strtotime($v['create_time']));
}
$data['status'] = 200;
......
<?php
namespace app\api_broker\service;
use app\model\UPhoneFollowPp;
/**
* Created by PhpStorm.
* User : zw
* Date : 2018/8/1
* Time : 13:50
* Intro:
*/
class ClientService
{
private $uPhoneFollowUpModel;
public function __construct()
{
$this->uPhoneFollowUpModel = new UPhoneFollowPp();
}
public function dialTotal($user_id)
{
//todo 拨打次数统计
$day = 1;
$num = 10;
$start_time = date("Y-m-d H:i:s", strtotime("-$day day"));
$end_time = date("Y-m-d H:i:s", time());
$params["create_time"] = array( "between", array( $start_time, $end_time ) );
$params["user_id"] = $user_id;
$total = $this->uPhoneFollowUpModel->getSearchCount("", $params);
if ($total > $num) {
return false;
} else {
return true;
}
}
}
\ No newline at end of file
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