|
@@ -230,22 +230,21 @@ class User extends BaseController{
|
|
|
$data['company_type']=$role['company_type']??'';
|
|
|
return app_show(0,"获取成功",$data);
|
|
|
}
|
|
|
- /**
|
|
|
+ /**@param id int 账户id
|
|
|
+ /**@param status int 状态 0/1
|
|
|
* @return \think\response\Json|void
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
public function setStatus(){
|
|
|
- $post =$this->request->only(["id"=>"","status"=>"","relaComNo"=>"","companyNo"=>"","token"=>""],"post");
|
|
|
+ $post =$this->request->only(["id"=>"","status"=>"","token"=>""],"post");
|
|
|
$valide =Validate::rule([
|
|
|
'id|账户ID' => 'require|number|gt:0',
|
|
|
'status|状态' => 'require|number|in:0,1',
|
|
|
- 'relaComNo|业务公司' => 'max:255',
|
|
|
- 'companyNo|业务公司' => 'max:255',
|
|
|
]);
|
|
|
if($valide->check($post)==false) return error_show(1004,$valide->getError());
|
|
|
$message = $post['status']==1?"启用":"禁用";
|
|
|
+ if($post['id']==$this->uid){
|
|
|
+ return error_show(1004,'不可禁用当前账户');
|
|
|
+ }
|
|
|
$condition=["id"=>$post['id'],"status"=>$post['status'],"token"=>$post['token']];
|
|
|
$ex=setStatus($condition);
|
|
|
if(!isset($ex['code'])||$ex['code']!=0){
|
|
@@ -254,6 +253,40 @@ class User extends BaseController{
|
|
|
return app_show(0,"{$message}成功");
|
|
|
}
|
|
|
|
|
|
+ public function setCompanyStatus(){
|
|
|
+ $post =$this->request->only(["id"=>"","status"=>"","relaComNo"=>"","companyNo"=>"","token"=>""],"post");
|
|
|
+ $valide =Validate::rule([
|
|
|
+ 'id|账户ID' => 'require|number|gt:0',
|
|
|
+ 'status|状态' => 'require|number|in:0,1',
|
|
|
+ 'relaComNo|业务公司' => 'max:255',
|
|
|
+ 'companyNo|公司编号' => 'require|max:255',
|
|
|
+ ]);
|
|
|
+ if($valide->check($post)==false) return error_show(1004,$valide->getError());
|
|
|
+ $message = $post['status']==1?"启用":"禁用";
|
|
|
+ if($post['id']==$this->uid &&$post['companyNo']==$post['relaComNo']){
|
|
|
+ return error_show(1004,'不可禁用当前账户');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $userinfo =Db::name("user_role")->where(["uid"=>$post['id'],"companyNo"=>$post['companyNo'],"is_del"=>0])->findOrEmpty();
|
|
|
+ if(!empty($userinfo)){
|
|
|
+ if($userinfo['is_main']==1) throw new Exception("默认账户不可禁用!");
|
|
|
+ $userinfo['status']=$post['status'];
|
|
|
+ $userinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ $sa=Db::name("user_role")->save($userinfo);
|
|
|
+ if($sa==false) throw new Exception("状态更新失败!");
|
|
|
+ }
|
|
|
+ $condition=["account_id"=>$post['id'],"companyCode"=>$post['companyNo'],"status"=>$post['status'],"token"=>$post['token']];
|
|
|
+ $effect=setCompanyStatus($condition);
|
|
|
+ if(!isset($effect['code'])||$effect['code']!=0)throw new Exception($effect['message']);
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"{$message}成功");
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取所有用户的信息
|
|
|
public function userAll(){
|
|
|
$post=$this->request->only(['relaComNo'=>"","companyNo"=>"","nickname"=>"","roleid"=>"","status"=>""],"post","trim");
|