This commit is contained in:
knowpia
2022-09-09 15:30:53 +08:00
parent 225d8cae21
commit 1ad2a3673d

View File

@@ -41,4 +41,43 @@ class Sms
return show("发送失败,请联系客服人员!"); return show("发送失败,请联系客服人员!");
} }
} }
public function repass_send_code(){
if(empty($GLOBALS['data']['data']['mobile'])){
return show("手机号不能为空!");
}
$mobileNumber = $GLOBALS['data']['data']['mobile'];
if(!is_mobile_number($mobileNumber)){
return show("手机号不正确!");
}
if(!Db::name("student")->where("mobile",$mobileNumber)->find()){
return show("此手机号未注册家长信息,请核对!");
}
$timeOut = 60;
$info = Db::name("app_sms")->order("id desc")->where("mobile",$mobileNumber)->find();
if(!empty($info) && (time() - $info['create_time'])<$timeOut){
return show("请在". ($timeOut-(time()-$info['create_time'])) ."后重新发送!");
}
$code = rand(111111,999999);
try {
if(!env("APP_DEBUG")){
$result = \app\tools\Sms::sendmsg($mobileNumber,$code);
if($result['code'] != 1){
return show("运营商接口无法返回!");
}
}else{
$code = "000000";
}
Db::name("app_sms")->insert([
"ipaddress"=>get_client_ip(),
"mobile"=>$mobileNumber,
"code"=>$code,
"create_time"=>time(),
"count"=>0
]);
return show("发送成功!",SUCCESS_CODE);
}catch(\Exception $e){
return show("发送失败,请联系客服人员!");
}
}
} }