Commit 1da0d767 authored by clone's avatar clone

bug

parent 66a631c2
...@@ -24,6 +24,7 @@ use think\Request; ...@@ -24,6 +24,7 @@ use think\Request;
class Broker extends Basic class Broker extends Basic
{ {
protected $a_agents; protected $a_agents;
public function __construct(Request $request = null) public function __construct(Request $request = null)
{ {
parent::__construct($request); parent::__construct($request);
...@@ -38,32 +39,33 @@ class Broker extends Basic ...@@ -38,32 +39,33 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function login() { public function login()
{
$data['data'] = []; $data['data'] = [];
if (empty($this->params['phone']) && empty($this->params['pwd'])) { if (empty($this->params['phone']) && empty($this->params['pwd'])) {
return $this->response(101, '用户名或密码为空',$data['data']); return $this->response(101, '用户名或密码为空', $data['data']);
} }
$field = 'id,device_id,store_id,auth_group_id,district_id,level,name,phone,password,sex,img,inviter_id,status'; $field = 'id,device_id,store_id,auth_group_id,district_id,level,name,phone,password,sex,img,inviter_id,status';
$where['phone'] = $this->params['phone']; $where['phone'] = $this->params['phone'];
$where['id'] = ['<>',1]; $where['id'] = [ '<>', 1 ];
$agents_data = $this->a_agents->getAgentInfo($field, '', $where); $agents_data = $this->a_agents->getAgentInfo($field, '', $where);
if (empty($agents_data)) { if (empty($agents_data)) {
return $this->response(101, '没有该用户',$data['data']); return $this->response(101, '没有该用户', $data['data']);
} }
if ($agents_data['status'] == 2) { if ($agents_data['status'] == 2) {
return $this->response(101, '您已离职',$data['data']); return $this->response(101, '您已离职', $data['data']);
} }
if ($agents_data['status'] == 1) { if ($agents_data['status'] == 1) {
return $this->response(101, '账号已冻结',$data['data']); return $this->response(101, '账号已冻结', $data['data']);
} }
if ($agents_data['password'] != md5($this->params['pwd'])) { if ($agents_data['password'] != md5($this->params['pwd'])) {
return $this->response(101, '密码错误',$data['data']); return $this->response(101, '密码错误', $data['data']);
} }
$agents_data['device_id'] = $this->params['device_id']; $agents_data['device_id'] = $this->params['device_id'];
...@@ -72,7 +74,7 @@ class Broker extends Basic ...@@ -72,7 +74,7 @@ class Broker extends Basic
$agents_data->allowField(true)->save(); $agents_data->allowField(true)->save();
if (!empty($agents_data['img'])) { if (!empty($agents_data['img'])) {
$agents_data['img'] = AGENTHEADERIMGURL.$agents_data->img; $agents_data['img'] = AGENTHEADERIMGURL . $agents_data->img;
} }
$jwt_data['id'] = $agents_data['id']; $jwt_data['id'] = $agents_data['id'];
...@@ -97,7 +99,8 @@ class Broker extends Basic ...@@ -97,7 +99,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getBroker() { public function getBroker()
{
$data['status'] = 200; $data['status'] = 200;
$data['data'] = ''; $data['data'] = '';
$data['msg'] = ''; $data['msg'] = '';
...@@ -106,16 +109,16 @@ class Broker extends Basic ...@@ -106,16 +109,16 @@ class Broker extends Basic
$pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize']; $pageSize = empty($this->params['pageSize']) ? 10 : $this->params['pageSize'];
$where = 'status <> 2'; $where = 'status <> 2';
if ($this->params['phone']) { if ($this->params['phone']) {
$where .= ' AND concat(phone,name) like "%'.$this->params['phone'].'%"'; $where .= ' AND concat(phone,name) like "%' . $this->params['phone'] . '%"';
} }
if ($this->params['level']) { if ($this->params['level']) {
$where .= ' AND level in ('.$this->params['level'].')'; $where .= ' AND level in (' . $this->params['level'] . ')';
} }
if ($where) { if ($where) {
$field = 'id,name,phone'; $field = 'id,name,phone';
$data['data'] = $this->a_agents->getList($pageNo, $pageSize, 'id DESC', $field, '',$where); $data['data'] = $this->a_agents->getList($pageNo, $pageSize, 'id DESC', $field, '', $where);
} else { } else {
$data['msg'] = '没有经纪人信息'; $data['msg'] = '没有经纪人信息';
} }
...@@ -161,7 +164,7 @@ class Broker extends Basic ...@@ -161,7 +164,7 @@ class Broker extends Basic
//dump($UPhoneFollowPp->id);exit; //dump($UPhoneFollowPp->id);exit;
//跟进,对客户状态进行更新 0:求租;1:已租;-1:无效 //跟进,对客户状态进行更新 0:求租;1:已租;-1:无效
$Users = new Users(); $Users = new Users();
$Users -> update_user_status(['id'=>$user_id,'user_status'=>$user_status]); $Users->update_user_status([ 'id' => $user_id, 'user_status' => $user_status ]);
if ($UPhoneFollowPp->id) { if ($UPhoneFollowPp->id) {
return $this->response("200", "success!", $UPhoneFollowPp->id); return $this->response("200", "success!", $UPhoneFollowPp->id);
...@@ -180,7 +183,7 @@ class Broker extends Basic ...@@ -180,7 +183,7 @@ class Broker extends Basic
*/ */
public function user_search() public function user_search()
{ {
$Two_days_ago = date("Y-m-d h:i:s",strtotime("-2 day")); $Two_days_ago = date("Y-m-d h:i:s", strtotime("-2 day"));
//dump($Two_days_ago); //dump($Two_days_ago);
$params = $this->params; $params = $this->params;
/* $params['phone_or_name'] ='周振磊'; /* $params['phone_or_name'] ='周振磊';
...@@ -197,35 +200,38 @@ class Broker extends Basic ...@@ -197,35 +200,38 @@ class Broker extends Basic
$user = new Users(); $user = new Users();
// 查询数据集 // 查询数据集
$user_res =$user ->where('user_name|user_phone','like',"%$phone_or_name%") $user_res = $user->where('user_name|user_phone', 'like', "%$phone_or_name%")
//->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户 //->where('create_time','< time',$Two_days_ago)//小于两天前,即排除48小时内受保护的客户
// ->whereOr('agent_id',$user_id) // ->whereOr('agent_id',$user_id)
->limit($pagesize) ->limit($pagesize)
->page($pagenum) ->page($pagenum)
->field('id as user_id,sex,user_name,user_phone') ->field('id as user_id,sex,user_name,user_nick,user_phone')
->select(); ->select();
// echo $user->getLastSql(); // echo $user->getLastSql();
//$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum); //$user_res =$user->user_search($phone_or_name,$Two_days_ago,$user_id,$pagesize,$pagenum);
$total =$user ->where('user_name|user_phone','like',"%$phone_or_name%") $total = $user->where('user_name|user_phone|user_nick', 'like', "%$phone_or_name%")
//->where('create_time','< time',$Two_days_ago) //->where('create_time','< time',$Two_days_ago)
// ->whereOr('agent_id',$user_id) // ->whereOr('agent_id',$user_id)
->count(); ->count();
$total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1); $total = intval($total / $pagesize) + (($total % $pagesize == 0) ? 0 : 1);
$user_res=json_decode(json_encode($user_res),true);//对象转数组 $user_res = json_decode(json_encode($user_res), true);//对象转数组
foreach($user_res as $k=>$v){ foreach ($user_res as $k => $v) {
//dump($v);exit; //dump($v);exit;
$user_res[$k]['user_name']=$v['user_name']?$v['user_name']:'未知'; if (empty($v["user_name"])) {
$user_res[$k]['user_name'] = $v["user_nick"];
}
$user_res[$k]['user_name'] = $v['user_name'] ? $v['user_name'] : '未知';
} }
/*dump($total); /*dump($total);
var_dump($user_res); var_dump($user_res);
exit;*/ exit;*/
if ($user_res) { if ($user_res) {
return $this->response("200", "success!", ['user_date'=>$user_res,'pagenum'=>$pagenum,'total'=>$total]); return $this->response("200", "success!", [ 'user_date' => $user_res, 'pagenum' => $pagenum, 'total' => $total ]);
} else { } else {
return $this->response("200", "request null",['user_date'=>[],'pagenum'=>$pagenum,'total'=>$total]); return $this->response("200", "request null", [ 'user_date' => [], 'pagenum' => $pagenum, 'total' => $total ]);
} }
} }
...@@ -278,16 +284,16 @@ class Broker extends Basic ...@@ -278,16 +284,16 @@ class Broker extends Basic
$user = new Users(); $user = new Users();
$user_res = $user->useraction_search_user_res($user_id); $user_res = $user->useraction_search_user_res($user_id);
$user_res['user_pic'] = HEADERIMGURL.$user_res['user_pic']; $user_res['user_pic'] = HEADERIMGURL . $user_res['user_pic'];
$agents_res = $agent->verifyUser('name,phone','', ['id'=>$user_res['agent_id']]); $agents_res = $agent->verifyUser('name,phone', '', [ 'id' => $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'] : '未知';
$orderLog = new OrderLogService(); $orderLog = new OrderLogService();
$records = new GOperatingRecords(); $records = new GOperatingRecords();
$records_result = $records->user_history($user_id); $records_result = $records->user_history($user_id);
$data['user_info'] = $user_res; $data['user_info'] = $user_res;
$data['user_date'] = $orderLog->selectListByUserId($user_id,''); $data['user_date'] = $orderLog->selectListByUserId($user_id, '');
$data['user_history'] = $records_result; $data['user_history'] = $records_result;
$data['agent_path'] = AGENTHEADERIMGURL; $data['agent_path'] = AGENTHEADERIMGURL;
return $this->response("200", "success!", $data); return $this->response("200", "success!", $data);
...@@ -297,25 +303,27 @@ class Broker extends Basic ...@@ -297,25 +303,27 @@ class Broker extends Basic
* 搜索动态 * 搜索动态
* @return \think\Response * @return \think\Response
*/ */
public function userStateSearch(){ public function userStateSearch()
{
$params = $this->params; $params = $this->params;
/* $params = array( /* $params = array(
"user_id" => 828, "user_id" => 828,
"keyword" => "asdfas" "keyword" => "asdfas"
);*/ );*/
if(!isset($params["user_id"]) || !isset($params["keyword"])){ if (!isset($params["user_id"]) || !isset($params["keyword"])) {
return $this->response("101","请输入需要检索的关键词"); return $this->response("101", "请输入需要检索的关键词");
} }
$orderLog = new OrderLogService(); $orderLog = new OrderLogService();
$data = $orderLog->selectListByUserId($params["user_id"],$params["keyword"]); $data = $orderLog->selectListByUserId($params["user_id"], $params["keyword"]);
$data['agent_path'] = AGENTHEADERIMGURL; $data['agent_path'] = AGENTHEADERIMGURL;
return $this->response("200","request success",$data); return $this->response("200", "request success", $data);
} }
/** /**
* 编辑密码 * 编辑密码
*/ */
public function editAgent() { public function editAgent()
{
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -342,7 +350,8 @@ class Broker extends Basic ...@@ -342,7 +350,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function forgetPwd() { public function forgetPwd()
{
$data['code'] = 101; $data['code'] = 101;
$data['msg'] = ""; $data['msg'] = "";
$data['data'] = []; $data['data'] = [];
...@@ -373,7 +382,7 @@ class Broker extends Basic ...@@ -373,7 +382,7 @@ class Broker extends Basic
if ($code == $this->request->param('code') && $jwt_phone == $this->params['phone']) { if ($code == $this->request->param('code') && $jwt_phone == $this->params['phone']) {
$agents->forgetPwd($agent_data['id'], $this->params['pwd']); $agents->forgetPwd($agent_data['id'], $this->params['pwd']);
$data['data'] = ['id' => $agent_data['id']]; $data['data'] = [ 'id' => $agent_data['id'] ];
$data['code'] = 200; $data['code'] = 200;
$data['msg'] = '修改成功'; $data['msg'] = '修改成功';
} else { } else {
...@@ -391,33 +400,34 @@ class Broker extends Basic ...@@ -391,33 +400,34 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function uploadHeadImg() { public function uploadHeadImg()
{
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = ''; $data['msg'] = '';
$data['data'] = ''; $data['data'] = '';
$file = request()->file('image'); $file = request()->file('image');
if($file){ if ($file) {
$path = ROOT_PATH . 'public' . DS . 'static'. DS . 'user_header'; $path = ROOT_PATH . 'public' . DS . 'static' . DS . 'user_header';
$info = $file->validate(['size'=>512000,'ext'=>'jpg,png']) //限制500KB $info = $file->validate([ 'size' => 512000, 'ext' => 'jpg,png' ])//限制500KB
->move($path); ->move($path);
if($info){ if ($info) {
$user = new AAgents(); $user = new AAgents();
$user_data = $user->field('img')->where('id',$this->agentId)->find(); $user_data = $user->field('img')->where('id', $this->agentId)->find();
@unlink($path.DS.$user_data->img); //删除原来的图片 @unlink($path . DS . $user_data->img); //删除原来的图片
$img_path = $info->getSaveName(); //生成的图片路径 $img_path = $info->getSaveName(); //生成的图片路径
//更新用户信息 //更新用户信息
$user_data->img = $img_path; $user_data->img = $img_path;
$user_data->save(); $user_data->save();
$static_path = $path.DS.$img_path; //生成图片的绝对路径 $static_path = $path . DS . $img_path; //生成图片的绝对路径
$image = \think\Image::open($static_path); $image = \think\Image::open($static_path);
$image->thumb(500, 500)->save($static_path); //生成缩略图 $image->thumb(500, 500)->save($static_path); //生成缩略图
$data['status'] = 200; $data['status'] = 200;
$data['msg'] = '上传成功'; $data['msg'] = '上传成功';
$data['data'] = ['file_name' => AGENTHEADERIMGURL . $img_path]; $data['data'] = [ 'file_name' => AGENTHEADERIMGURL . $img_path ];
}else{ } else {
// 上传失败获取错误信息 // 上传失败获取错误信息
$data['msg'] = $file->getError(); $data['msg'] = $file->getError();
} }
...@@ -433,12 +443,13 @@ class Broker extends Basic ...@@ -433,12 +443,13 @@ class Broker extends Basic
* *
* @return \think\Response * @return \think\Response
*/ */
public function token(){ public function token()
{
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$jwt = new JwtUntils(); $jwt = new JwtUntils();
$data['phone'] = $this->params['phone']; $data['phone'] = $this->params['phone'];
$token = $jwt->createToken($data); $token = $jwt->createToken($data);
return $this->response(200, "", ['AuthToken'=>$token]); return $this->response(200, "", [ 'AuthToken' => $token ]);
} }
/** /**
...@@ -449,7 +460,8 @@ class Broker extends Basic ...@@ -449,7 +460,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getAgentsByPhone() { public function getAgentsByPhone()
{
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Origin:*');
$agents = new AAgents(); $agents = new AAgents();
$data = $agents->getInfo($this->agentPhone); $data = $agents->getInfo($this->agentPhone);
...@@ -466,7 +478,8 @@ class Broker extends Basic ...@@ -466,7 +478,8 @@ class Broker extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function sendSms() { public function sendSms()
{
$data['data'] = []; $data['data'] = [];
$data['status'] = 101; $data['status'] = 101;
...@@ -490,16 +503,16 @@ class Broker extends Basic ...@@ -490,16 +503,16 @@ class Broker extends Basic
$noteLog = new NoteLog(); $noteLog = new NoteLog();
$send_time = $noteLog->field('send_time')->where('phone', $this->params['phone']) $send_time = $noteLog->field('send_time')->where('phone', $this->params['phone'])
->where('is_success',1) ->where('is_success', 1)
->where('send_time','between time',[date('Y-m-d').' 00:00:00',date('Y-m-d').' 23:59:59']) ->where('send_time', 'between time', [ date('Y-m-d') . ' 00:00:00', date('Y-m-d') . ' 23:59:59' ])
->select(); ->select();
$num = count($send_time); //发送数量 $num = count($send_time); //发送数量
if (!empty($send_time[$num-1]) && (time() - strtotime($send_time[$num-1]->send_time) < 58) && $num != 0) { if (!empty($send_time[$num - 1]) && (time() - strtotime($send_time[$num - 1]->send_time) < 58) && $num != 0) {
return $this->response($data['status'], '1分钟内不能再次获取验证码', $data['data']); return $this->response($data['status'], '1分钟内不能再次获取验证码', $data['data']);
} }
if ($num > 7){ if ($num > 7) {
return $this->response($data['status'], '短信发送超过上限', $data['data']); return $this->response($data['status'], '短信发送超过上限', $data['data']);
} }
...@@ -527,7 +540,8 @@ class Broker extends Basic ...@@ -527,7 +540,8 @@ class Broker extends Basic
* @throws \Endroid\QrCode\Exception\InvalidPathException * @throws \Endroid\QrCode\Exception\InvalidPathException
* @throws \Endroid\QrCode\Exception\InvalidWriterException * @throws \Endroid\QrCode\Exception\InvalidWriterException
*/ */
public function qrCode() { public function qrCode()
{
$parms = $this->params; $parms = $this->params;
$data['status'] = 101; $data['status'] = 101;
...@@ -543,9 +557,9 @@ class Broker extends Basic ...@@ -543,9 +557,9 @@ class Broker extends Basic
} }
$code = new GenerateCodeUntils(); $code = new GenerateCodeUntils();
$url = $this->request->domain().'/app/share_register?referrer_source=20&id='.$this->agentId; $url = $this->request->domain() . '/app/share_register?referrer_source=20&id=' . $this->agentId;
$path = $code->getCode($url, $this->agentId, 2); $path = $code->getCode($url, $this->agentId, 2);
$data['data'] = ['path' => $this->request->domain().'/'.$path]; $data['data'] = [ 'path' => $this->request->domain() . '/' . $path ];
$data['status'] = 200; $data['status'] = 200;
return $this->response($data['status'], $data['msg'], $data['data']); return $this->response($data['status'], $data['msg'], $data['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