Commit 788a9dac authored by zfc's avatar zfc

app客户列表

parent 537feef3
......@@ -4,6 +4,7 @@ namespace app\api_broker\controller;
use app\api_broker\extend\Basic;
use app\model\Users;
use app\model\UPhoneFollowPp;
/**
* Created by PhpStorm.
......@@ -58,4 +59,87 @@ class Client extends Basic
}
return $this->response($this->code, $this->msg,$this->data);
}
/**app 经纪人用户列表
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentUserTb(){
$table= new Users;
$data['msg'] = '';
$time=date("Y-m-d H:i:s",time());//当前时间
$params = $this->request->param();
$search=$params['search'];
if(empty($params['agent_id'])){
return $this->response(100,'参数不全');
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
//条件
//time_minute_diff 时间差(分)48小时内增加的【拥有经纪人】的客户为--受保护客户
$field=['id',
'user_nick',
'user_phone',
'agent_id',
'referrer_id',
'create_time',
"TIMESTAMPDIFF(MINUTE,create_time,'{$time}')as time_minute_diff"];
$where="agent_id in(0,{$params['agent_id']})
or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880";
if(!empty($search)){
$where.=" and user_nick like '%$search%' or user_phone like '%$search%' ";
$data['search']=$search;
}
$order="id asc";
$data['list']=$table->getAgentUserTb($pageNo, $pageSize,$order,$field, $where);
$data['total']=$table->getUserAgentTotal($where);
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(){
$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,'参数不全');
}
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field=['f.id',
'f.content',
'f.create_time',
'u.user_pic',
"TIMESTAMPDIFF(MINUTE,u.create_time,'{$time}')as time_minute_diff"
];
$where="agent_id in(0,{$params['agent_id']})
or TIMESTAMPDIFF(MINUTE,create_time,'{$time}') > 2880";
if(!empty($search)){
$where.=" and f.content like '%$search%' ";
$data['search']=$search;
}
$join=[['u_user u','u.id=f.user_id','left']];
$order="id asc";
$data['list']=$table->getSearch($pageNo, $pageSize,$order,$field,$join, $where);
$data['total']=$table->getUserAgentTotal($where,$join);
return $this->response(200,'成功',$data);
}
}
......@@ -19,4 +19,35 @@ class UPhoneFollowPp extends BaseModel
{
return $this->UPhoneFollowPp->find();
}
/**
* @param int $p
* @param int $pageSize
* @param string $order_
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getSearch($p = 1, $pageSize = 15, $order_= 'id desc',$field,$join, $where){
$r = $this->field($field)
->alias('f')
->join($join)
->where($where)
->order($order_)
->limit($pageSize)
->page($p)
->select();
return $r;
}
public function getUserAgentTotal($params,$join) {
$result = $this->alias('f')
->join($join)
->where($params)->count();
return $result;
}
}
......@@ -146,4 +146,26 @@ class Users extends Model
}
return $data;
}
/**
* @param int $p
* @param int $pageSize
* @param string $order_
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getAgentUserTb($p = 1, $pageSize = 15, $order_= 'id desc',$field, $where){
$r = $this->field($field)
->where($where)
->order($order_)
->limit($pageSize)
->page($p)
->select();
return $r;
}
}
......@@ -226,6 +226,7 @@ Route::group('broker', [
'getLabelsList' => ['api_broker/label/getLabelsList',['method'=>'get']], //标签列表
'add_phone_follow_up' => ['api_broker/broker/add_phone_follow_up',['method'=>'get|post']],//新增-客户电话跟进
'user_search' => ['api_broker/broker/user_search',['method'=>'get|post']],//客户搜索
'agentUserTb' => [ 'api_broker/Client/agentUserTb', [ 'method' => '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