where('mobile', $mobile)->where('created_at', '>=', date('Y-m-d H:i:s', time() - 60))->first(); if ($code) { return \Yz::echoError1("操作太频繁,请稍后再试"); } $code = rand(100000, 999999); //获取当前时间5分钟后的日期时间 $end_time = date('Y-m-d H:i:s', time() + 300); $i=DB::table('send_code')->insert([ 'mobile' => $mobile, 'code' => $code, 'created_at' => date('Y-m-d H:i:s'), 'end_time' => $end_time ]); if ($i) { $aspnet=new AspNetZhuanController(); $aspnet::SendYanZhengMaCode(1,$mobile,$code); return \Yz::Return(true,"发送成功",[]); } else { return \Yz::echoError1("发送失败"); } } //验证验证码 public function CheckMsgCode(){ $mobile = request('mobile'); $code = request('code'); $u = DB::table('send_code') ->where('mobile', $mobile) ->where('code', $code) ->where('end_time', '>=', date('Y-m-d H:i:s')) ->where(['status' => 1]) ->update(['status' => 2]); if($u){ return \Yz::Return(true,"验证成功",['data'=>$code]); }else{ return \Yz::echoError1("验证码无效"); } } }