LoginController.php
4.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
namespace App\Http\Controllers\Aside;
use App\Enums\Common\Code;
use App\Http\Logic\Aside\LoginLogic;
use App\Models\Domain\DomainInfo;
use App\Models\Manage\Manage;
use App\Models\Project\Project;
use App\Models\Sms\SmsLog;
use App\Rules\Mobile;
use Illuminate\Http\Request;
use Mrgoon\AliSms\AliSms;
/**
* @group 登录
*
* @package App\Http\Controllers\Aside
* @author zbj
* @date 2023/4/19
*/
class LoginController extends BaseController
{
/**
* @name 登录
* @description 读取联系人列表
* @type GET/POST
* @param {string} mobile 手机号
* @param {string} [password] 密码
*/
public function login(Request $request, LoginLogic $logic)
{
$request->validate([
'mobile' => ['required', new Mobile()],
'password' => 'required',
], [
'mobile.required' => '请输入手机号',
'password.required' => '请输入密码',
]);
$data = $logic->login();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :退出登录
* @name :logout
* @author :lyh
* @method :post
* @time :2023/9/7 16:29
*/
public function logout(LoginLogic $logic)
{
$logic->logout();
$this->response('success');
}
/**
* @remark :获取B端访问地址
* @name :accessAddress
* @author :lyh
* @method :post
* @time :2023/8/7 9:07
*/
public function getAccessAddress(LoginLogic $logic){
$data = $logic->accessAddress($this->manage['id']);
return $this->response('success',Code::SUCCESS,$data);
}
/**
* 发送登录短信
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function sendLoginSms()
{
$this->request->validate([
'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
],[
'mobile.required' => '手机号码不能为空',
'mobile.regex' => '请输入正确的手机号码',
]);
$mobile = $this->param['mobile'];
$manager = Manage::where(['mobile' => $mobile])->first();
if (empty($manager)) {
$this->response('请输入正确的手机号码!', Code::SYSTEM_ERROR);
}
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_MANAGER_LOGIN);
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
$this->response('请不要重复发送短信!', Code::SYSTEM_ERROR);
}
$template = config('aliyunsms.login_sms_temp');
$code['code'] = rand(100000,999999);
$ali_sms = new AliSms();
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
if (empty($send->Code) && $send->Code != 'OK') {
$this->response('发送失败, 请稍后重试!', Code::SYSTEM_ERROR);
}
SmsLog::createLog($mobile, $code['code'],SmsLog::TYPE_MANAGER_LOGIN);
$this->response('success');
}
public function ceshi(){
$projectModel = new Project();
$info = $projectModel->with('payment')->with('deploy_build')
->with('deploy_optimize')->where(['id'=>1])->first()->toArray();
$url = 'https://form.globalso.com/api/globalsov6';
$data = [
'id' => $info['from_order_id'],
'company_name'=>$info['company'],
'token'=>md5($info['from_order_id'].'qqs'.date('Y-m-d')),
];
if(!empty($info['mobile'])){
$data['mobile'] = $info['mobile'];
}
if(!empty($info['deploy_optimize']['domain'])){
$domainModel = new DomainInfo();
$data['main_url'] = $domainModel->getDomain($info['deploy_optimize']['domain']);
}
if($info['deploy_build']['test_domain']){
$data['test_url'] = $info['deploy_build']['test_domain'];
}
$header = array(
"charset=utf-8"
);
return http_post($url,$data,$header);
}
}