|
...
|
...
|
@@ -47,22 +47,14 @@ class UserLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function projectUserSave()
|
|
|
|
{
|
|
|
|
//验证手机号是否存在
|
|
|
|
$this->verifyMobile($this->param);
|
|
|
|
//验证一个项目是否只有一个超级管理员
|
|
|
|
$this->verifyRole($this->param);
|
|
|
|
if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
|
|
$info = $this->model->read(['mobile' => $this->param['mobile'], 'id' => ['!=', $this->param['id']]]);
|
|
|
|
if ($info !== false) {
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
$this->param = $this->editPassword($this->param);
|
|
|
|
$rs = $this->model->edit($this->param, ['id' => $this->param['id']]);
|
|
|
|
} else {
|
|
|
|
$info = $this->model->read(['mobile'=>$this->param['mobile']]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
$info = $this->model->read(['project_id'=>$this->param['project_id'],'role_id'=>0]);
|
|
|
|
if($info !== false){
|
|
|
|
$this->fail('当前项目已存在超级管理员,请选择其他项目');
|
|
|
|
}
|
|
|
|
$this->param['password'] = base64_encode(md5($this->param['password']));
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
}
|
|
...
|
...
|
@@ -73,6 +65,63 @@ class UserLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :验证手机号是否可用
|
|
|
|
* @name :verifyMobile
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/29 9:14
|
|
|
|
*/
|
|
|
|
public function verifyMobile($param){
|
|
|
|
if(isset($param['id']) && !empty($param['id'])){
|
|
|
|
$condition = [
|
|
|
|
'mobile' => $param['mobile'],
|
|
|
|
'project_id'=>$param['project_id'],
|
|
|
|
'id' => ['!=', $param['id']]
|
|
|
|
];
|
|
|
|
}else{
|
|
|
|
$condition = [
|
|
|
|
'mobile' => $param['mobile'],
|
|
|
|
'project_id'=>$param['project_id'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$info = $this->model->read($condition);
|
|
|
|
if ($info !== false) {
|
|
|
|
$this->fail('当前手机号码已存在');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :验证一个项目超级管理员只允许存在一个
|
|
|
|
* @name :verifyRole
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/29 9:22
|
|
|
|
*/
|
|
|
|
public function verifyRole($param){
|
|
|
|
if($param['role_id'] == $this->model::ROLE_MANAGER){
|
|
|
|
if(isset($param['id']) && !empty($param['id'])){
|
|
|
|
$condition = [
|
|
|
|
'mobile' => $param['mobile'],
|
|
|
|
'project_id'=>$param['project_id'],
|
|
|
|
'id' => ['!=', $param['id']],
|
|
|
|
'role_id'=>$this->model::ROLE_MANAGER
|
|
|
|
];
|
|
|
|
}else{
|
|
|
|
$condition = [
|
|
|
|
'mobile' => $param['mobile'],
|
|
|
|
'project_id'=>$param['project_id'],
|
|
|
|
'role_id'=>$this->model::ROLE_MANAGER,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
$info = $this->model->read($condition);
|
|
|
|
if ($info !== false) {
|
|
|
|
$this->fail('当前项目已存在超级管理员');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :编辑会员
|
|
|
|
* @return void
|
|
|
|
* @author :liyuhang
|
...
|
...
|
|