Commit 1da0d767 authored by clone's avatar clone

bug

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