From 1ad2a3673d1e8c5b2484f78a6e8d72cd7c41661b Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 9 Sep 2022 15:30:53 +0800 Subject: [PATCH] code add --- app/controller/Sms.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/controller/Sms.php b/app/controller/Sms.php index bd1303a..5e577d6 100644 --- a/app/controller/Sms.php +++ b/app/controller/Sms.php @@ -41,4 +41,43 @@ class Sms 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("发送失败,请联系客服人员!"); + } + } } \ No newline at end of file