|
@@ -5,8 +5,12 @@ namespace App\Http\Controllers\Aside; |
|
@@ -5,8 +5,12 @@ namespace App\Http\Controllers\Aside; |
|
5
|
|
5
|
|
|
6
|
use App\Enums\Common\Code;
|
6
|
use App\Enums\Common\Code;
|
|
7
|
use App\Http\Logic\Aside\LoginLogic;
|
7
|
use App\Http\Logic\Aside\LoginLogic;
|
|
|
|
8
|
+use App\Models\Manage\Manage;
|
|
|
|
9
|
+use App\Models\SmsLog;
|
|
|
|
10
|
+use App\Models\User\User as UserModel;
|
|
8
|
use App\Rules\Mobile;
|
11
|
use App\Rules\Mobile;
|
|
9
|
use Illuminate\Http\Request;
|
12
|
use Illuminate\Http\Request;
|
|
|
|
13
|
+use Mrgoon\AliSms\AliSms;
|
|
10
|
|
14
|
|
|
11
|
/**
|
15
|
/**
|
|
12
|
* @group 登录
|
16
|
* @group 登录
|
|
@@ -55,4 +59,37 @@ class LoginController extends BaseController |
|
@@ -55,4 +59,37 @@ class LoginController extends BaseController |
|
55
|
$data = $logic->accessAddress();
|
59
|
$data = $logic->accessAddress();
|
|
56
|
return $this->response('success',Code::SUCCESS,$data);
|
60
|
return $this->response('success',Code::SUCCESS,$data);
|
|
57
|
}
|
61
|
}
|
|
|
|
62
|
+
|
|
|
|
63
|
+ /**
|
|
|
|
64
|
+ * 发送登录短信
|
|
|
|
65
|
+ * @param Request $request
|
|
|
|
66
|
+ * @return \Illuminate\Http\JsonResponse
|
|
|
|
67
|
+ */
|
|
|
|
68
|
+ public function sendLoginSms()
|
|
|
|
69
|
+ {
|
|
|
|
70
|
+ $this->request->validate([
|
|
|
|
71
|
+ 'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
|
|
|
|
72
|
+ ],[
|
|
|
|
73
|
+ 'mobile.required' => '手机号码不能为空',
|
|
|
|
74
|
+ 'mobile.regex' => '请输入正确的手机号码',
|
|
|
|
75
|
+ ]);
|
|
|
|
76
|
+ $mobile = $this->param['mobile'];
|
|
|
|
77
|
+ $manager = Manage::where(['mobile' => $mobile])->first();
|
|
|
|
78
|
+ if (empty($manager)) {
|
|
|
|
79
|
+ $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
|
|
|
|
80
|
+ }
|
|
|
|
81
|
+ $last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_MANAGER_LOGIN);
|
|
|
|
82
|
+ if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
|
|
|
|
83
|
+ $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
|
|
|
|
84
|
+ }
|
|
|
|
85
|
+ $template = config('aliyunsms.login_sms_temp');
|
|
|
|
86
|
+ $code['code'] = rand(100000,999999);
|
|
|
|
87
|
+ $ali_sms = new AliSms();
|
|
|
|
88
|
+ $send = $ali_sms->sendSms(strval($mobile), $template, $code);
|
|
|
|
89
|
+ if (empty($send->Code) && $send->Code != 'OK') {
|
|
|
|
90
|
+ $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
|
|
|
|
91
|
+ }
|
|
|
|
92
|
+ SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
|
|
|
|
93
|
+ $this->response('success');
|
|
|
|
94
|
+ }
|
|
58
|
} |
95
|
} |