From 173a003dd7867b3023602f0b09521d8fd63ce00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Mon, 13 Oct 2025 10:10:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E7=A0=81=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Sms.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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]; } }