注释发短信代码

huazhiyu
lqmac 1 year ago
parent 17aec05a90
commit 0dbbf4aa6e
  1. 6
      application/api/controller/Sms.php
  2. 12
      application/common/library/Sms.php

@ -32,11 +32,11 @@ class Sms extends Api
$this->error(__('手机号不正确')); $this->error(__('手机号不正确'));
} }
$last = Smslib::get($mobile, $event); $last = Smslib::get($mobile, $event);
if ($last && time() - $last['createtime'] < 60) { if ($last && time() - $last['createtime'] < 5) {
$this->error(__('发送频繁')); $this->error(__('发送频繁'));
} }
$ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count(); $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
if ($ipSendTotal >= 5) { if ($ipSendTotal >= 20) {
$this->error(__('发送频繁')); $this->error(__('发送频繁'));
} }
if ($event) { if ($event) {
@ -57,7 +57,7 @@ class Sms extends Api
} }
$ret = Smslib::send($mobile, null, $event); $ret = Smslib::send($mobile, null, $event);
if ($ret) { if ($ret) {
$this->success(__('发送成功')); $this->success(__('发送成功'),['code' => $ret]);
} else { } else {
$this->error(__('发送失败,请检查短信配置是否正确')); $this->error(__('发送失败,请检查短信配置是否正确'));
} }

@ -53,12 +53,12 @@ class Sms
$time = time(); $time = time();
$ip = request()->ip(); $ip = request()->ip();
$sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]); $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]);
$result = Hook::listen('sms_send', $sms, null, true); // $result = Hook::listen('sms_send', $sms, null, true);
if (!$result) { // if (!$result) {
$sms->delete(); // $sms->delete();
return false; // return false;
} // }
return true; return $code;
} }
/** /**

Loading…
Cancel
Save