|
@@ -31,12 +31,12 @@ class ComController extends BaseController |
|
@@ -31,12 +31,12 @@ class ComController extends BaseController |
|
31
|
*/
|
31
|
*/
|
|
32
|
public function login(){
|
32
|
public function login(){
|
|
33
|
$this->request->validate([
|
33
|
$this->request->validate([
|
|
34
|
- 'mobile'=>['required'],
|
34
|
+ 'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
|
|
35
|
'password'=>['required'],
|
35
|
'password'=>['required'],
|
|
36
|
],[
|
36
|
],[
|
|
37
|
'mobile.required'=>'电话号码必须填写',
|
37
|
'mobile.required'=>'电话号码必须填写',
|
|
38
|
'password.required'=>'内容必须填写',
|
38
|
'password.required'=>'内容必须填写',
|
|
39
|
- 'mobile.max' => 'mobile不大于12字符.',
|
39
|
+ 'mobile.regex' => '请输入正确的手机号码',
|
|
40
|
]);
|
40
|
]);
|
|
41
|
$userModel = new UserModel();
|
41
|
$userModel = new UserModel();
|
|
42
|
$res = $userModel->login($this->param);
|
42
|
$res = $userModel->login($this->param);
|
|
@@ -122,62 +122,6 @@ class ComController extends BaseController |
|
@@ -122,62 +122,6 @@ class ComController extends BaseController |
|
122
|
$this->response('success');
|
122
|
$this->response('success');
|
|
123
|
}
|
123
|
}
|
|
124
|
|
124
|
|
|
125
|
-
|
|
|
|
126
|
- /**
|
|
|
|
127
|
- * @name : (测试定时任务)检测用户是否无操作记录
|
|
|
|
128
|
- * @author :lyh
|
|
|
|
129
|
- * @method :post
|
|
|
|
130
|
- * @time :2023/5/12 14:55
|
|
|
|
131
|
- */
|
|
|
|
132
|
- protected function ceShi(){
|
|
|
|
133
|
- $this->error = 0;
|
|
|
|
134
|
- //获取所有ayr_share用户
|
|
|
|
135
|
- $ayr_share_model = new AyrShareModel();
|
|
|
|
136
|
- $ayr_share_list = $ayr_share_model->list($this->map);
|
|
|
|
137
|
- if(!empty($ayr_share_list)){
|
|
|
|
138
|
- foreach ($ayr_share_list as $k => $v){
|
|
|
|
139
|
- //查询当前用户是否有未推送的博文
|
|
|
|
140
|
- $ayr_release = new AyrReleaseModel();
|
|
|
|
141
|
- $release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
|
|
|
|
142
|
- //有推文时,直接跳出循环
|
|
|
|
143
|
- if($release_info !== false){
|
|
|
|
144
|
- continue;
|
|
|
|
145
|
- }
|
|
|
|
146
|
- //查看用户是否在一周内有发送博客
|
|
|
|
147
|
- $start_at = Carbon::now()->modify('-7 days')->toDateString();
|
|
|
|
148
|
- $end_at = Carbon::now()->toDateString();
|
|
|
|
149
|
- $release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]);
|
|
|
|
150
|
- //有发送博文,则跳出循环
|
|
|
|
151
|
- if($release_info == false){
|
|
|
|
152
|
- continue;
|
|
|
|
153
|
- }
|
|
|
|
154
|
- //删除用户第三方配置
|
|
|
|
155
|
- $ayr_share_helper = new AyrShareHelper();
|
|
|
|
156
|
- $data_profiles = [
|
|
|
|
157
|
- 'title'=>$v['title'],
|
|
|
|
158
|
- 'profileKey'=>$v['profile_key']
|
|
|
|
159
|
- ];
|
|
|
|
160
|
- $res = $ayr_share_helper->deleted_profiles($data_profiles);
|
|
|
|
161
|
- if($res['status'] == 'fail'){
|
|
|
|
162
|
- $this->error++;
|
|
|
|
163
|
- continue;
|
|
|
|
164
|
- }
|
|
|
|
165
|
- //更新数据库
|
|
|
|
166
|
- $data = [
|
|
|
|
167
|
- 'title'=>null,
|
|
|
|
168
|
- 'bind_plat_from'=>null,
|
|
|
|
169
|
- 'profile_key'=>null,
|
|
|
|
170
|
- 'ref_id'=>null,
|
|
|
|
171
|
- ];
|
|
|
|
172
|
- $res = $ayr_share_model->edit($data,['id'=>$v['id']]);
|
|
|
|
173
|
- if($res == false){
|
|
|
|
174
|
- $this->error++;
|
|
|
|
175
|
- }
|
|
|
|
176
|
- }
|
|
|
|
177
|
- }
|
|
|
|
178
|
- return $this->error;
|
|
|
|
179
|
- }
|
|
|
|
180
|
-
|
|
|
|
181
|
/**
|
125
|
/**
|
|
182
|
* 发送登录短信
|
126
|
* 发送登录短信
|
|
183
|
* @param Request $request
|
127
|
* @param Request $request
|
|
@@ -191,25 +135,24 @@ class ComController extends BaseController |
|
@@ -191,25 +135,24 @@ class ComController extends BaseController |
|
191
|
'mobile.required' => '手机号码不能为空',
|
135
|
'mobile.required' => '手机号码不能为空',
|
|
192
|
'mobile.regex' => '请输入正确的手机号码',
|
136
|
'mobile.regex' => '请输入正确的手机号码',
|
|
193
|
]);
|
137
|
]);
|
|
194
|
-
|
|
|
|
195
|
$mobile = $request->input('mobile');
|
138
|
$mobile = $request->input('mobile');
|
|
196
|
$user = User::where(['mobile' => $mobile])->first();
|
139
|
$user = User::where(['mobile' => $mobile])->first();
|
|
197
|
- if (empty($user))
|
140
|
+ if (empty($user)) {
|
|
198
|
return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
|
141
|
return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
|
|
199
|
-
|
142
|
+ }
|
|
200
|
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
|
143
|
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
|
|
201
|
- if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60)
|
144
|
+ if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
|
|
202
|
return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
|
145
|
return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
|
|
203
|
-
|
146
|
+ }
|
|
204
|
$template = config('alisms.login_sms_temp');
|
147
|
$template = config('alisms.login_sms_temp');
|
|
205
|
$code['code'] = rand(100000,999999);
|
148
|
$code['code'] = rand(100000,999999);
|
|
206
|
$ali_sms = new AliSms();
|
149
|
$ali_sms = new AliSms();
|
|
207
|
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
|
150
|
$send = $ali_sms->sendSms(strval($mobile), $template, $code);
|
|
208
|
- if (empty($send->Code) && $send->Code != 'OK')
|
151
|
+ if (empty($send->Code) && $send->Code != 'OK') {
|
|
209
|
return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
|
152
|
return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
|
|
210
|
-
|
|
|
|
211
|
- SmsLog::createLog($mobile, $code['code'], SmsLog::TYPE_LOGIN);
|
|
|
|
212
|
- return $this->response('success', Code::SUCCESS);
|
153
|
+ }
|
|
|
|
154
|
+ SmsLog::createLog($mobile, $code['code']);
|
|
|
|
155
|
+ return $this->response('success');
|
|
213
|
}
|
156
|
}
|
|
214
|
|
157
|
|
|
215
|
} |
158
|
} |