Commit fc14cf16 authored by hujun's avatar hujun

经纪人忘记密码

parent 04e5d398
...@@ -10,9 +10,11 @@ namespace app\api_broker\controller; ...@@ -10,9 +10,11 @@ namespace app\api_broker\controller;
use app\api\untils\JwtUntils; use app\api\untils\JwtUntils;
use app\api\untils\MessageUntils;
use app\api_broker\extend\Basic; use app\api_broker\extend\Basic;
use app\model\AAgents; use app\model\AAgents;
use app\model\GOperatingRecords; use app\model\GOperatingRecords;
use app\model\NoteLog;
use app\model\ULabels; use app\model\ULabels;
use app\model\UPhoneFollowPp; use app\model\UPhoneFollowPp;
use app\model\Users; use app\model\Users;
...@@ -308,6 +310,55 @@ class Broker extends Basic ...@@ -308,6 +310,55 @@ class Broker extends Basic
return $this->response($data['code'], $data['msg'], $data['data']); return $this->response($data['code'], $data['msg'], $data['data']);
} }
/**
* 经纪人忘记密码
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function forgetPwd() {
$data['code'] = 101;
$data['msg'] = "";
$data['data'] = [];
if (empty($this->params['pwd'])) {
return $this->response(101, '手机号为空', $data['data']);
}
if (empty($this->params['token'])) {
return $this->response(101, 'Token is null', $data['data']);
}
if (empty($this->params['phone'])) {
return $this->response(101, 'Token is null', $data['data']);
}
$agents = new AAgents();
$agent_data = $agents->getInfo($this->params['phone'], '', false, 'id');
if (empty($agent_data['id'])) {
return $this->response(101, '没有该用户信息', $data['data']);
}
$jwt = new JwtUntils();
$jwt_data = $jwt->getDecode($this->params['token']);
$code = $jwt_data['data']['code'];
$jwt_phone = $jwt_data['data']['phone'];
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['status'] = 200;
$data['msg'] = '修改成功';
} else {
$data['msg'] = '验证码错误';
}
return $this->response($data['code'], $data['msg'], $data['data']);
}
/** /**
* 上传头像 * 上传头像
* *
...@@ -382,4 +433,66 @@ class Broker extends Basic ...@@ -382,4 +433,66 @@ class Broker extends Basic
$data['token'] = $this->authToken; $data['token'] = $this->authToken;
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 sendSms() {
$data['data'] = [];
$data['status'] = 101;
if (empty($this->params['phone'])) {
$data['msg'] = '手机号码为空';
return $this->response($data['status'], '手机号码为空', $data['data']);
}
if (!check_phone($this->params['phone'])) {
return $this->response($data['status'], '手机号码错误', $data['data']);
}
//忘记密码验证
if ($this->params['type'] == 'forget') {
$agent = new AAgents();
$num = $agent->getAgentExist($this->params['phone']);
if ($num == 0) {
return $this->response($data['status'], '您未注册,请注册');
}
}
$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'])
->select();
$num = count($send_time); //发送数量
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){
return $this->response($data['status'], '短信发送超过上限', $data['data']);
}
$result['statusMsg'] = '';
$result['statusCode'] = '';
$message = new MessageUntils();
$result = $message->sendCheckCode($this->params['phone']);
$result['status']=1;
if (empty($result['status'])) {
$data['code'] = 101;
$data['msg'] = '短信发送失败';
} else {
$data['data']['token'] = $result['token'];
$data['data']['sms_code'] = $result['sms_code'];
$data['msg'] = '短信发送成功';
}
return $this->response($data['status'], $data['msg'], $data['data']);
}
} }
\ No newline at end of file
...@@ -21,12 +21,13 @@ class AAgents extends BaseModel ...@@ -21,12 +21,13 @@ class AAgents extends BaseModel
* @param $phone * @param $phone
* @param string $pwd * @param string $pwd
* @param bool $department * @param bool $department
* @param string $field
* @return array|false|\PDOStatement|string|\think\Model * @return array|false|\PDOStatement|string|\think\Model
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getInfo($phone, $pwd = '', $department = true) public function getInfo($phone, $pwd = '', $department = true, $field = '*')
{ {
$where['status'] = 0; $where['status'] = 0;
$where['phone'] = $phone; $where['phone'] = $phone;
...@@ -35,7 +36,7 @@ class AAgents extends BaseModel ...@@ -35,7 +36,7 @@ class AAgents extends BaseModel
$where['password'] = $pwd; $where['password'] = $pwd;
} }
$agents_data = $this->where($where)->find(); $agents_data = $this->field($field)->where($where)->find();
if (!$department) { if (!$department) {
return $agents_data; return $agents_data;
...@@ -309,6 +310,18 @@ class AAgents extends BaseModel ...@@ -309,6 +310,18 @@ class AAgents extends BaseModel
return $result; return $result;
} }
/**
* 忘记密码
*
* @param $id
* @param $pwd
* @return false|int
*/
public function forgetPwd($id, $pwd)
{
return $this->save([ 'password' => md5($pwd) ], [ 'id' => $id ]);
}
public function saveList() public function saveList()
{ {
......
...@@ -313,6 +313,7 @@ Route::group('broker', [ ...@@ -313,6 +313,7 @@ Route::group('broker', [
'statusBargain' => [ 'api_broker/OrderLog/statusBargain', [ 'method' => 'get|post' ] ], 'statusBargain' => [ 'api_broker/OrderLog/statusBargain', [ 'method' => 'get|post' ] ],
'login' => [ 'api_broker/Broker/login', [ 'method' => 'post' ] ], //经纪人登陆 'login' => [ 'api_broker/Broker/login', [ 'method' => 'post' ] ], //经纪人登陆
'editAgent' => [ 'api_broker/Broker/editAgent', [ 'method' => 'post' ] ], //经纪人修改密码 'editAgent' => [ 'api_broker/Broker/editAgent', [ 'method' => 'post' ] ], //经纪人修改密码
'forgetPwd' => [ 'api_broker/Broker/forgetPwd', [ 'method' => 'post' ] ], //经纪人忘记密码
'uploadHeadImg' => [ 'api_broker/Broker/uploadHeadImg', [ 'method' => 'post' ] ], //经纪人上传头像 'uploadHeadImg' => [ 'api_broker/Broker/uploadHeadImg', [ 'method' => 'post' ] ], //经纪人上传头像
'editClient' => [ 'api_broker/Client/editClient', [ 'method' => 'get|post' ] ],//添加和编辑客户 'editClient' => [ 'api_broker/Client/editClient', [ 'method' => 'get|post' ] ],//添加和编辑客户
'getBroker' => [ 'api_broker/broker/getBroker',['method'=>'get']],//获取经纪人列表 'getBroker' => [ 'api_broker/broker/getBroker',['method'=>'get']],//获取经纪人列表
...@@ -374,6 +375,7 @@ Route::group('broker', [ ...@@ -374,6 +375,7 @@ Route::group('broker', [
'add_supervise' => ['api_broker/Supervise/add', ['method' => 'post']], //监督执行 'add_supervise' => ['api_broker/Supervise/add', ['method' => 'post']], //监督执行
'addBargain' => ['api_broker/OrderLog/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成) 'addBargain' => ['api_broker/OrderLog/addBargain', [ 'method' => 'post' ] ], //新增成交报告佣金(分佣提成)
'getSupervise' => ['api_broker/Supervise/getSupervise', [ 'method' => 'get' ] ], //监督执行列表 'getSupervise' => ['api_broker/Supervise/getSupervise', [ 'method' => 'get' ] ], //监督执行列表
'sendSms' => ['api_broker/broker/sendSms', [ 'method' => 'post' ] ], //发送短信
]); ]);
......
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