...
|
...
|
@@ -63,23 +63,23 @@ class HouseAdmin extends Api |
|
|
$info = HouseAdminModel::get(['user_id'=>$user_id,'house_id'=>$house_id],['house']);
|
|
|
// empty($info) && $this->error('您不是该小区的管理员');
|
|
|
if(empty($info)) {
|
|
|
// $info = HouseAdminModel::with(['house'])
|
|
|
// ->where(['user_id'=>$user_id])
|
|
|
// ->order(['is_direct'=>'asc','createtime'=>'asc'])
|
|
|
// ->field('id,house_id,is_direct,nickname,avatar')
|
|
|
// ->find();
|
|
|
$house = House::get($house_id);
|
|
|
$info = HouseAdminModel::get($house['admin_user_id']);
|
|
|
if($info){
|
|
|
$info['house_id'] = $house_id;
|
|
|
$info['house'] = $house;
|
|
|
}else{
|
|
|
$info = HouseAdminModel::with(['house'])
|
|
|
->where(['user_id'=>$user_id])
|
|
|
->order(['is_direct'=>'asc','createtime'=>'asc'])
|
|
|
->field('id,house_id,is_direct,nickname,avatar')
|
|
|
->find();
|
|
|
}
|
|
|
$info = HouseAdminModel::with(['house'])
|
|
|
->where(['user_id'=>$user_id])
|
|
|
->order(['is_direct'=>'asc','createtime'=>'asc'])
|
|
|
->field('id,house_id,is_direct,nickname,avatar')
|
|
|
->find();
|
|
|
// $house = House::get($house_id);
|
|
|
// $info = HouseAdminModel::get($house['admin_user_id']);
|
|
|
// if($info){
|
|
|
// $info['house_id'] = $house_id;
|
|
|
// $info['house'] = $house;
|
|
|
// }else{
|
|
|
// $info = HouseAdminModel::with(['house'])
|
|
|
// ->where(['user_id'=>$user_id])
|
|
|
// ->order(['is_direct'=>'asc','createtime'=>'asc'])
|
|
|
// ->field('id,house_id,is_direct,nickname,avatar')
|
|
|
// ->find();
|
|
|
// }
|
|
|
}
|
|
|
$info->visible(['id','house_id','is_direct','nickname','avatar','house'])->toArray();
|
|
|
}else{
|
...
|
...
|
@@ -119,36 +119,36 @@ class HouseAdmin extends Api |
|
|
$user = $this->auth->getUser();
|
|
|
$keyword = $this->request->param('keyword');
|
|
|
$where = [];
|
|
|
// if(!empty($keyword)){
|
|
|
// $where['h.name'] = ['like',"%$keyword%"];
|
|
|
// }
|
|
|
// // 查出该管理员已绑定的小区
|
|
|
// $list = HouseAdminModel::alias('ha')
|
|
|
// ->join('house h','h.id = ha.house_id')
|
|
|
// ->where('ha.user_id',$user['id'])
|
|
|
// ->where($where)
|
|
|
// ->field("h.id,h.name")
|
|
|
// ->order('ha.is_direct')
|
|
|
// ->select();
|
|
|
// 社区管理员管理多个小区
|
|
|
$house_ids = [];
|
|
|
$house_list = HouseAdminModel::where('user_id',$user['id'])->field('id,house_id')->select();
|
|
|
if(count($house_list) > 0){
|
|
|
$house_ids = array_merge($house_ids,array_column($house_list,'house_id'));
|
|
|
$house_admin_ids = array_column($house_list,'id');
|
|
|
if($house_admin_ids){
|
|
|
$house_ids = array_merge($house_ids,House::where('admin_user_id','in',$house_admin_ids)->column('id'));
|
|
|
}
|
|
|
}
|
|
|
$house_ids = array_filter(array_unique($house_ids));
|
|
|
if ($house_ids) {
|
|
|
$where['id'] = ['in',$house_ids];
|
|
|
}
|
|
|
// 关键字
|
|
|
if(!empty($keyword)){
|
|
|
$where['name'] = ['like',"%$keyword%"];
|
|
|
$where['h.name'] = ['like',"%$keyword%"];
|
|
|
}
|
|
|
$list = House::where($where)->field('id,name')->select();
|
|
|
// 查出该管理员已绑定的小区
|
|
|
$list = HouseAdminModel::alias('ha')
|
|
|
->join('house h','h.id = ha.house_id')
|
|
|
->where('ha.user_id',$user['id'])
|
|
|
->where($where)
|
|
|
->field("h.id,h.name")
|
|
|
->order('ha.is_direct')
|
|
|
->select();
|
|
|
// // 社区管理员管理多个小区
|
|
|
// $house_ids = [];
|
|
|
// $house_list = HouseAdminModel::where('user_id',$user['id'])->field('id,house_id')->select();
|
|
|
// if(count($house_list) > 0){
|
|
|
// $house_ids = array_merge($house_ids,array_column($house_list,'house_id'));
|
|
|
// $house_admin_ids = array_column($house_list,'id');
|
|
|
// if($house_admin_ids){
|
|
|
// $house_ids = array_merge($house_ids,House::where('admin_user_id','in',$house_admin_ids)->column('id'));
|
|
|
// }
|
|
|
// }
|
|
|
// $house_ids = array_filter(array_unique($house_ids));
|
|
|
// if ($house_ids) {
|
|
|
// $where['id'] = ['in',$house_ids];
|
|
|
// }
|
|
|
// // 关键字
|
|
|
// if(!empty($keyword)){
|
|
|
// $where['name'] = ['like',"%$keyword%"];
|
|
|
// }
|
|
|
// $list = House::where($where)->field('id,name')->select();
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -178,10 +178,10 @@ class HouseAdmin extends Api |
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
$info = HouseAdminModel::where(['user_id'=>$this->auth->id,'house_id'=>$house_id])->field('id,nickname,avatar,mobile')
|
|
|
->find();
|
|
|
if(!$info){
|
|
|
$admin_user_id = House::where('id',$house_id)->value('admin_user_id');
|
|
|
$info = HouseAdminModel::where(['id'=>$admin_user_id,'user_id'=>$this->auth->id])->field('id,nickname,avatar,mobile')->find();
|
|
|
}
|
|
|
// if(!$info){
|
|
|
// $admin_user_id = House::where('id',$house_id)->value('admin_user_id');
|
|
|
// $info = HouseAdminModel::where(['id'=>$admin_user_id,'user_id'=>$this->auth->id])->field('id,nickname,avatar,mobile')->find();
|
|
|
// }
|
|
|
$info['avatar'] = cdnurl($info['avatar'],true);
|
|
|
$this->success('success',$info);
|
|
|
}
|
...
|
...
|
@@ -200,10 +200,10 @@ class HouseAdmin extends Api |
|
|
|
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$house_id]);
|
|
|
if(!$admin){
|
|
|
$house = House::get($house_id);
|
|
|
$admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
}
|
|
|
// if(!$admin){
|
|
|
// $house = House::get($house_id);
|
|
|
// $admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
// }
|
|
|
empty($admin) && $this->error('您不是该小区的管理员');
|
|
|
|
|
|
$admin->nickname = $nickname;
|
...
|
...
|
@@ -230,10 +230,10 @@ class HouseAdmin extends Api |
|
|
$this->error('手机号格式不正确');
|
|
|
}
|
|
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$house_id]);
|
|
|
if(!$admin){
|
|
|
$house = House::get($house_id);
|
|
|
$admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
}
|
|
|
// if(!$admin){
|
|
|
// $house = House::get($house_id);
|
|
|
// $admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
// }
|
|
|
empty($admin) && $this->error('您不是该小区的管理员');
|
|
|
// 检查手机号是否存在
|
|
|
$mobile_exists = HouseAdminModel::where('mobile',$mobile)
|
...
|
...
|
@@ -451,10 +451,10 @@ class HouseAdmin extends Api |
|
|
empty($post['title']) && $this->error('请填写公告标题');
|
|
|
empty($post['content']) && $this->error('请填写公告内容');
|
|
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$post['house_id']]);
|
|
|
if(!$admin){
|
|
|
$house = House::get($post['house_id']);
|
|
|
$admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
}
|
|
|
// if(!$admin){
|
|
|
// $house = House::get($post['house_id']);
|
|
|
// $admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
// }
|
|
|
empty($admin) && $this->error('您不是该小区的管理员');
|
|
|
$count = HouseBoard::whereTime('createtime', 'week')
|
|
|
->where('house_id',$post['house_id'])
|
...
|
...
|
@@ -523,10 +523,10 @@ class HouseAdmin extends Api |
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$house_id]);
|
|
|
if(!$admin){
|
|
|
$house = House::get($house_id);
|
|
|
$admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
}
|
|
|
// if(!$admin){
|
|
|
// $house = House::get($house_id);
|
|
|
// $admin = HouseAdminModel::get(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id]);
|
|
|
// }
|
|
|
empty($admin) && $this->error('您不是该小区的管理员');
|
|
|
$info = HouseBoard::get(['house_id'=>$house_id,'id'=>$house_board_id]);
|
|
|
empty($info) && $this->error('公告信息不存在');
|
...
|
...
|
@@ -873,11 +873,11 @@ class HouseAdmin extends Api |
|
|
$user = $user_model->field('id,nickname,avatar')->where('id',$v['user_id'])->find();
|
|
|
}else{
|
|
|
$user = HouseAdminModel::where(['user_id'=>$this->auth->id,'house_id'=>$msg['object_id']])->field('id,nickname,avatar')->find();
|
|
|
// 多管理员
|
|
|
if(!$user){
|
|
|
$house = House::get($msg['object_id']);
|
|
|
$user = HouseAdminModel::where(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id])->field('id,nickname,avatar')->find();
|
|
|
}
|
|
|
// // 多管理员
|
|
|
// if(!$user){
|
|
|
// $house = House::get($msg['object_id']);
|
|
|
// $user = HouseAdminModel::where(['id'=>$house['admin_user_id'],'user_id'=>$this->auth->id])->field('id,nickname,avatar')->find();
|
|
|
// }
|
|
|
}
|
|
|
$user['avatar'] = cdnurl($user['avatar'],true);
|
|
|
$v['user'] = $user;
|
...
|
...
|
|