|
...
|
...
|
@@ -31,12 +31,12 @@ class ComController extends BaseController |
|
|
|
*/
|
|
|
|
public function login(){
|
|
|
|
$this->request->validate([
|
|
|
|
'mobile'=>['required'],
|
|
|
|
'mobile'=>['required', 'regex:/^1[3-9]\d{9}$/'],
|
|
|
|
'password'=>['required'],
|
|
|
|
],[
|
|
|
|
'mobile.required'=>'电话号码必须填写',
|
|
|
|
'password.required'=>'内容必须填写',
|
|
|
|
'mobile.max' => 'mobile不大于12字符.',
|
|
|
|
'mobile.regex' => '请输入正确的手机号码',
|
|
|
|
]);
|
|
|
|
$userModel = new UserModel();
|
|
|
|
$res = $userModel->login($this->param);
|
|
...
|
...
|
@@ -122,62 +122,6 @@ class ComController extends BaseController |
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name : (测试定时任务)检测用户是否无操作记录
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/12 14:55
|
|
|
|
*/
|
|
|
|
protected function ceShi(){
|
|
|
|
$this->error = 0;
|
|
|
|
//获取所有ayr_share用户
|
|
|
|
$ayr_share_model = new AyrShareModel();
|
|
|
|
$ayr_share_list = $ayr_share_model->list($this->map);
|
|
|
|
if(!empty($ayr_share_list)){
|
|
|
|
foreach ($ayr_share_list as $k => $v){
|
|
|
|
//查询当前用户是否有未推送的博文
|
|
|
|
$ayr_release = new AyrReleaseModel();
|
|
|
|
$release_info = $ayr_release->read(['schedule_date'=>['>',date('Y-m-d H:i:s',time())],'share_id'=>$v['id']]);
|
|
|
|
//有推文时,直接跳出循环
|
|
|
|
if($release_info !== false){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//查看用户是否在一周内有发送博客
|
|
|
|
$start_at = Carbon::now()->modify('-7 days')->toDateString();
|
|
|
|
$end_at = Carbon::now()->toDateString();
|
|
|
|
$release_info = $ayr_release->read(['created_at'=>['between',[$start_at,$end_at]]]);
|
|
|
|
//有发送博文,则跳出循环
|
|
|
|
if($release_info == false){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//删除用户第三方配置
|
|
|
|
$ayr_share_helper = new AyrShareHelper();
|
|
|
|
$data_profiles = [
|
|
|
|
'title'=>$v['title'],
|
|
|
|
'profileKey'=>$v['profile_key']
|
|
|
|
];
|
|
|
|
$res = $ayr_share_helper->deleted_profiles($data_profiles);
|
|
|
|
if($res['status'] == 'fail'){
|
|
|
|
$this->error++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//更新数据库
|
|
|
|
$data = [
|
|
|
|
'title'=>null,
|
|
|
|
'bind_plat_from'=>null,
|
|
|
|
'profile_key'=>null,
|
|
|
|
'ref_id'=>null,
|
|
|
|
];
|
|
|
|
$res = $ayr_share_model->edit($data,['id'=>$v['id']]);
|
|
|
|
if($res == false){
|
|
|
|
$this->error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 发送登录短信
|
|
|
|
* @param Request $request
|
|
...
|
...
|
@@ -191,25 +135,24 @@ class ComController extends BaseController |
|
|
|
'mobile.required' => '手机号码不能为空',
|
|
|
|
'mobile.regex' => '请输入正确的手机号码',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$mobile = $request->input('mobile');
|
|
|
|
$user = User::where(['mobile' => $mobile])->first();
|
|
|
|
if (empty($user))
|
|
|
|
if (empty($user)) {
|
|
|
|
return $this->response('请输入正确的手机号码!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
}
|
|
|
|
$last_sms = SmsLog::getLastLog($mobile, SmsLog::TYPE_LOGIN);
|
|
|
|
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60)
|
|
|
|
if ($last_sms && $last_sms->use = SmsLog::USE_USABLE && time() - strtotime($last_sms->created_at) < 60) {
|
|
|
|
return $this->response('请不要重复发送短信!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
}
|
|
|
|
$template = config('alisms.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')
|
|
|
|
if (empty($send->Code) && $send->Code != 'OK') {
|
|
|
|
return $this->response('发送失败, 请稍后重试!', Code::USER_LOGIN_ERROE);
|
|
|
|
|
|
|
|
SmsLog::createLog($mobile, $code['code'], SmsLog::TYPE_LOGIN);
|
|
|
|
return $this->response('success', Code::SUCCESS);
|
|
|
|
}
|
|
|
|
SmsLog::createLog($mobile, $code['code']);
|
|
|
|
return $this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|