Commit 04e5d398 authored by hujun's avatar hujun

修改客户发送短信

parent ef74744f
...@@ -101,79 +101,59 @@ class Member extends Basic ...@@ -101,79 +101,59 @@ class Member extends Basic
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function sendSms() { public function sendSms() {
$data['data'] = array(); $data['data'] = [];
$data['status'] = 101; $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)) { if (!check_phone($this->params['phone'])) {
$noteLog = new NoteLog(); return $this->response($data['status'], '手机号码错误', $data['data']);
$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 (!empty($send_time[$num-1]) && (time() - strtotime($send_time[$num-1]->send_time) < 58) && $num != 0) { $noteLog = new NoteLog();
$data['msg'] = '1分钟内不能再次获取验证码'; $send_time = $noteLog->field('send_time')->where('phone', $this->params['phone'])
} elseif ($num > 7){ ->where('is_success',1)
$data['msg'] = '短信发送超过上限'; ->where('send_time','between time',[date('Y-m-d').' 00:00:00',date('Y-m-d').' 23:59:59'])
} else { ->select();
$result['statusMsg'] = ''; $num = count($send_time); //发送数量
$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'], '您已注册,请登录');
}
}
//忘记密码验证 if (!empty($send_time[$num-1]) && (time() - strtotime($send_time[$num-1]->send_time) < 58) && $num != 0) {
if ($this->request->param('type') == 'forget') { return $this->response($data['status'], '1分钟内不能再次获取验证码', $data['data']);
$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;
$data['data']['sms_code'] = $_code; if ($num > 7){
$data['data']['token'] = $jwt->createToken($jwt_data); return $this->response($data['status'], '短信发送超过上限', $data['data']);
$data['status'] = 200; }
$data['msg'] = '发送短信成功';
} else { $result['statusMsg'] = '';
$noteLog->is_success = 2; $result['statusCode'] = '';
$data['msg'] = '短信发送失败';
} //注册发送短信验证
$noteLog->save(); if ($this->request->param('type') == 'add') {
} $num = $this->user->where([
} else { 'user_phone'=> $this->params['phone'],
$data['msg'] = '手机号码错误'; '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']); 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