Commit 25b6b0e7 authored by 蔡闯's avatar 蔡闯

社区基本信息功能

parent ac5c4c71
......@@ -19,7 +19,13 @@ abstract class BaseController
"property" => '物业费',
"electric" => '电费',
"gas" => '燃气费',
"parking" => '停车费'
"park" => '停车费'
];
protected $myUnit = [
'water' =>"吨",
'electric' =>'度',
'gas' =>'立方'
];
/**
* Request实例
......
......@@ -9,10 +9,31 @@ use think\facade\Request;
class Index extends Base
{
//app首页信息,如果用户只绑定了一个房间,则默认展示一个房间的
public function index() {
$page = Request::param('page',1);
$uid = $this->uid;
$village_id = Request::param('village_id');
if(empty($village_id)) {
$data = Db::name('house_user_bind')->alias('hub')
->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')
->leftJoin('house_village hvi','hvi.village_id = hv.village_id')
->where(['hub.uid'=>$uid])
->field('hvi.village_name,hvi.village_id')->find();
} else {
$data = Db::name('house_village')->where(['village_id'=>$village_id])->field('village_id,village_name')->find();
}
$news= Db::name('news')->where(['village_id'=>$data['village_id'],'is_recommend'=>1])->order('recommend_sort_id','desc')
->field('title,pic,content')
->page($page,config('app.limit'))
->select()->toArray();
return "这是我请求的内容";
foreach ($news as $k=>$v) {
$news[$k]['content'] = mb_substr(strip_tags($v['content']),0,100);
}
$data['news'] = $news;
return $this->returnJson($data);
}
//建筑列表
......@@ -90,6 +111,175 @@ class Index extends Base
}
//当前用户的所有的房间列表
public function allVacancy() {
$uid = $this->uid;
$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')
->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();
$data[$k]['cars'] = $cars;
$car_total = count($cars);
if($car_total ==1) {
$data[$k]['cars'] = $cars[0];
}
$data[$k]['car_total'] = $car_total;
}
$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);
}
//查看车辆详情
public function detailCar() {
$car_id = Request::param('car_id');
$data = Db::name('car')->where(['car_id'=>$car_id,'uid'=>$this->uid])->find();
return $this->returnJson($data);
}
//修改车辆
public function changeCar() {
$car_id = Request::param('car_id');
$data['license_plate'] = Request::param('license_plate');
$is_exit = Db::name('car')->where('uid','<>',$this->uid)->where($data)->find();
if($is_exit){
return $this->returnJson([],'该车牌号已存在!',400);
}
$data['name'] = Request::param('name');
$data['car_color'] = Request::param('car_color');
$data['brand'] = Request::param('brand');
$data['car_type'] = Request::param('car_type');
$change = Db::name('car')->where(['car_id'=>$car_id])->save($data);
if($change) {
return $this->returnJson([],'操作成功!');
} else {
return $this->returnJson([],'操作失败!',400);
}
}
//用户添加车辆
public function addCar() {
$uid = $this->uid;
$car_id = Request::param('car_id');
$data['phone'] = Db::name('user')->where(['uid'=>$uid])->value('phone');
$data['name'] = Request::param('name');
$data['brand'] = Request::param('brand');
$data['car_color'] = Request::param('car_color');
$data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1);
$data['uid'] = $uid;
$data['village_id'] = Request::param('village_id');
if($car_id) {
//判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->where('car_id','<>',$car_id)->find();
if($is_exit) {
return $this->returnJson([],'系统中已存在该车牌!',400);
}
$operation = Db::name('car')->where(['car_id'=>$car_id])->save($data);
} else {
$data['create_time'] = time();
//判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate'],'village_id'=>$data['village_id']])->find();
if($is_exit) {
return $this->returnJson([],'系统中已存在该车牌!',400);
}
$operation = Db::name('car')->save($data);
}
if($operation) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'操作失败!',400);
}
}
//删除车辆
public function deleteCar() {
$car_id = Request::param('car_id');
$delete = Db::name('car')->where(['car_id'=>$car_id,'uid'=>$this->uid])->delete();
if($delete) {
return $this->returnJson();
} else {
return $this->returnJson([],'删除失败!',400);
}
}
//我的房间详情
public function detailVacancy() {
$bind_id = Request::param('bind_id');
$uid = $this->uid;
$where[] = ['hub.uid','=',$uid];
$where[] = ['hub.house_user_bind_id','=',$bind_id];
$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('hvi.village_id,hvi.village_name,hv.vacancy_code,hv.layout_id,hub.pass_time,hub.type,hub.status,hub.vacancy_id,hvi.village_logo,hv.name,hv.phone,hub.house_user_bind_id')
->find();
$res = Common::getVacancyAddress($data['vacancy_code'],$data['layout_id']);
$data['vacancy_address'] = $res['vacancy_address'];
if($data['type'] ==0 ){
//查询家属
$data['family'] = $this->getFamily($data['vacancy_id']);
//查询租客
$data['tenant'] = $this->getTenant($data['vacancy_id']);
} elseif($data['type'] ==2){
$data['tenant'] = $this->getTenant($data['vacancy_id']);
}
return $this->returnJson($data);
}
//根据房间id,查询租客
public function getTenant($vacancy_id) {
//查询租客
$tenant = Db::name('house_user_bind')->alias('hub')->rightJoin('user','user.uid = hub.uid')
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>2])
->field('hub.name,hub.phone,user.avatar,user.uid,hub.village_id')->select()->toArray();
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);
}
return $tenant;
}
//根据房间id,查询家属
public function getFamily($vacancy_id) {
//查询租客
$family = Db::name('house_user_bind')->alias('hub')->rightJoin('user','user.uid = hub.uid')
->where(['hub.vacancy_id'=>$vacancy_id,'hub.type'=>1])
->field('hub.village_id,hub.name,hub.phone,user.avatar,user.uid')->select()->toArray();
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);
}
return $family;
}
......
<?php
namespace app\api\controller;
use app\common\controller\Common;
use think\facade\Db;
use think\facade\Request;
class News extends Base{
//新闻分类
public function newsType() {
$villate_id = Request::param('village_id');
$new_type = Db::name('news_type')->where(['village_id'=>$villate_id])->order('sort_id','desc')->select()->toArray();
return $this->returnJson($new_type);
}
//分类下的新闻列表
public function newsList() {
$type_id = Request::param('type_id');
$page = Request::param('page',1);
$where['news_type_id'] = $type_id;
$data = Db::name('news')->where($where)->page($page,config('app.limit'))->order(['sort_id'=>'desc','create_time'=>'desc'])->field('news_id,title,content,create_time')->page($page,config('app.limit'))->select()->toArray();
foreach ($data as $k => $v) {
$data[$k]['content'] = mb_substr(strip_tags($v['content']),0,100);
}
$res['total'] = Db::name('news')->where($where)->count();
$res['data'] = Common::changeField($data);
return $this->returnJson($res);
}
//新闻详情
public function detailNews() {
$news_id = Request::param('news_id');
$data = Db::name('news')->where(['news_id'=>$news_id])->find();
if($data){
return $this->returnJson(Common::changeField($data));
} else {
return $this->returnJson();
}
}
}
\ No newline at end of file
......@@ -10,32 +10,187 @@ use think\facade\Request;
class Payorder extends Base
{
//查看当前房间下的未缴费的水电物业等,只有业主才能看到记录
//业主所有房间下的未缴费的水电物业等,只有业主才能看到记录
public function payList() {
//获取是业主身份的房间
$vacancys = Db::name('house_user_bind')->alias('hub')
->rightJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')
->where(['hub.type'=>0,'hub.status'=>1])
->field('hub.house_user_bind_id,hv.vacancy_id,hv.vacancy_code,hv.layout_id')
->select()->toArray();
if($vacancys) {
$convertArr = $this->convertArr;
$vacancy_id = Request::param('vacancy_id');
$uid = $this->uid;
$array_keys = array_keys($convertArr);
foreach ($vacancys as $k =>$v) {
$where['vacancy_id'] = $v['vacancy_id'];
$where['is_pay'] = 0;
$res = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']);
$vacancys[$k]['vacancy_address'] = $res['vacancy_address'];
foreach ($convertArr as $key=>$value) {
$where['type'] = $key;
//总金额
$data= Db::name('cost')->where($where)->sum('pay_money');
$all_list[$key] = $data;
}
$vacancys[$k]['pay_list'] = $all_list;
//获取自定义的
unset($where['type']);
$vacancys[$k]['pay_list']['other'] = Db::name('cost')->where($where)->whereNotIn('type',array_keys($convertArr))->sum('pay_money');
}
foreach ($vacancys as $k =>$v) {
foreach ($array_keys as $val ) { //删除水电物业费为0的记录
if($v['pay_list'][$val] ==0) {
unset($vacancys[$k]['pay_list'][$val]);
}
}
if($v['pay_list']['other'] ==0) {
unset($vacancys[$k]['pay_list']['other']);
}
}
} else {
$vacancys = [];
}
return $this->returnJson($vacancys);
}
//查看已缴费的列表
public function getPayList() {
//获取是业主身份的房间
$vacancys = Db::name('house_user_bind')->alias('hub')
->rightJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')
->where(['hub.type'=>0,'hub.status'=>1])
->field('hub.house_user_bind_id,hv.vacancy_id,hv.vacancy_code,hv.layout_id')
->select()->toArray();
if($vacancys) {
$convertArr = $this->convertArr;
$array_keys = array_keys($convertArr);
$unit = $this->myUnit;
foreach ($vacancys as $k =>$v) {
$where['vacancy_id'] = $v['vacancy_id'];
$where['is_pay'] = 1;
$res = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']);
$vacancys[$k]['vacancy_address'] = $res['vacancy_address'];
foreach ($convertArr as $key=>$value) {
$where['type'] = $key;
//总金额
$data= Db::name('cost')->where($where)->sum('pay_money');
$rest['total_money'] = $data;
if($key == "property" || $key =="park"){
$count = Db::name('cost')->where($where)->count();
$total_num = $count."个月";
} else if($key == "water" || $key=="electric" || $key == "gas") {
$num = Db::name('cost')->where($where)->sum('area');
$total_num = $num.$unit[$key];
}
$rest['total_num'] = $total_num;
$all[$key] = $rest;
//$vacancys[$k][$key] = $rest;
}
//获取自定义的
unset($where['type']);
$count = Db::name('cost')->where($where)->whereNotIn('type',$array_keys)->sum('pay_money');
// $vacancys[$k]['other'] = $count;
$all['other'] = $count;
$vacancys[$k]['pay_list'] = $all;
}
//如果已缴费金额为0,删除,不显示
foreach ($vacancys as $k =>$v) {
foreach ($array_keys as $val ) { //删除水电物业费为0的记录
if($v['pay_list'][$val]['total_money'] ==0) {
unset($vacancys[$k]['pay_list'][$val]);
} else {
$pay_time = Db::name('cost')->where(['is_pay'=>1,'type'=>$val,'vacancy_id'=>$v['vacancy_id']])->order('pay_time','desc')->value('pay_time');
$vacancys[$k]['pay_list'][$val]['pay_time'] = date('Y-m-d H:i:s',$pay_time);
}
}
if($v['pay_list']['other'] ==0) {
unset($vacancys[$k]['pay_list']['other']);
} else {
$pay_time = Db::name('cost')->where(['is_pay'=>1,'vacancy_id'=>$v['vacancy_id']])->whereNotIn('type',$array_keys)->order('pay_time','desc')->value('pay_time');
$vacancys[$k]['pay_list'][$val]['pay_time'] = date('Y-m-d H:i:s',$pay_time);
}
}
//要分开循环删除
foreach ($vacancys as $k => $v) {
if(!isset($v['pay_list']['water']) && !isset($v['pay_list']['property']) && !isset($v['pay_list']['electric']) && !isset($v['pay_list']['gas']) && !isset($v['pay_list']['park']) && !isset($v['pay_list']['other'])){
unset($vacancys[$k]);
}
}
} else {
$vacancys = [];
}
return $this->returnJson($vacancys);
}
//某个房间下的某个收费项的以缴费缴费列表
public function vacancyPayedList(){
$vacancy_id = Request::param('vacancy_id');
$type = Request::param('type'); //property|water|electric|gas|park|other,除了other,其他都能对应表中的type
$page = Request::param('page',1);
$isPay = Request::param('is_pay',0);
//不是房主不显示费用明细
$isOwner = Db::name('house_user_bind')->where(['uid'=>$uid,'vacancy_id'=>$vacancy_id])->find();
if($isOwner['type'] != 0) {
return $this->returnJson([]);
$convertArr = $this->convertArr;
if(in_array($type,array_keys($convertArr))){
$where[] = ['type','=',$type];
} else {
$where[] = ['type','not in',array_keys($convertArr)];
}
$where['vacancy_id'] = $vacancy_id;
$where['is_pay'] = $isPay;
$where[] = ['vacancy_id','=',$vacancy_id];
$where[] = ['is_pay','=',1];
//先查询是否合法
$is_exit = Db::name('house_user_bind')->where(['uid'=>$this->uid,'vacancy_id'=>$vacancy_id,'type'=>0])->find();
if(!$is_exit) {
return $this->returnJson([],'查询错误!',400);
}
$data = Db::name('cost')->where($where)->page($page,config('app.limit'))->order('cost_month','desc')->field('cost_id,cost_month,pay_money,type')->select()->toArray();
$total = Db::name('cost')->where($where)->count();
$res['total'] = $total;
$res['data'] = $data;
return $this->returnJson($res);
}
//某个房间下的某个收费项的未缴费缴费列表
public function vacancyPayList() {
$vacancy_id = Request::param('vacancy_id');
$type = Request::param('type'); //property|water|electric|gas|park|other,除了other,其他都能对应表中的type
$page = Request::param('page',1);
$convertArr = $this->convertArr;
if(in_array($type,array_keys($convertArr))){
$where[] = ['type','=',$type];
} else {
$where[] = ['type','not in',array_keys($convertArr)];
$data = Db::name('cost')->where($where)->order('cost_month','asc')->page($page,config('app.limit'))->select()->toArray();
foreach ($data as $k => $v){
$data[$k]['type'] = isset($convertArr[$v['type']]) ? $convertArr[$v['type']]: $v['type'] ;
}
$where[] = ['vacancy_id','=',$vacancy_id];
$where[] = ['is_pay','=',0];
//先查询是否合法
$is_exit = Db::name('house_user_bind')->where(['uid'=>$this->uid,'vacancy_id'=>$vacancy_id,'type'=>0])->find();
if(!$is_exit) {
return $this->returnJson([],'查询错误!',400);
}
$data = Db::name('cost')->where($where)->page($page,config('app.limit'))->order('cost_month','desc')->field('cost_id,cost_month,pay_money,type')->select()->toArray();
$total = Db::name('cost')->where($where)->count();
$res['total'] = $total;
$res['data'] = Common::changeField($data);
$res['data'] = $data;
return $this->returnJson($res);
}
//查看具体的订单详情
public function getDetailPay(){
$cost_id = Request::param('cost_id');
$data = Db::name('cost')->where(['cost_id'=>$cost_id])->find();
return $this->returnJson(Common::changeField($data));
}
//生成订单
public function createOrder(){
$vacancy_id = Request::param('vacancy_id');
......
......@@ -13,24 +13,45 @@ class User extends Base
//获取用户所入住的小区|搜索小区
public function getUserVillage() {
$keyword = Request::param('keyword');
$page = Request::param('page',1);
$province_id = Request::param('province_id');
$city_id = Request::param('city_id');
$area_id = Request::param('area_id');
$where =[];
if($province_id) {
$where['province_id'] = $province_id;
}
if($city_id) {
$where['city_id'] = $city_id;
}
if($area_id) {
$where['area_id'] = $area_id;
}
if($keyword) { //如果有关键字就搜索关键字的小区
$villages = Db::name('house_village')->where('village_name','like','%'.$keyword.'%')->field('village_name,village_id')->select()->toArray();
$res=[];
$villages = Db::name('house_village')->where($where)->where('village_name','like','%'.$keyword.'%')->field('village_name,village_id')->page($page,config('app.limit'))->select()->toArray();
$res['total'] = Db::name('house_village')->where($where)->where('village_name','like','%'.$keyword.'%')->count();
$rest=[];
foreach ($villages as $k =>$v) {
$res[$k]['village_name'] = $v['village_name'];
$res[$k]['vacancy'] = Common::getVacancy($v['village_id'],$this->uid);
$rest['village_name'] = $v['village_name'];
$rest['vacancy'] = Common::getVacancy($v['village_id'],$this->uid);
$res['data'][] = $rest;
}
} else { //没有就展示已入住的小区
$where['hub.uid'] = $this->uid;
$where['hub.status'] = 1;
$village_ids = DB::name('house_user_bind')->alias('hub')->where($where)->column('village_id');
$village_name = Db::name('house_village')->whereIn('village_id',$village_ids)->column('village_name','village_id');
$res=[];
$res['total'] = count($village_ids);
$rest=[];
foreach ($village_ids as $k =>$v) {
$res[$k]['village_name'] = $village_name[$v];
$res[$k]['vacancy'] = Common::getVacancy($v,$this->uid);
$rest['village_name'] = $village_name[$v];
$rest['vacancy'] = Common::getVacancy($v,$this->uid);
$res['data'][] = $rest;
}
}
if($res['total']==1){
$res['data'] = array_values($res['data']);
}
return $this->returnJson($res);
}
......@@ -88,17 +109,21 @@ class User extends Base
$village_id = Request::param('village_id');
$vacancy_id = Request::param('vacancy_id');
$data['vacancy_id'] = $vacancy_id;
$data['name'] = Request::param("name");
$data['phone'] = Request::param("phone");
$data['village_id'] = $village_id;
$data['name'] = $car['name'] = Request::param("name");
$data['phone'] = $car['phone'] = Request::param("phone");
$data['village_id'] = $car['village_id']= $village_id;
$is_exit = Common::getOwnerInfo($vacancy_id);
$data['id_card'] = Request::param("id_card");
$data['uid'] = $this->uid;
$data['uid'] =$car['uid'] = $this->uid;
$data['status'] = 2;
$data['create_time'] = time();
$data['create_time'] =$car['create_time']= time();
$data['memo'] = Request::param('memo');
$data['emer_user'] = Request::param('emer_user');//紧急联系人
$data['emer_phone'] = Request::param('emer_phone'); //紧急联系人电话
$car['brand'] = Request::param('barnd');
$car['car_type'] = Request::param('car_type');
$car['license_plate'] = Request::param('license_plate');
//查看当前手机号是否重复绑定当前房间,一个房间对应的一个手机号只能有一种身份
$is_only = Db::name('house_user_bind')->where(['village_id'=>$village_id,'vacancy_id'=>$vacancy_id,'phone'=>$data['phone']])->where('status',"<>",3)->find();
if($is_only){
......@@ -125,13 +150,20 @@ class User extends Base
return $this->returnJson([],'业主后四位手机号不正确!');
}
}
$add = Db::name('house_user_bind')->save($data);
if($add) {
return $this->returnJson([],'申请成功,等待审核!',200);
} else {
return $this->returnJson([],'申请失败,请重试!',400);
Db::startTrans();
try{
Db::name('house_user_bind')->save($data);
if($car['brand'] && $car['car_type'] && $car['license_plate']) {
Db::name('car')->save($car);
}
Db::commit();
return $this->returnJson();
}catch(\Exception $e){
Db::rollback();
return $this->returnJson([],'绑定失败,请重试!',400);
}
}
//用户申请解绑
......@@ -167,49 +199,14 @@ class User extends Base
//如果是租客身份,查找所属业主
$data[$k]['myOwner'] = Db::name('house_user_bind')->where(['vacancy_id'=>$v['vacancy_id'],'type'=>0,'status'=>1])->field('name,phone,status')->find();
}
}
return $this->returnJson($data);
}
//用户添加车辆
public function addCar() {
$uid = $this->uid;
$car_id = Request::param('car_id');
$data['phone'] = Db::name('user')->where(['uid'=>$uid])->value('phone');
$data['name'] = Request::param('name');
$data['brand'] = Request::param('brand');
$data['car_color'] = Request::param('car_color');
$data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1);
$data['uid'] = $uid;
$data['village_id'] = Request::param('village_id');
if($car_id) {
//判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->where('car_id','<>',$car_id)->find();
if($is_exit) {
return $this->returnJson([],'系统中已存在该车牌!',400);
}
$operation = Db::name('car')->where(['car_id'=>$car_id])->save($data);
} else {
$data['create_time'] = time();
//判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate'],'village_id'=>$data['village_id']])->find();
if($is_exit) {
return $this->returnJson([],'系统中已存在该车牌!',400);
}
$operation = Db::name('car')->save($data);
}
if($operation) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'操作失败!',400);
}
}
}
\ No newline at end of file
......@@ -9,6 +9,7 @@ use think\facade\Request;
class Village extends Base
{
//搜索小区
}
\ No newline at end of file
......@@ -196,7 +196,6 @@ class Common extends BaseController
}
}
//获取流水列表
public static function getWithDrawList($where,$page) {
$count = Db::name('village_money_list')->alias('ml')
......@@ -548,7 +547,6 @@ class Common extends BaseController
$sheet = $objPHPExcel->getSheet(0);
$dataAll = $objPHPExcel->getSheet(0)->toArray(); //获取导入的数据;
$highestRow = $sheet->getHighestRow(); // 取得总行数
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('park_block_id','name');
$errorData =[]; //存放导入失败的数据;
$insertData = [];
......@@ -843,16 +841,23 @@ class Common extends BaseController
}
//通过房间编号和布局id获取房间地址
public static function getVacancyAddress($vacancy_code,$layout_id) {
$layoutString = Db::name('layout_list')->where(['layout_id'=>$layout_id])->value('code');
$layoutArr = explode('-',$layoutString);
$vacancyCodeArr = explode('-',$vacancy_code);
$address="";
foreach ($vacancyCodeArr as $k =>$v){
public static function getVacancyAddress($vacancyCode,$layout_id) {
$address.=$v.$layoutArr[$k];
$layoutCode = Db::name('layout_list')->where(['layout_id'=>$layout_id])->value('code');
$codeArr = explode('-',$layoutCode);
$rom = array_pop($codeArr); //获取最后一个房间的单位
$arr = explode('-',$vacancyCode);
$room_code = array_pop($arr);
$string = '';
$room_num = '';
foreach ($arr as $v) {
$code_name = Db::name('layout_build')->where(['layout_build_id'=>$v])->field('code,level')->find();
$key = $code_name['level'] -1;
$string.=$code_name['code'].$codeArr[$key];
$room_num.=$code_name['code']."-";
}
return $address;
$room_num = $room_num.$room_code;
return ['vacancy_address'=>$string.$room_code.$rom,'room_num'=>$room_num];
}
//通过房间id获取业主信息
......@@ -875,7 +880,8 @@ class Common extends BaseController
$data = Db::name('house_user_bind')->alias('hub')->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')->where(['hub.village_id'=>$village_id,'hub.uid'=>$uid])->whereIn('hub.status',[1,2,4])
->field('hub.house_user_bind_id,hub.vacancy_id,hub.type,hv.layout_id,hv.vacancy_code')->select()->toArray();
foreach ($data as $key =>$val) {
$data[$key]['vacancy_address'] = self::getVacancyAddress($val['vacancy_code'],$val['layout_id']);
$res = self::getVacancyAddress($val['vacancy_code'],$val['layout_id']);
$data[$key]['vacancy_address'] = $res['vacancy_address'];
}
return $data;
......
......@@ -258,7 +258,6 @@ class Build extends Base
}
}
//根据建筑id获取同一级的建筑
public function getCurrent() {
$build_id = Request::param('build_id');
......
......@@ -5,6 +5,7 @@ namespace app\shequ\controller;
use app\admin\controller\Common;
use think\facade\Db;
use think\facade\Request;
......@@ -85,5 +86,110 @@ class Village extends Base
}
//查看社区的基本信息
public function villageInfo() {
$where['village_id'] = $this->village_id;
$data =DB::name('house_village')->where($where)
->field('village_id,property_price,water_price,electric_price,gas_price,park_price,village_Logo,village_name,village_address,province_id,province_name,city_id,city_name,area_id,area_name')->find();
return $this->returnJson($data,'success');
}
//修改小区的基本信息
public function changeVillageInfo(){
$property_price = Request::param('property_price');
$water_price = Request::param('water_price');
$electric_price = Request::param('electric_price');
$gas_price = Request::param('gas_price');
$park_price = Request::param('park_price');
if(!isset($park_price) || !isset($gas_price) || !isset($electric_price) || !isset($water_price) || !isset($property_price)){
return $this->returnJson([],'费用必传递!',400);
}
$where['village_id'] = $this->village_id;
//查看小区的水电物业费等
$info = Db::name('house_village')->where($where)->field('property_price,water_price,electric_price,gas_price,park_price,village_logo')->find();
//修改了小区的费用
if($info['property_price'] != $property_price || $info['water_price'] != $water_price || $info['electric_price'] != $electric_price || $info['gas_price'] != $gas_price ||$info['park_price'] != $park_price ) {
$save['property_price'] = $property_price;
$save['water_price'] = $water_price;
$save['electric_price'] = $electric_price;
$save['gas_price'] = $gas_price;
$save['park_price'] = $park_price;
Db::startTrans();
try{
Db::name('layout_build')->where($where)->save($save);
DB::name('house_village')->where($where)->save($save);
Db::commit();
return $this->returnJson();
}catch(\Exception $e){
Db::rollback();
return $this->returnJson([],'修改失败',400);
}
}
$data['village_name'] = Request::param('village_name');
$data['village_address'] = Request::param('village_address');
$data['province_id'] = Request::param('province_id');
$data['province_name'] = Request::param('province_name');
$data['city_id'] = Request::param('city_id');
$data['city_name'] = Request::param('city_name');
$data['area_id'] = Request::param('area_id');
$data['area_name'] = Request::param('area_name');
$data['village_logo'] = Request::param('logo');
$change = DB::name('house_village')->where($where)->save($data);
if(!$change) {
return $this->returnJson([], '修改失败', 400);
}
return $this->returnJson();
}
//banner图添或修改
public function addBanner() {
$banner_id =Request::param('banner_id');
$data['pic'] =Request::param('pic');
$data['url'] =Request::param('url');
$data['sort_id'] =Request::param('sort_id',1);
if($banner_id){
$where['banner_id'] = $banner_id;
$where['village_id'] = $this->village_id;
$operation = Db::name('village_banner')->where($where)->save($data);
} else {
$data['village_id'] = $this->village_id;
$data['create_time'] = time();
$operation = Db::name('village_banner')->insert($data);
}
if($operation) {
return $this->returnJson();
} else {
return $this->returnJson([],'操作失败!',400);
}
}
//删除banner
public function deleteBanner() {
$banner_id =Request::param('banner_id');
$where['banner_id'] = $banner_id;
$where['village_id'] = $this->village_id;
$delete = Db::name('village_banner')->where($where)->delete();
if($delete) {
return $this->returnJson();
} else {
return $this->returnJson([],'删除失败!',400);
}
}
//banner列表
public function bannerList(){
$where['village_id'] = $this->village_id;
$data =Db::name('village_banner')->where($where)->order(['sort_id'=>'desc','create_time'=>'desc'])->select()->toArray();
return $this->returnJson(Common::changeField($data));
}
}
\ 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