注销相关逻辑

This commit is contained in:
Jerry Yan 2020-09-14 20:49:23 +08:00
parent e1630850b1
commit 539afccbc7
2 changed files with 39 additions and 4 deletions

View File

@ -863,6 +863,31 @@ public function forgetPasss(){
return WSTReturn("成功", 1, $data);
}
}
public function unregister_get_sms_code() {
$m = new MUsers();
$data = $m->getById($this->getUserId());
$userPhone = '15270565305';
// $userPhone = $data['userPhone'];
$phoneVerify = rand(1000,9999);
$tpl = WSTMsgTemplates('PHONE_FOTGET');
// $tpl = WSTMsgTemplates('PHONE_UNREGISTER');
$rv = ['status'=>-1,'msg'=>'短信发送失败'];
if( $tpl['tplContent']!='' && $tpl['status']=='1'){
$params = ['tpl'=>$tpl,'params'=>['code'=>$phoneVerify]];
$m = new LogSms();
try{
$rv = $m->sendSMS(0,$userPhone,$params,'unregister_get_sms_code',$phoneVerify);
} catch (\Exception $e) {
$rv['extra'] = $e->getMessage();
exit(json_encode($rv));
}
}
session('unreg.time', time());
session('unreg.code', $phoneVerify);
exit(json_encode($rv));
}
/**
* 注销
*/
@ -872,10 +897,20 @@ public function forgetPasss(){
$user = $m->getById($userId);
if (empty($user)) exit(jsonReturn('系统异常',0,[]));
$opUser = input('post.op_user');
$opContent = input('post.op_content');
// TODO: 记录操作人员名称
// TODO: 验证规则
$opContent = input('post.op_content', '');
$opPic = input('post.op_pic', '');
if (empty($opUser)) {
exit(jsonReturn('操作用户不能为空!',-1));
}
Db::startTrans();
Db::name('user_unregister')->insert([
'historyData'=>json_encode($user),
'historyUserName'=>$user['loginName'],
'op_user'=>$opUser,
'op_content'=>$opContent,
'op_pic'=>$opPic,
]);
Db::name('user_lock')->insert([
'lockTime'=>0,
'lockReason'=>'账号已注销,操作人:'.$opUser.',注销申请内容:'.$opContent,

View File

@ -337,7 +337,7 @@ class Users extends Base{
$fp = fopen("reg.lock", "r");
if(flock($fp,LOCK_EX | LOCK_NB)) {//if(flock($fp,LOCK_EX))阻塞(等待)模式
//检测账号是否存在
$crs = WSTCheckLoginKey($loginName);
$crs = ($loginName);
if($crs['status']!=1){
flock($fp,LOCK_UN);
fclose($fp);