Commit 9e5a7e9e authored by hujun's avatar hujun

token 修改

parent c66a313c
......@@ -169,9 +169,9 @@ class Broker extends Basic
$Two_days_ago = date("Y-m-d h:i:s",strtotime("-2 day"));
//dump($Two_days_ago);
$params = $this->params;
/* $params['phone_or_name'] ='22';
$params['pagenum'] ='1';
$params['user_id'] ='10';*/
/* $params['phone_or_name'] ='22';
$params['pagenum'] ='1';
$params['user_id'] ='10';*/
if (!isset($params['phone_or_name']) || !isset($params['user_id'])) {
return $this->response("300", "参数不全", [ 'remote_groupid' => '' ]);
}
......@@ -184,19 +184,19 @@ class Broker extends Basic
$user = new Users();
// 查询数据集
$user_res =$user ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->whereOr('agent_id',$user_id)
->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
->whereOr('agent_id',$user_id)
->limit($pagesize)
->page($pagenum)
->field('id as user_id,sex,user_nick,user_phone')
->select();
->limit($pagesize)
->page($pagenum)
->field('id as user_id,sex,user_nick,user_phone')
->select();
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total =$user ->where('user_nick|user_phone','like',"%$phone_or_name%")
->where('create_time','< time',$Two_days_ago)
->whereOr('agent_id',$user_id)
->count();
->where('create_time','< time',$Two_days_ago)
->whereOr('agent_id',$user_id)
->count();
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
$user_res=json_decode(json_encode($user_res),true);//对象转数组
......@@ -363,8 +363,8 @@ class Broker extends Basic
*/
public function token(){
$jwt = new JwtUntils();
$phone = $this->params['phone'];
$token = $jwt->createToken($phone);
$data['phone'] = $this->params['phone'];
$token = $jwt->createToken($data);
return $this->response(200, "", ['AuthToken'=>$token]);
}
......
......@@ -29,7 +29,7 @@ class Client extends Basic
}
public function selectUser(){
}
/**
......@@ -54,11 +54,11 @@ class Client extends Basic
$data['start'] = $this->user->edit($this->params);
if ($data['start'] == -1) {
$this->code = 101;
$this->msg = '该客户手机号已存在于系统内!';
$this->msg = '该用户已存在';
}
if($data['start']==1){
$data['id']= $this->user->id;
$data['id']= $this->user->id;
$this->operating_records($this->params['ccr_id'], $type=3, $remark='用户添加',0,$data['id']);
}else{
$this->code = 101;
......@@ -78,7 +78,32 @@ class Client extends Basic
}
/**经纪人搜索
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function agentSearch(){
header('Access-Control-Allow-Origin:*');
$table= new Agents;
$data['msg'] = '';
$params = $this->request->param();
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field = ['id','realname','phone'];
$where = 'level in(2,5) ';
if(!empty($params['search'])){
$where .=" and realname like '%{$params['search']}%' or phone like '%{$params['search']}%' ";
$data['search'] = $params['search'];
}
$order="id desc";
$data['list']=$table->searchList($pageNo, $pageSize,$order,$field, $where);
$total=$table->searchTotal($where);
$data['total']= ceil($total / $pageSize);
$data['page']=$pageNo;
return $this->response(200,'成功',$data);
}
/**经纪人搜索
* @return \think\Response
......@@ -145,7 +170,7 @@ class Client extends Basic
$data['search']=$search;
}
// echo $where;exit;
// echo $where;exit;
$order="id desc";
$data['list']=$table->getAgentUserTb($pageNo, $pageSize,$order,$field, $where);
......@@ -177,14 +202,14 @@ class Client extends Basic
$pageNo = empty($params['pageNo']) ? 1 : $params['pageNo'];
$pageSize = empty($params['pageSize']) ? 15 : $params['pageSize'];
$field=['f.id',
'f.user_id',
'f.agent_id',
'f.content',
'f.create_time',
'a.realname',
'a.agentshopname',
'a.sub_shopname',
"TIMESTAMPDIFF(MINUTE,f.create_time,'{$time}')as time_minute_diff"
'f.user_id',
'f.agent_id',
'f.content',
'f.create_time',
'a.realname',
'a.agentshopname',
'a.sub_shopname',
"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 ) ";
if(!empty($search)){
......
......@@ -70,7 +70,8 @@ class Basic extends Controller
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array('HS256')); //解码token
$this->timeStamp_ = $result->timeStamp_;
$is = Db::table('agents')->where('phone', $result->data)->count();
$this->agentPhone = $result->data->phone;
$is = Db::table('agents')->where('phone', $result->data->phone)->count();
if ($is == 0) {
echo json_encode(array("code" => "300", "msg" => "用户验证失败,重新登录!", "data" => [], "type" => "json"));
......@@ -85,21 +86,21 @@ class Basic extends Controller
/*临时验证 end*/
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
/* if (isset($this->params['AuthToken']) && $this->params['AuthToken'] != 'null' && !empty($this->params['AuthToken'])) {
$jwt = new \Firebase\JWT\JWT();
$this->authToken = $this->params['AuthToken'];
$result = $jwt->decode($this->authToken, config('jwt_key'), array( 'HS256' )); //解码token
$this->userId = $result->data->id;
$this->phone = $result->data->phone;
$this->userNick = $result->data->userNick;
$this->timeStamp_ = $result->timeStamp_;
}
$requestPath = $this->request->routeInfo()["rule"][0] . "/" . $this->request->routeInfo()["rule"][1];
//过滤掉不需要验证token的接口
if (!in_array(trim($requestPath), $this->filterVerify)) {
$this->tokenVerify();
}*/
}
......
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