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

接口调试

parent 6a37de71
...@@ -144,19 +144,17 @@ class Index extends Base ...@@ -144,19 +144,17 @@ class Index extends Base
$uid = $this->uid; $uid = $this->uid;
$userType = $this->userType; $userType = $this->userType;
$where[] = ['hub.uid','=',$uid]; $where[] = ['hub.uid','=',$uid];
$page = Request::param('page',1);
$data = Db::name('house_user_bind')->alias('hub')->where($where) $data = Db::name('house_user_bind')->alias('hub')->where($where)
->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id') ->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')
->leftJoin('house_village hvi','hvi.village_id = hub.village_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') ->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]) ->where(['hub.status'=>1])
->page($page,config('app.limit'))
->select()->toArray(); ->select()->toArray();
foreach ($data as $k=>$v) { foreach ($data as $k=>$v) {
$rest = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']); $rest = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']);
$data[$k]['vacancy_address'] = $rest['vacancy_address']; $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; $data[$k]['cars'] = $cars;
$car_total = count($cars); $car_total = count($cars);
if($car_total ==1) { if($car_total ==1) {
...@@ -165,10 +163,8 @@ class Index extends Base ...@@ -165,10 +163,8 @@ class Index extends Base
$data[$k]['car_total'] = $car_total; $data[$k]['car_total'] = $car_total;
$data[$k]['type_zh'] = $userType[$v['type']]; $data[$k]['type_zh'] = $userType[$v['type']];
} }
$total = Db::name('house_user_bind')->alias('hub')->where($where)->count(); $data = Common::changeField($data,'pass_time');
$res['total'] = $total; return $this->returnJson($data);
$res['data'] = Common::changeField($data,'pass_time');
return $this->returnJson($res);
} }
//查看车辆详情 //查看车辆详情
...@@ -237,7 +233,6 @@ class Index extends Base ...@@ -237,7 +233,6 @@ class Index extends Base
} else { } else {
return $this->returnJson([],'操作失败!',400); return $this->returnJson([],'操作失败!',400);
} }
} }
//删除车辆 //删除车辆
...@@ -265,20 +260,20 @@ class Index extends Base ...@@ -265,20 +260,20 @@ class Index extends Base
->find(); ->find();
$res = Common::getVacancyAddress($data['vacancy_code'],$data['layout_id']); $res = Common::getVacancyAddress($data['vacancy_code'],$data['layout_id']);
$data['vacancy_address'] = $res['vacancy_address']; $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 ){ if($data['type'] ==0 ){
//查询家属 //查询家属
$family = $this->getFamily($data['vacancy_id']); $family = $this->getFamily($data['vacancy_id']);
//查询租客 //查询租客
$tenant = $this->getTenant($data['vacancy_id']); $tenant = $this->getTenant($data['vacancy_id']);
$data['user'] = array_merge($family,$tenant); $data['user'] = array_merge($family,$tenant);
} elseif($data['type'] ==2){ } elseif($data['type'] ==2){
$data['user'] = $this->getTenant($data['vacancy_id']); $data['user'] = $this->getTenant($data['vacancy_id']);
} else {
$data['user'] = [];
} }
return $this->returnJson($data); return $this->returnJson($data);
} }
...@@ -286,37 +281,36 @@ class Index extends Base ...@@ -286,37 +281,36 @@ class Index extends Base
//根据房间id,查询租客 //根据房间id,查询租客
public function getTenant($vacancy_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;
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>2]) $where['hub.type'] = 2;
->where('hub.status','<>',3) $tenant = $this->getUser($where);
->where('hub.uid','<>',null)
->field('hub.name,hub.phone,user.avatar,user.uid,hub.village_id,hub.status,hub.type')->select()->toArray();
foreach ($tenant as $k =>$v) { foreach ($tenant as $k =>$v) {
$car = Db::name('car')->where(['uid'=>$v['uid'],'village_id'=>$v['village_id']])->select()->toArray(); $tenant[$k]['type_zh'] = "租客";
$tenant[$k]['cars'] = $car;
$tenant[$k]['car_total'] = count($car);
$family[$k]['type_zh'] = "租客";
} }
return $tenant; return $tenant;
} }
//根据房间id,查询家属 //根据房间id,查询家属
public function getFamily($vacancy_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;
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>1]) $where['hub.type'] = 1;
->where('hub.status','<>',3) $family = $this->getUser($where);
->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();
foreach ($family as $k =>$v) { 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; 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() { public function changeStatus() {
...@@ -335,6 +329,4 @@ class Index extends Base ...@@ -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