Commit 04e5d398 authored by hujun's avatar hujun

修改客户发送短信

parent ef74744f
......@@ -101,79 +101,59 @@ class Member extends Basic
* @throws \think\exception\DbException
*/
public function sendSms() {
$data['data'] = array();
$data['data'] = [];
$data['status'] = 101;
if ($this->request->param('phone')) {
$phone = $this->request->param('phone');
if (empty($this->params['phone'])) {
$data['msg'] = '手机号码为空';
return $this->response($data['status'], '手机号码为空', $data['data']);
}
if (check_phone($phone)) {
$noteLog = new NoteLog();
$send_time = $noteLog->field('send_time')->where('phone', $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 (!check_phone($this->params['phone'])) {
return $this->response($data['status'], '手机号码错误', $data['data']);
}
if (!empty($send_time[$num-1]) && (time() - strtotime($send_time[$num-1]->send_time) < 58) && $num != 0) {
$data['msg'] = '1分钟内不能再次获取验证码';
} elseif ($num > 7){
$data['msg'] = '短信发送超过上限';
} else {
$result['statusMsg'] = '';
$result['statusCode'] = '';
//注册发送短信验证
if ($this->request->param('type') == 'add') {
$num = $this->user->where([
'user_phone'=> $phone,
'status' => 0
])->count();
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 ($this->request->param('type') == 'forget') {
$num = $this->user->where('user_phone', $phone)->count();
if ($num == 0) {
return $this->response($data['status'], '您未注册,请注册');
}
}
$message = new MessageUntils();
$_code = mt_rand(1000, 9999) . '';
$result = $message->sendCCPSMS($phone, array($_code, '5分钟'), 214759);
$noteLog->phone = $phone;
$noteLog->template_msg = '【同联商业】您的验证码为'.$_code.',请于5分钟内正确输入,如非本人操作,请忽略此短信。';
$noteLog->code = $_code;
$noteLog->send_time = date('Y-m-d H:i:s');
$result['statusCode'] = 1;
if ($result['statusCode'] == 1) {
$jwt = new JwtUntils();
$noteLog->is_success = 1;
$jwt_data['phone'] = $phone;
$jwt_data['code'] = $_code;
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']);
}
$data['data']['sms_code'] = $_code;
$data['data']['token'] = $jwt->createToken($jwt_data);
$data['status'] = 200;
$data['msg'] = '发送短信成功';
} else {
$noteLog->is_success = 2;
$data['msg'] = '短信发送失败';
}
$noteLog->save();
}
} else {
$data['msg'] = '手机号码错误';
if ($num > 7){
return $this->response($data['status'], '短信发送超过上限', $data['data']);
}
$result['statusMsg'] = '';
$result['statusCode'] = '';
//注册发送短信验证
if ($this->request->param('type') == 'add') {
$num = $this->user->where([
'user_phone'=> $this->params['phone'],
'status' => 0
])->count();
if ($num > 0) {
return $this->response($data['status'], '您已注册,请登录');
}
} else {
$data['msg'] = '手机号码为空';
}
//忘记密码验证
if ($this->request->param('type') == 'forget') {
$num = $this->user->where('user_phone', $this->params['phone'])->count();
if ($num == 0) {
return $this->response($data['status'], '您未注册,请注册');
}
}
$message = new MessageUntils();
$result = $message->sendCheckCode($this->params['phone']);
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