正在显示
1 个修改的文件
包含
5 行增加
和
2 行删除
@@ -498,7 +498,10 @@ class HouseAdmin extends Api | @@ -498,7 +498,10 @@ class HouseAdmin extends Api | ||
498 | } | 498 | } |
499 | 499 | ||
500 | Db::startTrans(); | 500 | Db::startTrans(); |
501 | - $result = (new HouseAdminModel)->allowField(true)->save(array_merge([ | 501 | + if(!$houseAdminModel = HouseAdminModel::get(['user_id'=>$admin_user['id'],'house_id'=>0])){ |
502 | + $houseAdminModel = new HouseAdminModel; | ||
503 | + } | ||
504 | + $result = $houseAdminModel->allowField(true)->save(array_merge([ | ||
502 | 'user_id' => $admin_user['id'], | 505 | 'user_id' => $admin_user['id'], |
503 | 'avatar' => $admin_user['avatar'], | 506 | 'avatar' => $admin_user['avatar'], |
504 | 'is_direct' => 2 | 507 | 'is_direct' => 2 |
@@ -511,7 +514,7 @@ class HouseAdmin extends Api | @@ -511,7 +514,7 @@ class HouseAdmin extends Api | ||
511 | Db::rollback(); | 514 | Db::rollback(); |
512 | $this->error('添加管理员失败'); | 515 | $this->error('添加管理员失败'); |
513 | } | 516 | } |
514 | - | 517 | + Db::commit(); |
515 | $this->success('success'); | 518 | $this->success('success'); |
516 | } | 519 | } |
517 | 520 |
-
请 注册 或 登录 后发表评论