Commit 8e6df942 authored by 蔡闯's avatar 蔡闯

2020-12-28

parent 00ab1955
...@@ -113,8 +113,7 @@ abstract class BaseController ...@@ -113,8 +113,7 @@ abstract class BaseController
*下面是自定义的方法 *下面是自定义的方法
*/ */
//用来返回json数据 //用来返回json数据
protected function returnJson($data,$msg='',$code=200,$type="json"){ protected function returnJson($data=[],$msg="success",$code='200',$type="json"){
$result = [ $result = [
'code' => $code, 'code' => $code,
'msg' => $msg, 'msg' => $msg,
...@@ -125,6 +124,18 @@ abstract class BaseController ...@@ -125,6 +124,18 @@ abstract class BaseController
} }
protected function returnApiJson($data,$code,$msg=""){
$result = [
'code' => $code,
'data' => $data,
];
return Response::create($result,"json");
}
//无限极分类 //无限极分类
public function getTree($data,$parent_id=0,$pk='id'){ public function getTree($data,$parent_id=0,$pk='id'){
......
...@@ -66,7 +66,7 @@ class AdminUser extends Base ...@@ -66,7 +66,7 @@ class AdminUser extends Base
$data = Db::name('admin_role')->where($where)->find(); $data = Db::name('admin_role')->where($where)->find();
$data = Common::changeField($data); $data = Common::changeField($data);
$allNav = Db::name('admin_nav')->field("admin_nav_id,url,url_name,admin_nav_status,parent_id")->select()->toArray(); $allNav = Db::name('admin_nav')->field("admin_nav_id,url,url_name,admin_nav_status,parent_id")->select()->toArray();
$urls = Common::changeNav($data['url_ids'],$allNav,$data['type']); $urls = Common::changeNav($data['url_ids'],$allNav);
$data['url_ids'] = $this->getTree($urls,0,'admin_nav_id'); $data['url_ids'] = $this->getTree($urls,0,'admin_nav_id');
return $this->returnJson($data,'success'); return $this->returnJson($data,'success');
......
...@@ -71,7 +71,7 @@ class Common extends Base ...@@ -71,7 +71,7 @@ class Common extends Base
* @param $navAl array * @param $navAl array
* @param $type int 1 所有都赋值,0 给特定的赋值 * @param $type int 1 所有都赋值,0 给特定的赋值
*/ */
public static function changeNav($url_ids,$navAl,$type=1) { public static function changeNav($url_ids,$navAl,$type=0) {
$urlsArr = explode(",",$url_ids); $urlsArr = explode(",",$url_ids);
if($type==1 ) { if($type==1 ) {
return $navAl; return $navAl;
...@@ -151,4 +151,5 @@ class Common extends Base ...@@ -151,4 +151,5 @@ class Common extends Base
} }
\ No newline at end of file
...@@ -267,14 +267,14 @@ class Index extends Base { ...@@ -267,14 +267,14 @@ class Index extends Base {
if($type==1) { if($type==1) {
$data = DB::name('admin_nav')->where(['admin_nav_id'=>$id])->find(); $data = DB::name('admin_nav')->where(['admin_nav_id'=>$id])->find();
if($data['parent_id'] != 0) { if($data['parent_id'] != 0) {
$res['p_nav'] = DB::name('admin_nav')->where(['admin_nav_id'=>$data['parent_id']])->field('admin_nav_id,url,url_name,admin_nav_status,level,parent_id,sort_id')->find(); $res['p_nav'] = DB::name('admin_nav')->where(['admin_nav_id'=>$data['parent_id']])->field('admin_nav_id,url,url_name,admin_nav_status,level,parent_id,sort_id,icon')->find();
} else{ } else{
$res['p_nav'] = []; $res['p_nav'] = [];
} }
$res['nav'] = $data; $res['nav'] = $data;
} elseif($type==2) { } elseif($type==2) {
$data = DB::name('property_nav')->where(['property_nav_id'=>$id])->field('property_nav_id,url,url_name,admin_nav_status,level,parent_id,sort_id')->find(); $data = DB::name('property_nav')->where(['property_nav_id'=>$id])->field('property_nav_id,url,url_name,property_nav_status,level,parent_id,sort_id,icon')->find();
if($data['parent_id'] != 0) { if($data['parent_id'] != 0) {
$res['p_nav'] = DB::name('property_nav')->where(['property_nav_id'=>$data['parent_id']])->find(); $res['p_nav'] = DB::name('property_nav')->where(['property_nav_id'=>$data['parent_id']])->find();
} else{ } else{
...@@ -282,7 +282,7 @@ class Index extends Base { ...@@ -282,7 +282,7 @@ class Index extends Base {
} }
$res['nav'] = $data; $res['nav'] = $data;
} else { } else {
$data = DB::name('community_nav')->where(['community_nav_id'=>$id])->field('community_nav_id,url,url_name,admin_nav_status,level,parent_id,sort_id')->find(); $data = DB::name('community_nav')->where(['community_nav_id'=>$id])->field('community_nav_id,url,url_name,community_nav_status,level,parent_id,sort_id,icon')->find();
if($data['parent_id'] != 0) { if($data['parent_id'] != 0) {
$res['p_nav'] = DB::name('community_nav')->where(['community_nav_id'=>$data['parent_id']])->find(); $res['p_nav'] = DB::name('community_nav')->where(['community_nav_id'=>$data['parent_id']])->find();
} else{ } else{
...@@ -409,7 +409,7 @@ class Index extends Base { ...@@ -409,7 +409,7 @@ class Index extends Base {
$is_zi = Db::name('admin_nav')->where(['parent_id'=>$id])->find(); $is_zi = Db::name('admin_nav')->where(['parent_id'=>$id])->find();
} elseif($type==2) { } elseif($type==2) {
$is_zi = Db::name('admin_nav')->where(['parent_id'=>$id])->find(); $is_zi = Db::name('property_nav')->where(['parent_id'=>$id])->find();
} else{ } else{
$is_zi = Db::name('community_nav')->where(['parent_id'=>$id])->find(); $is_zi = Db::name('community_nav')->where(['parent_id'=>$id])->find();
......
...@@ -41,7 +41,7 @@ class Login extends BaseController ...@@ -41,7 +41,7 @@ class Login extends BaseController
$where['ad.password'] = md5($password); $where['ad.password'] = md5($password);
$where['ad.status'] = 1; $where['ad.status'] = 1;
$userInfo = Db::name('admin')->alias("ad")->join('ruer_admin_role','ruer_admin_role.role_id = ad.role_id')->where($where)->field("ad.admin_id,ad.username,ruer_admin_role.name,ruer_admin_role.type,ruer_admin_role.url_ids")->find(); $userInfo = Db::name('admin')->alias("ad")->join('admin_role','admin_role.role_id = ad.role_id')->where($where)->field("ad.type,ad.admin_id,ad.username,admin_role.name,admin_role.url_ids")->find();
$data['uid'] = $userInfo['admin_id']; $data['uid'] = $userInfo['admin_id'];
$jwt = JWT::encode($data,config('app.jwt_key')); //根据参数生成了 token $jwt = JWT::encode($data,config('app.jwt_key')); //根据参数生成了 token
......
<?php <?php
namespace app\api\controller; namespace app\api\controller;
use Firebase\JWT\JWT;
use think\facade\Request; use think\facade\Request;
class Base extends \app\BaseController class Base extends \app\BaseController
{ {
//路由中间件
protected $middleware = ['\app\middleware\Logincheck::class'];
public function __construct(\think\App $app) public function __construct(\think\App $app)
{ {
parent::__construct($app); parent::__construct($app);
$decodeData= (array)JWT::decode(Request::param('token'),"zhihuishequ",array("HS256"));
$this->uid = $decodeData['uid']; if(Request::header("token")){
$this->userinfo = Db::name("admin")->where(['admin_id'=>$this->uid])->field("admin_id,username,status,type")->find(); $decodeData= (array)JWT::decode(Request::header('token'),config('app.jwt_key'),array("HS256"));
//把用户的数据,权限都写入到当中; $this->uid = $decodeData['uid'];
} else {
echo json_encode(['code'=>401,'msg'=>"token不存在!"]);exit;
}
} }
} }
\ No newline at end of file
...@@ -2,13 +2,80 @@ ...@@ -2,13 +2,80 @@
namespace app\api\controller; namespace app\api\controller;
use app\common\controller\Common;
use app\BaseController; use app\BaseController;
use think\facade\Db;
use think\facade\Request;
class Index extends Base class Index extends Base
{ {
protected $middleware = ['app\middleware\Logincheck::class'];
public function index() { public function index() {
return "这是我请求的内容"; return "这是我请求的内容";
} }
//建筑列表
public function buildList() {
$where['lb.village_id'] = Request::param('village_id');
$parent_id = Request::param('parent_id',0);
$where['lb.parent_id'] = $parent_id;
//检查当前的parent_id是否是最下的一个建筑了,如果是,则查询该下面的房屋
if($parent_id != 0) {
$layout_id = Request::param('layout_id');
$listInfo = Db::name('layout_list')->where(['layout_id'=>$layout_id])->field('code,level')->find();
$level = $listInfo['level']-1;
$listArr = explode('-',$listInfo['code']);
$name = array_pop($listArr);
$is_last = Db::name('layout_build')->where(['layout_build_id'=>$parent_id,'level'=>$level])->find();
if($is_last){ //查找房间
$data = Db::name('house_vacancy')->where(['parent_id'=>$parent_id])->field('vacancy_id,vacancy_code')->select()->toArray();
foreach ($data as $k => $v) {
$vacancyArr = explode('-',$v['vacancy_code']);
$code = array_pop($vacancyArr);
$data[$k]['code_name'] = $code.$name;
}
} else{
$data = $this->getBuildInfo($where);
}
} else {
$data = $this->getBuildInfo($where);
}
return $this->returnJson($data);
}
//获取建筑信息
public function getBuildInfo($where) {
if(Request::param('layout_id')) {
$where['lb.layout_id'] = Request::param('layout_id');
}
$data = Db::name('layout_build')->alias('lb')->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')->where($where)->order(['lb.layout_id'=>'asc','lb.sort_id'=>'desc'])
->field("lb.layout_build_id,lb.layout_id,lb.code,lb.level,lb.village_id,ll.code as list_code")
->select()
->toArray();
foreach ($data as $k =>$v) {
$data[$k]['code_name'] = $v['code'].explode('-',$v['list_code'])[$v['level']-1];
}
return $data;
}
//获取单个房间基本信息
public function getVacancyInfo() {
$vacancy_id = Request::param('vacancy_id');
$data = Db::name('house_vacancy')->alias('hv')
->Join('house_village hvi','hvi.village_id = hv.village_id')
->Join('house_user_bind hub','hub.vacancy_id = hv.vacancy_id')
->where(['hv.vacancy_id'=>$vacancy_id])
->field('hv.vacancy_code,hv.village_id,hv.parent_id,layout_id,hvi.village_name,hvi.village_address,hvi.province_name,hvi.city_name,hvi.area_name')
->find();
$data['vacancy_address'] = Common::getVacancyAddress($data['vacancy_code'],$data['layout_id']);
$data['vacancyOwnerInfo'] = Common::getOwnerInfo($vacancy_id); //物业信息
$data['getUserBindType'] = Common::getUserBindType();
$data['getFamilyBindType'] = Common::getFamilyBindType();
return $this->returnJson($data);
}
} }
\ No newline at end of file
<?php
namespace app\api\controller;
use app\common\controller\Common;
use app\BaseController;
use Firebase\JWT\JWT;
use think\facade\Db;
use think\facade\Request;
class Login extends BaseController
{
//用户登入
public function login(){
$phone = Request::param('phone');
$password = md5(Request::param('password'));
$code = Request::param('code');
if($code) {
//验证短信验证码是否正确
if(Common::rightCode($phone,$code)){
$userInfo = Db::name('user')->where(['phone'=>$phone])->find();
if($userInfo) {
$uid = $userInfo['uid'];
} else {
//注册
$data['phone'] = $phone;
$data['nickname'] = substr_replace($phone,"*",3,5);
$data['create_time'] =$data['last_time']=time();
$data['add_ip'] = $data['last_ip'] = request()->ip();
$uid= Db::name('user')->insertGetId($data);
}
Common::synUserData($uid,$phone); //返回用户的绑定的房间
$token['uid']= $uid;
$token['time']= date('Y-m-d H:i');
$token = JWT::encode($token,config('app.jwt_key')); //根据参数生成了 token
$res['token'] = $token;
$res['uid'] = $uid;
$res['phone'] = $phone;
return $this->returnJson($res);
} else{
return $this->returnJson([],'验证码不正确!','400');
}
}
if($password){
$where['password'] = $password;
$where['phone'] = $phone;
$userInfo = Db::name('user')->where($where)->find();
if($userInfo){
//更该登入信息
$data['last_time']=time();
$data['last_ip'] = request()->ip();
Db::name('user')->where(['phone'=>$phone])->save($data);
$token['uid']= $userInfo['uid'];
$token['time']= date('Y-m-d H:i');
$token = JWT::encode($token,config('app.jwt_key')); //根据参数生成了 token
$res['token'] = $token;
$res['uid'] = $userInfo['uid'];
$res['phone'] = $phone;
Common::synUserData($userInfo['uid'],$phone);
return $this->returnJson($res,200);
} else {
return $this->returnJson([],'密码不正确!','400');
}
}
return $this->returnJson([],'参数错误,请检查!','400');
}
//发送短信验证码
public function sendCode() {
$phone = Request::param('phone');
$temp_id = 165103;
$temp_para['code'] = createPhoneCode(6);
$client = new \JSMS('7cb29ca79f936510847b7bc6', '8b1c955df362e317b987554c');
$res=$client->sendMessage($phone, $temp_id, $temp_para);
if($res['http_code'] ==200) {
$data['expires_time'] = time() + 300;
$data['code'] = $temp_para['code'] ;
$data['phone'] = $phone;
//先删除该手机号的验证码数据,
Db::name('send_code')->where(['phone'=>$phone])->delete();
Db::name('send_code')->insert($data);
return $this->returnJson([]);
} else {
$this->returnJson([],'短信验证码发送失败','400');
}
}
}
\ No newline at end of file
<?php
namespace app\api\controller;
class PayOrder extends Base
{
//查看当前房间下的未缴费的水电物业等
public function unPyaList() {
}
}
\ No newline at end of file
<?php
namespace app\api\controller;
use app\common\controller\Common;
use think\facade\Db;
use think\facade\Request;
class User extends Base
{
//获取用户所入住的小区|搜索小区
public function getUserVillage() {
$keyword = Request::param('keyword');
if($keyword) { //如果有关键字就搜索关键字的小区
$villages = Db::name('house_village')->where('village_name','like','%'.$keyword.'%')->field('village_name,village_id')->select()->toArray();
$res=[];
foreach ($villages as $k =>$v) {
$res[$k]['village_name'] = $v['village_name'];
$res[$k]['vacancy'] = Common::getVacancy($v['village_id'],$this->uid);
}
} 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=[];
foreach ($village_ids as $k =>$v) {
$res[$k]['village_name'] = $village_name[$v];
$res[$k]['vacancy'] = Common::getVacancy($v,$this->uid);
}
}
return $this->returnJson($res);
}
//修改|忘记密码
public function changePassword() {
if(request()->isPost()) {
$original_password = md5(Request::param('original_password'));
$new_password = md5(Request::param('new_password'));
$code = Request::param('code');
$phone = Request::param('phone');
if($code){
if(Common::rightCode($phone,$code)){
$change = Db::name('user')->where(['uid'=>$this->uid,'phone'=>$phone])->save(['password'=>$new_password]);
if($change){
return $this->returnJson([]);
} else {
return $this->returnJson([],'修改失败',400);
}
} else {
return $this->returnJson([],"验证码不正确",400);
}
} else {
//验证原密码是否正确
$is_exit = Db::name('user')->where(['uid'=>$this->uid,'phone'=>$phone,'password'=>$original_password])->find();
if($is_exit) {
$change = Db::name('user')->where(['uid'=>$this->uid,'phone'=>$phone])->save(['password'=>$new_password]);
if($change){
return $this->returnJson();
} else {
return $this->returnJson([],'修改失败',400);
}
} else {
return $this->returnJson([],'验证码不正确',400);
}
}
} else {
return $this->returnJson([],'请求方式不正确',400);
}
}
//用户设置密码
public function setPassword() {
$data['password'] = md5(Request::param('password'));
$save = Db::name('user')->where(['uid'=>$this->uid])->save($data);
if($save) {
return $this->returnJson();
} else {
return $this->returnJson([],'','111111');
}
}
//用户绑定房间
public function userBindVacancy(){
$data['type'] = Request::param('type');
$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;
$is_exit = Common::getOwnerInfo($vacancy_id);
$data['id_card'] = Request::param("id_card");
$data['uid'] = $this->uid;
$data['status'] = 2;
$data['create_time'] = time();
$data['memo'] = Request::param('memo');
$data['emer_user'] = Request::param('emer_user');//紧急联系人
$data['emer_phone'] = Request::param('emer_phone'); //紧急联系人电话
//查看当前手机号是否重复绑定当前房间,一个房间对应的一个手机号只能有一种身份
$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){
return $this->returnJson([],'用户已绑定房间!',400);
}
if($data['type'] == 0) { //申请业主不需要填写业主后四位手机号
//检查该房间是否有房主绑定
if(!empty($is_exit)){
return $this->returnJson([],'该房间下已有业主!',);
}
$save['id_card'] = $data['id_card'];
$save['name'] = $data['name'];
$save['phone'] = $data['phone'];
$save['uid'] = $data['uid'];
//修改房间的信息
Db::name('house_vacancy')->where(['vacancy_id'=>$vacancy_id])->save($save);
}else{
if(empty($is_exit)){
return $this->returnJson([],'该房间未绑定业主,不能绑定租客!',);
}
$ownerPhone = $is_exit['phone'];
$phone_num = Request::param('phone_num');
if($phone_num != substr($ownerPhone,7)){
return $this->returnJson([],'业主后四位手机号不正确!');
}
}
$add = Db::name('house_user_bind')->save($data);
if($add) {
return $this->returnJson([],'申请成功,等待审核!',200);
} else {
return $this->returnJson([],'申请失败,请重试!',400);
}
}
//用户申请解绑
public function userUnBind(){
$where['house_user_bind_id'] = Request::param('house_user_bind_id');
$where['uid'] = $this->uid;
$save['status'] = 4;
$change =Db::name('house_user_bind')->where($where)->save($save);
if($change) {
return $this->returnJson([],'申请成功!');
} else {
return $this->returnJson([],'申请失败!',400);
}
}
//查看所有的房间,如果是业主,展示房间下的所有租客或家属
public function getUserVacancy() {
$uid = $this->uid;
$where['hub.uid'] = $uid;
$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 = hub.village_id')
->where($where)->whereIn('hub.status',[1,2,4])
->field('hub.type,hub.house_user_bind_id,hub.vacancy_id,parent_id,hv.vacancy_code,hv.layout_id,hv.name,hv.phone,hvi.village_name')
->select()->toArray();
foreach ($data as $k =>$v) {
$data[$k]['vacancy_address'] = Common::getVacancyAddress($v['vacancy_code'],$v['layout_id']);
if($v['type'] ==0) {
//如果是业主身份,查找下面的租客或家属等
$data[$k]['myTenant'] = Db::name('house_user_bind')->where(['vacancy_id'=>$v['vacancy_id']])->whereIn('type',[1,2,3])->field('name,phone,status')->select()->toArray();
}else{
//如果是租客身份,查找所属业主
$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);
}
//
}
\ No newline at end of file
<?php
namespace app\api\controller;
use app\common\controller\Common;
use think\facade\Db;
use think\facade\Request;
class Village extends Base
{
}
\ No newline at end of file
...@@ -114,7 +114,45 @@ function isPhoneNo($phone){ ...@@ -114,7 +114,45 @@ function isPhoneNo($phone){
//图片上传 //图片上传
//文件下载
function downloadFile($file,$file_name) {
ob_clean();
if(!file_exists($file)){
echo "文件不存在";
return;
}
$fp=fopen($file,"r");
//取得文件大小
$file_Size=filesize($file);
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_Size);
if(!$file_name){
$fileArr = explode('/',$file);
$file_name = end($fileArr);
}
header("Content-Disposition: attachment; filename=".$file_name);
$buffer=1024;
$buffer_count=0;
while(!feof($fp)&&$file_Size-$buffer_count>0){
$data=fread($fp,$buffer);
$buffer_count+=$buffer;
echo $data;
}
fclose($fp);
}
//生成短信验证码
function createPhoneCode($length) {
return substr(str_shuffle("012345678901234567890123456789"), 0, $length);;
}
......
This diff is collapsed.
<?php
namespace app\common\controller;
use app\BaseController;
use think\facade\Db;
class Timing extends BaseController
{
//每月的一号生成所有房间的当月的物业费,其他费用后台每月自己添加
public function createCost() {
//物业费每月自动生成
Db::name('house_vacancy')->alias('hv')
->leftJoin('layout_build lb','lb.layout_build_id = hv.parent_id' )
->field('lb.property_price,hv.property_fee as vacancy_property_price,hv.property_end_time,hv.area,hv.is_inherit,hv.vacancy_id,hv.village_id')
->chunk(20,function ($dataAll){
foreach ($dataAll as $k=>$v) {
if(is_null($v['property_end_time'])){
continue;
}
$price = $v['is_inherit'] == 1 ? $v['property_price'] : $v['vacancy_property_price'];
$property_end_time = strtotime($v['property_end_time']);
$now_time = date('Y-m',time());
$now_time_stamp = strtotime($now_time);
if($now_time_stamp > $property_end_time) { //生成当前月份与物业结束时间之前的每月费用
$data['vacancy_id'] = $v['vacancy_id'];
$data['village_id'] = $v['village_id'];
$data['type'] = 'property';
$res = $this->createDate($v['property_end_time'],$now_time); //返回物业开始时间到结束时间之前的每月时间,array
foreach ($res as $val){
$data['cost_month'] = $val;
//先判断当前月份的物业费是否已存在
$is_exit = Db::name('cost')->where($data)->where($data)->find();
if($is_exit) {
continue;
}
$data['area'] = $v['area'];
$data['total_month'] = $v['area']*$price;
$data['create_time'] = time();
$data['price'] = $price;
Db::name('cost')->insert($data);
}
}
}
});
}
//根据开始时间和结束时间生成中间的月份
// Y-m;
public function createDate($start_time,$end_time) {
$start_time_year = explode('-',$start_time)[0];
$start_time_month = explode('-',$start_time)[1];
$end_time_year = explode('-',$end_time)[0];
$end_time_month = explode('-',$end_time)[1];
$res =[];
if($start_time_year==$end_time_year) {
for($i=$start_time_month;$i<=$end_time_month;$i++) {
$res[] = $start_time_year."-".$i;
}
} else {
for($i=$start_time_year;$i<=$end_time_year;$i++) {
if($i == $end_time_year) {
for($j=1;$j<=$end_time_month;$j++) {
if($j<10){
$res[] = $i."-0".$j;
} else {
$res[] = $i."-".$j;
}
}
} elseif($i==$start_time_year) {
for($k=$start_time_month;$k<13;$k++) {
if($k<10){
$res[] = $i."-0".$k;
} else{
$res[] = $i."-".$k;
}
}
} else {
for($k=1;$k<13;$k++) {
if($k<10){
$res[] = $i."-0".$k;
} else{
$res[] = $i."-".$k;
}
}
}
}
}
return $res;
}
}
\ No newline at end of file
...@@ -52,11 +52,11 @@ class Admin extends Base ...@@ -52,11 +52,11 @@ class Admin extends Base
$page = Request::param('page',1); $page = Request::param('page',1);
$total = Db::name('community_admin')->alias('ca')->where($where)->count(); $total = Db::name('community_admin')->alias('ca')->where($where)->count();
$data = Db::name('community_admin')->alias('ca')->leftJoin('ruer_community_role cr','cr.role_id = ca.role_id')->where($where) $data = Db::name('community_admin')->alias('ca')->leftJoin('ruer_community_role cr','cr.role_id = ca.role_id')->where($where)
->field("ca.community_admin_id,ca.account,ca.status,ca.phone,ca.name,cr.name as role_name,cr.role_id,ca.type") ->field("ca.create_time,ca.community_admin_id,ca.account,ca.status,ca.phone,ca.name,cr.name as role_name,cr.role_id,ca.type")
->page($page,config('app.limit')) ->page($page,config('app.limit'))
->select()->toArray(); ->select()->toArray();
$res['total'] = $total; $res['total'] = $total;
$res['data'] = $data; $res['data'] = Common::changeField($data);
return $this->returnJson($res,'success'); return $this->returnJson($res,'success');
} }
...@@ -64,7 +64,7 @@ class Admin extends Base ...@@ -64,7 +64,7 @@ class Admin extends Base
public function detailAdmin() { public function detailAdmin() {
$where['admin.community_admin_id'] = Request::param('admin_id'); $where['admin.community_admin_id'] = Request::param('admin_id');
$data = Db::name('community_admin')->alias('admin')->leftJoin('community_role ar','ar.role_id = admin.role_id')->where($where) $data = Db::name('community_admin')->alias('admin')->leftJoin('community_role ar','ar.role_id = admin.role_id')->where($where)
->field('admin.role_id,admin.type,admin.community_admin_id,admin.account,admin.status,admin.role_id, admin.name as admin_name,ar.url_ids,ar.name')->find(); ->field('admin.phone,admin.role_id,admin.type,admin.community_admin_id,admin.account,admin.status,admin.role_id,admin.name as admin_name,ar.url_ids,ar.name')->find();
$allNav = DB::name('community_nav')->where(['community_nav_status'=>1])->field('community_nav_id,url,url_name,parent_id')->select()->toArray(); $allNav = DB::name('community_nav')->where(['community_nav_status'=>1])->field('community_nav_id,url,url_name,parent_id')->select()->toArray();
...@@ -81,7 +81,7 @@ class Admin extends Base ...@@ -81,7 +81,7 @@ class Admin extends Base
//删除小区管理员 //删除小区管理员
public function deleteAdmin() { public function deleteAdmin() {
$property_admin_id = Request::param('community_admin_id'); $property_admin_id = Request::param('admin_id');
$where['community_admin_id'] = $property_admin_id; $where['community_admin_id'] = $property_admin_id;
$opation = Db::name('community_admin')->where($where)->delete(); $opation = Db::name('community_admin')->where($where)->delete();
if($opation) { if($opation) {
...@@ -91,19 +91,17 @@ class Admin extends Base ...@@ -91,19 +91,17 @@ class Admin extends Base
} }
} }
//创建|修改角色 //创建|修改角色
public function createRole() { public function createRole() {
$role_id = Request::param('role_id'); $role_id = Request::param('role_id');
$data['village_id'] = Request::param('village_id'); $data['village_id'] = Request::param('village_id');
$data['name'] = Request::param('name'); $data['name'] = Request::param('name');
$data['status'] = Request::param('status'); $data['status'] = 1;
$data['type'] = Request::param('type',0); //1表示超级管理,0表示普通的
$data['url_ids'] = implode(',',Request::param('url_ids')); $data['url_ids'] = implode(',',Request::param('url_ids'));
if($role_id){ if($role_id){
$opation = Db::name('community_role')->where(['role_id'=>$role_id])->save($data); $opation = Db::name('community_role')->where(['role_id'=>$role_id])->save($data);
} else { } else {
$data['create_time'] = time();
$opation = Db::name('community_role')->insert($data); $opation = Db::name('community_role')->insert($data);
} }
if($opation) { if($opation) {
...@@ -152,7 +150,7 @@ class Admin extends Base ...@@ -152,7 +150,7 @@ class Admin extends Base
$data = Db::name('community_role')->where($where)->find(); $data = Db::name('community_role')->where($where)->find();
$data = Common::changeField($data); $data = Common::changeField($data);
$allNav = Db::name('community_nav')->field("community_nav_id,url,url_name,community_nav_status,parent_id")->select()->toArray(); $allNav = Db::name('community_nav')->field("community_nav_id,url,url_name,community_nav_status,parent_id")->select()->toArray();
$res = Common::changeNav($data['url_ids'],$allNav,$data['type']); $res = Common::changeNav($data['url_ids'],$allNav);
$data['url_ids'] = $this->getTree($res,0,'community_nav_id'); $data['url_ids'] = $this->getTree($res,0,'community_nav_id');
return $this->returnJson($data,'success'); return $this->returnJson($data,'success');
} }
...@@ -172,7 +170,7 @@ class Admin extends Base ...@@ -172,7 +170,7 @@ class Admin extends Base
$where['admin.status'] = 1; $where['admin.status'] = 1;
$data = Db::name('community_admin')->alias('admin')->leftJoin('community_role ar','ar.role_id = admin.role_id')->where($where)->field('admin.*,ar.url_ids')->find(); $data = Db::name('community_admin')->alias('admin')->leftJoin('community_role ar','ar.role_id = admin.role_id')->where($where)->field('admin.*,ar.url_ids')->find();
$allNav = Db::name('community_nav')->field("community_nav_id,url,url_name,community_nav_status,parent_id")->where(['community_nav_status'=>1])->select()->toArray(); $allNav = Db::name('community_nav')->field("community_nav_id,url,url_name,community_nav_status,parent_id,icon")->where(['community_nav_status'=>1])->select()->toArray();
$urlsArr = explode(",",$data['url_ids']); $urlsArr = explode(",",$data['url_ids']);
if(!$data['type'] ==1 ) { if(!$data['type'] ==1 ) {
......
...@@ -139,7 +139,7 @@ class Build extends Base ...@@ -139,7 +139,7 @@ class Build extends Base
$code = Request::param('code'); $code = Request::param('code');
//查询修改的code是否存在 //查询修改的code是否存在
$is_exit = Db::name('layout_build')->where(['village_id'=>$buildInfo['village_id'],'layout_id'=>$buildInfo['layout_id'],'parent_id'=>$buildInfo['parent_id'],'code'=>$code])->where('layout_build_id','!=',$buildInfo['layout_build_id'])->find(); $is_exit = Db::name('layout_build')->where(['village_id'=>$buildInfo['village_id'],'layout_id'=>$buildInfo['layout_id'],'parent_id'=>$buildInfo['parent_id'],'code'=>$code])->where('layout_build_id','<>',$buildInfo['layout_build_id'])->find();
if($is_exit) { if($is_exit) {
return $this->returnJson([],'该建筑编号已存在!',400); return $this->returnJson([],'该建筑编号已存在!',400);
} }
...@@ -171,8 +171,10 @@ class Build extends Base ...@@ -171,8 +171,10 @@ class Build extends Base
if($data['property_price'] != $buildInfo['property_price'] || $data['water_price'] != $buildInfo['water_price'] || $data['electric_price'] != $buildInfo['electric_price'] || $data['gas_price'] != $buildInfo['gas_price'] || $data['parking_price'] != $buildInfo['parking_price'] ) { if($data['property_price'] != $buildInfo['property_price'] || $data['water_price'] != $buildInfo['water_price'] || $data['electric_price'] != $buildInfo['electric_price'] || $data['gas_price'] != $buildInfo['gas_price'] || $data['parking_price'] != $buildInfo['parking_price'] ) {
//先修改下面的建筑,然后在修改其他 //先修改下面的建筑,然后在修改其他
$ids = $this->findBuildId($layout_build_id); $ids = $this->findBuildId($layout_build_id);
unset($where['layout_build_id']);
Db::name('layout_build')->where('layout_build_id','in',$ids)->save($where); Db::name('layout_build')->where('layout_build_id','in',$ids)->save($where);
} }
$data['is_inherit'] = $is_inherit; $data['is_inherit'] = $is_inherit;
$change = Db::name('layout_build')->where(['layout_build_id'=>$layout_build_id])->save($data); $change = Db::name('layout_build')->where(['layout_build_id'=>$layout_build_id])->save($data);
...@@ -216,12 +218,26 @@ class Build extends Base ...@@ -216,12 +218,26 @@ class Build extends Base
$page = Request::param('page',1); $page = Request::param('page',1);
$data = Db::name('layout_build')->alias('lb')->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')->where($where)->order(['lb.layout_id'=>'asc','lb.sort_id'=>'desc'])->page($page,config('app.limit')) $data = Db::name('layout_build')->alias('lb')->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')->where($where)->order(['lb.layout_id'=>'asc','lb.sort_id'=>'desc'])->page($page,config('app.limit'))
->field("lb.*,ll.name as layout_name") ->field("lb.*,ll.name as layout_name,ll.level as layout_level")
->select() ->select()
->toArray(); ->toArray();
foreach ($data as $k => $v) {
$is_exit = Db::name('layout_build')->where(['parent_id'=>$v['layout_build_id']])->value('layout_build_id');
if($is_exit){
$data[$k]['hasChildren'] = true;
} else{
$data[$k]['hasChildren'] = false;
}
//查看当前是否是最后一级建筑
if($v['level'] == ($v['layout_level']-1)){
$data[$k]['isEnd'] = true;
} else {
$data[$k]['isEnd'] = false;
}
}
$count = Db::name('layout_build')->alias('lb')->where($where)->count(); $count = Db::name('layout_build')->alias('lb')->where($where)->count();
$res['count'] = $count; $res['count'] = $count;
$res['data'] = Common::changeField($data); $res['data'] = Common::changeField($data);
return $this->returnJson($res,'success'); return $this->returnJson($res,'success');
} }
......
<?php
namespace app\shequ\controller;
use app\admin\controller\Common;
use think\facade\Db;
use think\facade\Request;
class Device extends Base
{
//添加|修改设备
public function createDevice() {
$device_id = Request::param('device_id');
$data['device_name'] = Request::param('device_name');
$data['device_type'] = Request::param('device_type');
$data['device_alive'] = Request::param('device_alive');
$data['device_score'] = Request::param('device_score');
$data['device_sn'] = Request::param('device_sn');
$data['village_id'] = $this->village_id;
$data['build_id'] = Request::param('build_id');
$data['device_direction'] = Request::param('device_direction');
$data['device_platform'] = Request::param('device_platform');
if($device_id) {
$where['device_id'] = $device_id;
$operate = Db::name('house_face_device')->where($where)->save($data);
} else {
$data['create_time'] = time();
$operate = Db::name('house_face_device')->save($data);
}
if($operate) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'操作失败!');
}
}
//删除设备
public function deleteDevice() {
$where['device_id'] = Request::param('device_id');
$where['village_id'] = $this->village_id;
$del = Db::name('house_face_device')->where($where)->delete();
if($del) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'删除失败',400);
}
}
//设备列表
public function deviceList() {
$where['village_id'] = $this->village_id;
$page = Request::param('page',1);
$total = Db::name('house_face_device')->where($where)->count();
$data = Db::name('house_face_device')->alias('hfd')->where($where)->order('create_time','desc')
->field('hfd.device_id,hfd.device_name,hfd.device_type,hfd.device_alive,hfd.device_score,hfd.device_sn,hfd.build_id,hfd.device_direction,hfd.device_platform,hfd.create_time')
->page($page,config('app.limit'))->select()->toArray();
$res['total'] = $total;
$res['data'] = Common::changeField($data);
return $this->returnJson($res,'success');
}
}
\ No newline at end of file
...@@ -15,7 +15,7 @@ class Login extends BaseController ...@@ -15,7 +15,7 @@ class Login extends BaseController
$where['cad.account'] = Request::param("account"); $where['cad.account'] = Request::param("account");
$where['cad.password'] = md5(Request::param("password")); $where['cad.password'] = md5(Request::param("password"));
$where['cad.status'] = 1; $where['cad.status'] = 1;
$userInfo = Db::name('community_admin')->alias("cad")->leftJoin('ruer_community_role cr','cr.role_id = cad.role_id') $userInfo = Db::name('community_admin')->alias("cad")->leftJoin('community_role cr','cr.role_id = cad.role_id')
->field("cad.community_admin_id,cad.account,cad.name,cad.type,cr.url_ids,cad.village_id") ->field("cad.community_admin_id,cad.account,cad.name,cad.type,cr.url_ids,cad.village_id")
->where($where)->find(); ->where($where)->find();
if($userInfo){ if($userInfo){
...@@ -37,7 +37,6 @@ class Login extends BaseController ...@@ -37,7 +37,6 @@ class Login extends BaseController
//超级管理员 //超级管理员
if($userInfo['type']==1) { if($userInfo['type']==1) {
$res = Db::name('community_nav')->where(['community_nav_status'=>1])->order("sort_id,level")->field("community_nav_id,url_name,url,parent_id")->select()->toArray(); $res = Db::name('community_nav')->where(['community_nav_status'=>1])->order("sort_id,level")->field("community_nav_id,url_name,url,parent_id")->select()->toArray();
} else { //普通管理员 } else { //普通管理员
$res = Db::name('community_nav')->where(['community_nav_status'=>1])->whereIn('community_nav_id',$userInfo['url_ids'])->field("community_nav_id,url_name,url,parent_id")->order("sort_id,level")->select()->toArray(); $res = Db::name('community_nav')->where(['community_nav_status'=>1])->whereIn('community_nav_id',$userInfo['url_ids'])->field("community_nav_id,url_name,url,parent_id")->order("sort_id,level")->select()->toArray();
} }
......
This diff is collapsed.
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace app\shequ\controller; namespace app\shequ\controller;
use app\admin\controller\Common; use app\common\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
...@@ -12,17 +12,47 @@ class UserBind extends Base ...@@ -12,17 +12,47 @@ class UserBind extends Base
{ {
protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class']; protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class'];
//用户解绑房间 //用户绑定|解绑房间
public function unbind() { public function unbind() {
$where['house_user_bind_id'] = Request::param('bind_id'); $where['house_user_bind_id'] = Request::param('bind_id');
//现获取这一条房间的绑定的状态
$bindInfo = Db::name('house_user_bind')->where($where)->field('phone,id_card,vacancy_id,type')->find();
$status= Request::param('status',3); $status= Request::param('status',3);
$save['status'] = $status;
if($status == 1) { if($status == 1) {
$save['pass_time'] = time(); $save['pass_time'] = time();
if($bindInfo['type'] == 3) { //这是更换业主或审核房主
//1.更换房间表的信息
$data['name'] = $bindInfo['name'];
$data['id_card'] = $bindInfo['id_card'];
$save['type'] = 0;
Db::startTrans();
try{
Db::name('house_vacancy')->where(['vacancy_id'=>$bindInfo['vacancy_id']])->save($data);
//更改原先的业主的绑定字段
Db::name('house_user_bind')->where(['vacancy_id'=>$bindInfo['vacancy_id'],'type'=>0,'status'=>1])->save(['status'=>3]);
//更改现在的用户为房主
$change = Db::name('house_user_bind')->where($where)->update($save);
Db::commit();
return $this->returnJson();
}catch(\Exception $e){
Db::rollback();
return $this->returnJson([],'绑定失败,请重试!',400);
}
}
} }
if($status == 3) { if($status == 3) {
$save['unbind_time'] = time(); $save['unbind_time'] = time();
//如果是解绑的话,需要考虑,当前如果是业主,需要查看是否又其他的用户绑定了
if($bindInfo['type']==0) {
$is_exit = Db::name('house_user_bind')->where(['vacancy_id'=>$bindInfo['vacancy_id']])->where('status','<>',3)->where('type','<>',0)->find();
if($is_exit) {
return $this->returnJson([], '业主解绑失败,该房间下还有用户未解绑!');
}
}
} }
$save['status'] = $status;
$change = Db::name('house_user_bind')->where($where)->update($save); $change = Db::name('house_user_bind')->where($where)->update($save);
if($change) { if($change) {
return $this->returnJson([],'success',200); return $this->returnJson([],'success',200);
...@@ -157,6 +187,70 @@ class UserBind extends Base ...@@ -157,6 +187,70 @@ class UserBind extends Base
} }
//用户导入模板下载
public function downloadTenant() {
$file_dir = "./formwork/importTenant.xls";
$phpExcel = \PHPExcel_IOFactory::load($file_dir);
$village_id = $this->village_id??1;
$optionsArr = Db::name('layout_list')->where(['village_id'=>$village_id])->column('code');
$optionsString = implode(',',$optionsArr);//这个是选择布局
for($i=2;$i<200;$i++) {
$phpExcel->getActiveSheet()->getCell('F'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
-> setShowInputMessage(true)
-> setShowErrorMessage(true)
-> setShowDropDown(true)
-> setErrorTitle('输入的值有误')
-> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('社区布局')
-> setFormula1('"'.$optionsString.'"');; //这一句为要设置数据有效性的单元格
$phpExcel->getActiveSheet()->getCell('E'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
-> setShowInputMessage(true)
-> setShowErrorMessage(true)
-> setShowDropDown(true)
-> setErrorTitle('输入的值有误')
-> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('社区布局')
-> setFormula1('"租客,业主,家属"');; //这一句为要设置数据有效性的单元格
}
$objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="用户导入.xls"');
header('Cache-Control: max-age=0');
$objWriter->save("php://output");
}
//用户批量导入数据
public function importTenant() {
$filePath = Request::param('filePath');
if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400);
}
$village_id = $this->village_id ?? 1;
$res = Common::importTenant($filePath,$village_id);
if($res['code']!=200) {
return $this->returnJson([],'success');
}
}
//查看用户关联到车辆
public function userCar() {
$phone = Request::param("phone");
$data = Db::name('car')->where(['phone'=>$phone])->field("car_id,phone,license_plate,create_time,name,car_color")->order('create_time','desc')->select()->toArray();
return $this->returnJson(Common::changeField($data),'success');
}
......
...@@ -5,7 +5,7 @@ namespace app\shequ\controller; ...@@ -5,7 +5,7 @@ namespace app\shequ\controller;
//关于房屋的操作 //关于房屋的操作
use app\admin\controller\Common; use app\common\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
...@@ -13,7 +13,6 @@ class Vacancy extends Base ...@@ -13,7 +13,6 @@ class Vacancy extends Base
{ {
protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class']; protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class'];
//房间列表 //房间列表
public function vacancyList() { public function vacancyList() {
$page = Request::param('page',1); $page = Request::param('page',1);
...@@ -207,9 +206,150 @@ class Vacancy extends Base ...@@ -207,9 +206,150 @@ class Vacancy extends Base
} }
//房间批量导入
public function importVacancy() {
$filePath = Request::param('filePath');
if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400);
}
$village_id = $this->village_id ?? 1;
$res = Common::importVacancy($filePath,$village_id);
if($res['code']==200) {
return $this->returnJson([],'success');
}
}
//excel文件上传
public function uploadFile() {
$file = request()->file('xls');
$ext = $file->getOriginalExtension();
if($ext != 'xls') {
return $this->returnJson([],'请上传xls文件',400);
}
$savename = \think\facade\Filesystem::putFile('', $file);
$data['filePath'] = "./public/".$savename;
return $this->returnJson($data,'success');
}
//房间批量下载模板下载
public function downloadImportVacancy() {
$file = "./formwork/importVacancy.xls";
$phpExcel = \PHPExcel_IOFactory::load($file);
$village_id = $this->village_id;
$optionsArr = Db::name('layout_list')->where(['village_id'=>$village_id])->column('code');
$optionsString = implode(',',$optionsArr);//这个是选择布局
$car_blockArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsCarBlockString = implode(',',$car_blockArr);//这个是车库布局
for($i=2;$i<200;$i++) {
$phpExcel->getActiveSheet()->getCell('H'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
-> setShowInputMessage(true)
-> setShowErrorMessage(true)
-> setShowDropDown(true)
-> setErrorTitle('输入的值有误')
-> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('社区布局')
-> setFormula1('"'.$optionsString.'"');; //这一句为要设置数据有效性的单元格
if($optionsCarBlockString) {
$phpExcel->getActiveSheet()->getCell('F'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
-> setShowInputMessage(true)
-> setShowErrorMessage(true)
-> setShowDropDown(true)
-> setErrorTitle('输入的值有误')
-> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('车库位置')
-> setFormula1('"'.$optionsCarBlockString.'"');; //这一句为要设置数据有效性的单元格
}
}
$objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="房间.xls"');
header('Cache-Control: max-age=0');
$objWriter->save("php://output");
}
//当前房间下的费用明细
public function vacancyCost(){
$cost_month = Request::param('month');
$page = Request::param('page',1);
$vacancy_id = Request::param('vacancy_id');
$where['village_id'] = $this->village_id;
$where['vacancy_id'] = $vacancy_id;
if($cost_month){
$where['cost_month'] =$cost_month;
}
$data = Db::name('cost')->where($where)->order('cost_id','desc')->field('cost_id,price,type,total_money,cost_month,is_pay,area')->page($page,config('app.limit'))->select()->toArray();
foreach ($data as $k=>$v) {
switch ($v['type']){
case "property":
$data[$k]['type'] ="物业费";
break;
case "water":
$data[$k]['type'] ="水费";
break;
case "gas":
$data[$k]['type'] ="燃气费";
break;
case "electric":
$data[$k]['type'] ="电费";
break;
case "parking":
$data[$k]['type'] ="停车费";
break;
}
}
$total = Db::name('cost')->where($where)->count();
$res['total'] = $total;
$res['data'] = $data;
return $this->returnJson($res);
}
//修改某个房间的费用明细
public function changeCost() {
$where['cost_id'] = Request::param('cost_id');
$where['village_id'] = $this->village_id;
$data['price'] =Request::param('price');
$data['area'] =Request::param('area');
$data['total_money'] = $data['price'] * $data['area'];
$data['is_pay'] =Request::param('is_pay',0);
$type =Request::param('type','物业费');
switch ($type){
case "物业费":
$real_type = "property";
break;
case "水费" :
$real_type ="water";
break;
case "燃气费":
$real_type ="gas";
break;
case "电费" :
$real_type = "electric";
break;
case "停车费" :
$real_type ="parking";
break;
default :
return $this->returnJson([],'费用类型不正确',400);
}
$data['type'] = $real_type;
$change = Db::name('cost')->where($where)->save($data);
if($change) {
Db::name('cost_log')->insert(['cost_id'=>$where['cost_id'],'community_admin_id'=>$this->uid,'data'=>json_encode($data)]);
return $this->returnJson();
} else {
return $this->returnJson([],'修改失败',400);
}
}
//房间导入
} }
\ No newline at end of file
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
namespace app\wuye\controller; namespace app\wuye\controller;
use app\admin\controller\Base;
use app\admin\controller\Common; use app\admin\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
...@@ -25,9 +23,8 @@ class Admin extends Base ...@@ -25,9 +23,8 @@ class Admin extends Base
$data['role_id'] = Request::param('role_id'); $data['role_id'] = Request::param('role_id');
$data['phone'] = Request::param('phone'); $data['phone'] = Request::param('phone');
$data['status'] = Request::param('status'); $data['status'] = Request::param('status');
$data['village_id'] = Request::param('status'); $data['name'] = Request::param('name');
$data['type'] = Request::param('type',0); $data['type'] = Request::param('type',0);
$data['village_ids'] = implode(',',Request::param('village_ids'));
if($property_admin_id){ if($property_admin_id){
$where['property_admin_id'] = $property_admin_id; $where['property_admin_id'] = $property_admin_id;
$opation = Db::name('property_admin')->where($where)->save($data); $opation = Db::name('property_admin')->where($where)->save($data);
...@@ -50,7 +47,7 @@ class Admin extends Base ...@@ -50,7 +47,7 @@ class Admin extends Base
$res['total'] = Db::name('property_admin')->alias('pa')->where($where)->count(); $res['total'] = Db::name('property_admin')->alias('pa')->where($where)->count();
$data = Db::name('property_admin')->alias('pa')->join('ruer_property_role pr','pa.role_id = pr.role_id')->where($where) $data = Db::name('property_admin')->alias('pa')->join('ruer_property_role pr','pa.role_id = pr.role_id')->where($where)
->page($page,config('app.limit')) ->page($page,config('app.limit'))
->field("pa.property_id,pa.property_admin_id,pa.account,pa.status,pa.phone,pr.name,pa.type,pa.role_id,pa.create_time") ->field("pa.property_id,pa.property_admin_id,pa.account,pa.status,pa.phone,pa.name,pa.type,pa.role_id,pa.create_time")
->select()->toArray(); ->select()->toArray();
$res['data'] = Common::changeField($data); $res['data'] = Common::changeField($data);
...@@ -75,7 +72,7 @@ class Admin extends Base ...@@ -75,7 +72,7 @@ class Admin extends Base
$property_admin_id = Request::param('property_admin_id'); $property_admin_id = Request::param('property_admin_id');
$where['property_admin_id'] = $property_admin_id; $where['property_admin_id'] = $property_admin_id;
$data = Db::name('property_admin')->alias('pa')->join('ruer_property_role pr','pa.role_id = pr.role_id')->where($where) $data = Db::name('property_admin')->alias('pa')->join('ruer_property_role pr','pa.role_id = pr.role_id')->where($where)
->field("pa.property_id,pa.property_admin_id,pa.account,pa.status,pa.phone,pr.name,pr.url_ids,pa.type,pa.role_id,pa.create_time") ->field("pa.property_id,pa.property_admin_id,pa.account,pa.status,pa.phone,pa.name,pr.name as role_name,pr.url_ids,pa.type,pa.role_id,pa.create_time")
->find(); ->find();
if($data) { if($data) {
$allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id")->select()->toArray(); $allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id")->select()->toArray();
...@@ -102,6 +99,7 @@ class Admin extends Base ...@@ -102,6 +99,7 @@ class Admin extends Base
if($role_id){ if($role_id){
$opation = Db::name('property_role')->where(['role_id'=>$role_id])->save($data); $opation = Db::name('property_role')->where(['role_id'=>$role_id])->save($data);
} else{ } else{
$data['create_time'] = time();
$opation = Db::name('property_role')->insert($data); $opation = Db::name('property_role')->insert($data);
} }
...@@ -137,7 +135,7 @@ class Admin extends Base ...@@ -137,7 +135,7 @@ class Admin extends Base
$total = Db::name('property_role')->where($where)->count(); $total = Db::name('property_role')->where($where)->count();
$res['total'] = $total; $res['total'] = $total;
$res['data'] = $data; $res['data'] = Common::changeField($data);
return $this->returnJson($res,'success'); return $this->returnJson($res,'success');
} }
...@@ -149,7 +147,7 @@ class Admin extends Base ...@@ -149,7 +147,7 @@ class Admin extends Base
$data = Db::name('property_role')->where($where)->find(); $data = Db::name('property_role')->where($where)->find();
$data = Common::changeField($data); $data = Common::changeField($data);
$allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id")->select()->toArray(); $allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id")->select()->toArray();
$res = Common::changeNav($data['url_ids'],$allNav,$data['type']); $res = Common::changeNav($data['url_ids'],$allNav);
$data['url_ids'] = $this->getTree($res,0,'property_nav_id'); $data['url_ids'] = $this->getTree($res,0,'property_nav_id');
return $this->returnJson($data,'success'); return $this->returnJson($data,'success');
...@@ -169,10 +167,10 @@ class Admin extends Base ...@@ -169,10 +167,10 @@ class Admin extends Base
$where['admin.status'] = 1; $where['admin.status'] = 1;
$data = Db::name('property_admin')->alias('admin')->leftJoin('property_role ar','ar.role_id = admin.role_id')->where($where)->field('admin.*,ar.url_ids')->find(); $data = Db::name('property_admin')->alias('admin')->leftJoin('property_role ar','ar.role_id = admin.role_id')->where($where)->field('admin.*,ar.url_ids')->find();
$allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id")->where(['property_nav_status'=>1])->select()->toArray(); $allNav = Db::name('property_nav')->field("property_nav_id,url,url_name,property_nav_status,parent_id,icon")->where(['property_nav_status'=>1])->select()->toArray();
$urlsArr = explode(",",$data['url_ids']); $urlsArr = explode(",",$data['url_ids']);
if(!$data['type'] ==1 ) { if($data['type'] !=1 ) {
foreach($allNav as $k => $v) { foreach($allNav as $k => $v) {
if(!in_array($v['property_nav_id'],$urlsArr)){ if(!in_array($v['property_nav_id'],$urlsArr)){
unset($allNav[$k]); unset($allNav[$k]);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace app\wuye\controller; namespace app\wuye\controller;
use app\admin\controller\Base;
use app\admin\controller\Common; use app\admin\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
...@@ -90,32 +90,15 @@ class Index extends Base ...@@ -90,32 +90,15 @@ class Index extends Base
} }
//该物业下的小区列表 //该物业下的小区列表
public function villageList() { public function villageList() {
$page = Request::param("page",1);
$uid = $this->uid; $where[] = ['ca.type','=',1];
//查看是否是超级管理员 $where[] = ['hv.property_id','=',Request::param("property_id")];
$adminInfo = Db::name('property_admin')->where(['property_admin_id'=>$uid])->find(); $count = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')->where($where)->count();
if($adminInfo['type'] == 1) { //超级管理员能访问所有小区 $data = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')
$page = Request::param("page",1); ->where($where)
$where[] = ['ca.type','=',1]; ->page($page,config("app.limit"))
$where[] = ['hv.property_id','=',Request::param("property_id")]; ->field("hv.*,ca.account,ca.status as status_admin,ca.phone")
$count = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')->where($where)->count(); ->select()->toArray();
$data = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')
->where($where)
->page($page,config("app.limit"))
->field("hv.*,ca.account,ca.status as status_admin,ca.phone")
->select()->toArray();
} else {
$where[] = ['hv.property_id','=',Request::param("property_id")];
$where[] = ['ca.type','=',1];
$count = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')->where($where)
->whereIn('hv.village_id',$adminInfo['village_ids'])->count();
$data = Db::name('house_village')->alias("hv")->join('ruer_community_admin ca','ca.community_admin_id = hv.community_admin_id')
->where($where)
->whereIn('hv.village_id',$adminInfo['village_ids'])
->field("hv.*,ca.account,ca.status as status_admin,ca.phone")
->select()->toArray();
}
$res['total'] = $count; $res['total'] = $count;
$res['data'] =Common::changeField($data); $res['data'] =Common::changeField($data);
return $this->returnJson($res,'success'); return $this->returnJson($res,'success');
......
...@@ -16,8 +16,8 @@ class Login extends \app\BaseController ...@@ -16,8 +16,8 @@ class Login extends \app\BaseController
$userInfo = Db::name('property_admin')->alias("pad")->leftJoin('ruer_property_role','ruer_property_role.role_id = pad.role_id')->where($where)->field("pad.property_id,pad.property_admin_id,pad.account,ruer_property_role.name,pad.type,ruer_property_role.url_ids")->find(); $userInfo = Db::name('property_admin')->alias("pad")->leftJoin('ruer_property_role','ruer_property_role.role_id = pad.role_id')->where($where)->field("pad.property_id,pad.property_admin_id,pad.account,ruer_property_role.name,pad.type,ruer_property_role.url_ids")->find();
if($userInfo){ if($userInfo){
//判断物业公司装填 //判断物业公司装填
$status = DB::name('house_property')->where(['property_id'=>$userInfo['property_id']])->value('status'); $propertyInfo = DB::name('house_property')->where(['property_id'=>$userInfo['property_id']])->field('status,property_name')->find();
if($status != 1) { if($propertyInfo['status'] != 1) {
return $this->returnJson([],'物业公司不存在或被禁用!',400); return $this->returnJson([],'物业公司不存在或被禁用!',400);
} }
//把jwt放入redis缓存中 //把jwt放入redis缓存中
...@@ -37,6 +37,7 @@ class Login extends \app\BaseController ...@@ -37,6 +37,7 @@ class Login extends \app\BaseController
} }
$navs = $this->getTree($res,0,"property_nav_id"); $navs = $this->getTree($res,0,"property_nav_id");
$userInfo['urls_id'] =$navs; $userInfo['urls_id'] =$navs;
$userInfo['property_name'] = $propertyInfo['property_name'];
return $this->returnJson(['token'=>$jwt,'adminInfo'=>$userInfo],'success'); return $this->returnJson(['token'=>$jwt,'adminInfo'=>$userInfo],'success');
} else { } else {
return $this->returnJson([],'用户不存在!',400); return $this->returnJson([],'用户不存在!',400);
......
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
namespace app\wuye\controller; namespace app\wuye\controller;
use app\admin\controller\Base;
use app\admin\controller\Common;
use think\facade\Db; use think\facade\Db;
use think\facade\Request; use think\facade\Request;
...@@ -56,6 +57,53 @@ class Property extends Base ...@@ -56,6 +57,53 @@ class Property extends Base
} }
//查看单个物业公司详情
public function detailProperty() {
$where['hp.property_id'] = Request::param('property_id');
$data = Db::name('house_property')->alias("hp")->join('property_admin pa','pa.property_admin_id = hp.property_admin_id')
->where($where)
->field("hp.*,pa.account,pa.status as status_admin")
->find();
$data = Common::changeField($data);
return $this->returnJson($data,'success');
}
//修改物业公司基本信息
public function changeProperty() {
$property_id = Request::param("property_id");
$data['property_name']= Request::param("property_name");
$data['property_phone'] = $save['phone']= Request::param("property_phone");
$data['property_address'] = Request::param("property_address");
$data['province_name'] = Request::param("province_name");
$data['province_id'] = Request::param("province_id");
$data['city_name'] = Request::param("city_name");
$data['city_id'] = Request::param("city_id");
$data['area_name'] = Request::param("area_name");
$data['area_id'] = Request::param("area_id");
$data['account_name'] = Request::param("account_name");
$data['account_account'] = Request::param("account_account");
$data['account_username'] = Request::param("account_username");
$save['account'] = Request::param("account");
$save['create_time'] = $data['create_time'] = time();
$save['name'] = Request::param("name");
if(Request::param("password")){
$save['password'] = md5(Request::param("password"));
}
$where['property_id'] = $property_id;
$op = Db::name('house_property')->where($where)->save($data);
$property_admin_id = Db::name('house_property')->where($where)->value("property_admin_id");
$op1 = Db::name('property_admin')->where(['property_admin_id'=>$property_admin_id])->save($save);
if($op || $op1) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'error',400);
}
}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6873841ab4ee77dfd59242ef3fbc5190", "content-hash": "ce8a522de5ef11aada5055f1eff148c5",
"packages": [ "packages": [
{ {
"name": "firebase/php-jwt", "name": "firebase/php-jwt",
...@@ -269,6 +269,75 @@ ...@@ -269,6 +269,75 @@
], ],
"time": "2020-10-18T11:50:25+00:00" "time": "2020-10-18T11:50:25+00:00"
}, },
{
"name": "phpoffice/phpexcel",
"version": "1.8.2",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PHPExcel.git",
"reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870",
"reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-mbstring": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"php": "^5.2|^7.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.*"
},
"type": "library",
"autoload": {
"psr-0": {
"PHPExcel": "Classes/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-2.1"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "http://blog.maartenballiauw.be"
},
{
"name": "Erik Tilt"
},
{
"name": "Franck Lefevre",
"homepage": "http://rootslabs.net"
},
{
"name": "Mark Baker",
"homepage": "http://markbakeruk.net"
}
],
"description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PHPExcel",
"keywords": [
"OpenXML",
"excel",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"abandoned": "phpoffice/phpspreadsheet",
"time": "2018-11-22T23:07:24+00:00"
},
{ {
"name": "psr/cache", "name": "psr/cache",
"version": "1.0.1", "version": "1.0.1",
......
...@@ -7,15 +7,15 @@ return [ ...@@ -7,15 +7,15 @@ return [
'disks' => [ 'disks' => [
'local' => [ 'local' => [
'type' => 'local', 'type' => 'local',
'root' => app()->getRuntimePath() . 'storage', 'root' => app()->getRootPath() . 'public/upload',
], ],
'public' => [ 'public' => [
// 磁盘类型 // 磁盘类型
'type' => 'local', 'type' => 'local',
// 磁盘路径 // 磁盘路径
'root' => app()->getRootPath() . 'public/storage', 'root' => app()->getRootPath() . 'public/upload',
// 磁盘路径对应的外部URL路径 // 磁盘路径对应的外部URL路径
'url' => '/storage', 'url' => '/upload',
// 可见性 // 可见性
'visibility' => 'public', 'visibility' => 'public',
], ],
......
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