Commit 89bc9a1f authored by 蔡闯's avatar 蔡闯

接口调试

parent 6a37de71
......@@ -144,19 +144,17 @@ class Index extends Base
$uid = $this->uid;
$userType = $this->userType;
$where[] = ['hub.uid','=',$uid];
$page = Request::param('page',1);
$data = Db::name('house_user_bind')->alias('hub')->where($where)
->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')
->leftJoin('house_village hvi','hvi.village_id = hub.village_id')
->field('hub.house_user_bind_id,hvi.village_name,hv.vacancy_code,hv.layout_id,hub.pass_time,hub.type,hub.status,hub.vacancy_id,hvi.village_logo,hvi.village_id')
->where(['hub.status'=>1])
->page($page,config('app.limit'))
->select()->toArray();
foreach ($data as $k=>$v) {
$rest = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']);
$data[$k]['vacancy_address'] = $rest['vacancy_address'];
//获取用户车辆信息
$cars = Db::name('car')->where(['uid'=>$this->uid,'village_id'=>$v['village_id']])->field('car_id,license_plate')->select()->toArray();
$cars = Db::name('car')->where(['uid'=>$this->uid,'village_id'=>$v['village_id']])->field('car_id,license_plate,brand')->select()->toArray();
$data[$k]['cars'] = $cars;
$car_total = count($cars);
if($car_total ==1) {
......@@ -165,10 +163,8 @@ class Index extends Base
$data[$k]['car_total'] = $car_total;
$data[$k]['type_zh'] = $userType[$v['type']];
}
$total = Db::name('house_user_bind')->alias('hub')->where($where)->count();
$res['total'] = $total;
$res['data'] = Common::changeField($data,'pass_time');
return $this->returnJson($res);
$data = Common::changeField($data,'pass_time');
return $this->returnJson($data);
}
//查看车辆详情
......@@ -237,7 +233,6 @@ class Index extends Base
} else {
return $this->returnJson([],'操作失败!',400);
}
}
//删除车辆
......@@ -265,20 +260,20 @@ class Index extends Base
->find();
$res = Common::getVacancyAddress($data['vacancy_code'],$data['layout_id']);
$data['vacancy_address'] = $res['vacancy_address'];
//获取用户车辆信息
$cars = Db::name('car')->where(['uid'=>$this->uid,'village_id'=>$data['village_id']])->select()->toArray();
$data['car'] = $cars;
if($data['type'] ==0 ){
//查询家属
$family = $this->getFamily($data['vacancy_id']);
//查询租客
$tenant = $this->getTenant($data['vacancy_id']);
$data['user'] = array_merge($family,$tenant);
} elseif($data['type'] ==2){
$data['user'] = $this->getTenant($data['vacancy_id']);
} else {
$data['user'] = [];
}
return $this->returnJson($data);
}
......@@ -286,37 +281,36 @@ class Index extends Base
//根据房间id,查询租客
public function getTenant($vacancy_id) {
//查询租客
$tenant = Db::name('house_user_bind')->alias('hub')->leftJoin('user','user.uid = hub.uid')
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>2])
->where('hub.status','<>',3)
->where('hub.uid','<>',null)
->field('hub.name,hub.phone,user.avatar,user.uid,hub.village_id,hub.status,hub.type')->select()->toArray();
$where['hub.vacancy_id'] = $vacancy_id;
$where['hub.type'] = 2;
$tenant = $this->getUser($where);
foreach ($tenant as $k =>$v) {
$car = Db::name('car')->where(['uid'=>$v['uid'],'village_id'=>$v['village_id']])->select()->toArray();
$tenant[$k]['cars'] = $car;
$tenant[$k]['car_total'] = count($car);
$family[$k]['type_zh'] = "租客";
$tenant[$k]['type_zh'] = "租客";
}
return $tenant;
}
//根据房间id,查询家属
public function getFamily($vacancy_id) {
//查询租客
$family = Db::name('house_user_bind')->alias('hub')->leftJoin('user','user.uid = hub.uid')
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>1])
->where('hub.status','<>',3)
->where('hub.uid','<>',null)
->field('hub.house_user_bind_id,hub.village_id,hub.name,hub.phone,user.avatar,hub.uid,hub.status,hub.type')->select()->toArray();
$where['hub.vacancy_id'] = $vacancy_id;
$where['hub.type'] = 1;
$family = $this->getUser($where);
foreach ($family as $k =>$v) {
$car = Db::name('car')->where(['uid'=>$v['uid'],'village_id'=>$v['village_id']])->select()->toArray();
$family[$k]['cars'] = $car;
$family[$k]['car_total'] = count($car);
$family[$k]['type_zh'] = "家属";
$family[$k]['type_zh'] = "家属";
}
return $family;
}
//获取绑定用户信息
public function getUser($where){
$user = Db::name('house_user_bind')->alias('hub')->leftJoin('user','user.uid = hub.uid')
->where($where)
->whereNotIn('hub.status',[0,3])
->where('hub.uid','<>',null)
->field('hub.house_user_bind_id,hub.name,hub.phone,user.avatar,user.uid,hub.village_id,hub.status,hub.type')->select()->toArray();
return $user;
}
//业主审核租客和家属,或家属租客申请解绑
public function changeStatus() {
......@@ -335,6 +329,4 @@ class Index extends Base
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment