diff --git a/application/api/model/Sms.php b/application/api/model/Sms.php index c132806..85127ec 100644 --- a/application/api/model/Sms.php +++ b/application/api/model/Sms.php @@ -40,14 +40,7 @@ class Sms extends Model return ['code' => 0, 'msg' => '验证码错误次数过多,账号已被封禁,请联系管理员处理','data' =>null]; } - //验证码错误次数 - $count_sms = max(5 - $sms_count, 0); - $data = [ - 'mobile' => $mobile, - 'sms' => $code, - 'createtime'=> time(), - ]; - db::name('sms_error')->insert($data); + $is_code = db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->order('id desc')->find(); if ($is_code && $is_code['code'] == $code) { //验证码正确 @@ -64,6 +57,14 @@ class Sms extends Model db::name('sms')->where(['mobile' => $mobile, 'event' => $type])->delete(); return ['code' =>1, 'msg' =>'验证码正确','data' =>null]; } else { + //验证码错误次数 + $count_sms = max(5 - $sms_count, 0); + $data = [ + 'mobile' => $mobile, + 'sms' => $code, + 'createtime'=> time(), + ]; + db::name('sms_error')->insert($data); return ['code' => 0, 'msg' => '验证码错误,'.$count_sms.'次后账号将被封禁24小时','data' =>null]; } }