Commit 64f679eb authored by 蔡闯's avatar 蔡闯

2021-1-6

parent 8e6df942
...@@ -3,3 +3,4 @@ ...@@ -3,3 +3,4 @@
/vendor /vendor
*.log *.log
.env .env
/public/upload
\ No newline at end of file
...@@ -14,6 +14,13 @@ use think\Validate; ...@@ -14,6 +14,13 @@ use think\Validate;
abstract class BaseController abstract class BaseController
{ {
protected $convertArr = [
"water" => '水费',
"property" => '物业费',
"electric" => '电费',
"gas" => '燃气费',
"parking" => '停车费'
];
/** /**
* Request实例 * Request实例
* @var \think\Request * @var \think\Request
......
...@@ -11,6 +11,7 @@ class Index extends Base ...@@ -11,6 +11,7 @@ class Index extends Base
{ {
public function index() { public function index() {
return "这是我请求的内容"; return "这是我请求的内容";
} }
...@@ -78,4 +79,19 @@ class Index extends Base ...@@ -78,4 +79,19 @@ class Index extends Base
} }
//常用电话
public function commonPhone() {
$village_id = Request::param('village_id');
$where['village_id'] = $village_id;
$where['status'] = 1;
$data = Db::name('village_phone')->where($where)->order(['is_on_call_phone'=>'desc','sort'=>'desc'])->select()->toArray();
return $this->returnJson($data);
}
} }
\ No newline at end of file
...@@ -4,14 +4,185 @@ ...@@ -4,14 +4,185 @@
namespace app\api\controller; namespace app\api\controller;
use app\common\controller\Common;
use app\common\model\db\Config;
use think\facade\Db;
use think\facade\Request;
class PayOrder extends Base class PayOrder extends Base
{ {
//查看当前房间下的未缴费的水电物业等 //查看当前房间下的未缴费的水电物业等,只有业主才能看到记录
public function unPyaList() { public function payList() {
$convertArr = $this->convertArr;
$vacancy_id = Request::param('vacancy_id');
$uid = $this->uid;
$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([]);
}
$where['vacancy_id'] = $vacancy_id;
$where['is_pay'] = $isPay;
$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'] ;
}
$total = Db::name('cost')->where($where)->count();
$res['total'] = $total;
$res['data'] = Common::changeField($data);
return $this->returnJson($res);
}
//生成订单
public function createOrder(){
$vacancy_id = Request::param('vacancy_id');
$bind_id = Request::param('bind_id');
$cost_ids = Request::param('cost_ids');
$total_money = Request::param('total_money',0);
//验证物业费订单是否是连续的
$where['type'] = 'property';
$where['is_pay'] = 0;
$where['vacancy_id'] = $vacancy_id;
$property_cost_ids = Db::name('cost')->where($where)->whereIn('cost_id',$cost_ids)->column('cost_id'); //上传的未缴物业费的连续cost_id
$limit = count($property_cost_ids);
$cost_property_ids = Db::name('cost')->where($where)->limit($limit)->column('cost_id');
if($cost_property_ids != $property_cost_ids) {
return $this->returnJson([],'物业费缴费必须连续!');
}
//判断金额是否一致
unset($where['type']);
$total = Db::name('cost')->where($where)->whereIn('cost_id',$cost_ids)->sum('pay_money');
if($total != $total_money) {
return $this->returnJson([],'支付金额不正确!',400);
}
$data['uid'] = $this->uid;
if(count($cost_ids)>1){
$data['order_type'] = "多订单收费";
} else {
$type =Db::name('cost')->whereIn('cost_id',$cost_ids)->value('type');
$data['order_type'] = $type;
}
$data['order_name'] = "社区收费";
$data['order_num'] = createOrderNum();
$data['vacancy_id'] = $vacancy_id;
$res = $this->getProperty($data['vacancy_id']);
if($res['code'] !=200){
return $this->returnJson([],$res['data'],400);
}
$data['property_id'] =$res['data']['property_id'];
$data['village_id'] =$res['data']['village_id'];
$data['bind_id'] = $bind_id;
$data['money'] = $total;
$data['create_time'] = time();
$data['cost_ids'] = json_encode($cost_ids);
$data['money'] = $total;
$order_id = Db::name('pay_order')->insertGetId($data);
if($order_id) {
unset($res);
$res['order_id'] = $order_id;
return $this->returnJson($res);
} else{
return $this->returnJson([],'添加失败!',400);
}
}
//根据房间id获取当前的物业id和小区id
public function getProperty($vacancy_id) {
$data = Db::name('house_vacancy')->alias('hv')->leftJoin('house_village hvi','hvi.village_id = hv.village_id')->where(['hv.vacancy_id'=>$vacancy_id])->field('hvi.village_id,hvi.property_id')->find();
if($data){
return ['code'=>200,'data'=>$data];
} else {
return ['code'=>400,'data'=>'数据错误!'];
} }
}
//生成支付参数
public function createPaySign() {
$order_id = Request::param('order_id');
$total_money = Request::param('total_money');
$vacancy_id = Request::param('vacancy_id');
$pay_type = Request::param('pay_type','alipay'); //weixin|alipay
if(empty($order_id)) {
return $this->returnJson([],'订单未找到!',400);
}
if($this->checkOrder($order_id,$total_money,$vacancy_id)){
$orderInfo = Db::name('pay_order')->where(['order_id'=>$order_id])->find();
//支付宝支付
if($pay_type =='alipay') {
$param['out_trade_no'] = $orderInfo['order_num'];
$param['subject'] = $orderInfo['order_name'];
$param['total_amount'] = floatval($orderInfo['money']);
$res= $this->getAliPaySign($param);
//微信支付
} else {
$param['order_id'] = $orderInfo['order_id'];
$param['total_money'] = $orderInfo['money'];
$param['order_name'] = $orderInfo['order_name'];
$param['order_num'] = $orderInfo['order_num'];
$res= $this->getWeiXinPaySign($param);
}
return $this->returnJson($res);
} else {
return $this->returnJson([],'非法的订单信息!',400);
}
}
//获取支付宝支付参数
public function getAliPaySign($param) {
require_once "../extend/aliPay/AopClient.php";
require_once "../extend/aliPay/request/AlipayTradeAppPayRequest.php";
$aop = new \AopClient();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = config('app.pay_alipay_appid');
$aop->rsaPrivateKey = config('app.pay_alipay_merchant_private_key');
$aop->alipayrsaPublicKey = config('app.pay_alipay_public_key');
$aop->apiVersion = '1.0';
$aop->signType = config('app.pay_alipay_sign_type');
$aop->postCharset = 'utf-8';
$aop->format = 'json';
$request = new \AlipayTradeAppPayRequest();
$request->setNotifyUrl(config('app.notifyurl'));
$request->setBizContent(json_encode($param));
$response = $aop->sdkExecute($request);
return $response;
}
//获取微信支付参数
public function getWeiXinPaySign($param) {
require_once "../extend/weixin/Weixin.php";
$configArr = config('app.weixinPay');
$configArr['notifyurl'] = config('app.notifyurl');
$weixin = new \Weixin($param,$configArr);
return $weixin->pay();
}
//检查订单是否合法
public function checkOrder($order_id,$total_money,$vacancy_id) {
$where['order_id'] = $order_id;
$where['uid'] = $this->uid;
$where['vacancy_id'] = $vacancy_id;
$money = Db::name('pay_order')->where($where)->value('money');
if($money != $total_money) {
return false;
}
return true;
}
......
<?php
namespace app\api\controller;
use app\BaseController;
class PayReturn extends BaseController
{
//支付成功后的异步通知地址
public function payReturn() {
}
}
\ No newline at end of file
...@@ -41,7 +41,6 @@ class User extends Base ...@@ -41,7 +41,6 @@ class User extends Base
$new_password = md5(Request::param('new_password')); $new_password = md5(Request::param('new_password'));
$code = Request::param('code'); $code = Request::param('code');
$phone = Request::param('phone'); $phone = Request::param('phone');
if($code){ if($code){
if(Common::rightCode($phone,$code)){ if(Common::rightCode($phone,$code)){
$change = Db::name('user')->where(['uid'=>$this->uid,'phone'=>$phone])->save(['password'=>$new_password]); $change = Db::name('user')->where(['uid'=>$this->uid,'phone'=>$phone])->save(['password'=>$new_password]);
......
...@@ -113,6 +113,43 @@ function isPhoneNo($phone){ ...@@ -113,6 +113,43 @@ function isPhoneNo($phone){
} }
//图片上传 //图片上传
function uploadImgs($up_dir,$base64_img,$imgName="") {
$up_root_dir = getcwd().$up_dir; //获取绝对路径
if(!file_exists($up_root_dir)){
mkdir($up_root_dir,0777);
}
if(!$base64_img){
return ['code'=>400,'msg'=>'图片数据未传递!'];
}
if(preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_img, $result)){
$type = $result[2];
if(in_array($type,array('pjpeg','jpeg','jpg','gif','bmp','png'))){
if(!$imgName){
$img_name = date('YmdHis');
}
$new_file = $up_root_dir.$img_name.".".$type;
if(file_put_contents($new_file, base64_decode(str_replace($result[1], '', $base64_img)))){
if(isHTTPS()){
$http = "https://";
} else {
$http = "http://";
}
return ['code'=>200,'msg'=>$http.$_SERVER['SERVER_NAME'].$up_dir.$img_name.'.'.$type];
}else{
return ['code'=>400,'msg'=>'图片上传错误!'];
}
}else{
//文件类型错误
return ['code'=>400,'msg'=>'图片上传类型错误!'];
}
}else{
//文件错误
return ['code'=>400,'msg'=>'文件错误!'];
}
}
//文件下载 //文件下载
function downloadFile($file,$file_name) { function downloadFile($file,$file_name) {
...@@ -127,6 +164,7 @@ function downloadFile($file,$file_name) { ...@@ -127,6 +164,7 @@ function downloadFile($file,$file_name) {
//取得文件大小 //取得文件大小
$file_Size=filesize($file); $file_Size=filesize($file);
header("Content-type:application/octet-stream"); header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes"); header("Accept-Ranges:bytes");
header("Accept-Length:".$file_Size); header("Accept-Length:".$file_Size);
...@@ -154,6 +192,48 @@ function createPhoneCode($length) { ...@@ -154,6 +192,48 @@ function createPhoneCode($length) {
return substr(str_shuffle("012345678901234567890123456789"), 0, $length);; return substr(str_shuffle("012345678901234567890123456789"), 0, $length);;
} }
//生成订单编号
function createOrderNum(){
return date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
}
function get_client_ip($type = 0) {
$type = $type ? 1 : 0;
static $ip = NULL;
if ($ip !== NULL) return $ip[$type];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$pos = array_search('unknown',$arr);
if(false !== $pos) unset($arr[$pos]);
$ip = trim($arr[0]);
}elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
}
// IP地址合法验证
$long = sprintf("%u",ip2long($ip));
$ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
return $ip[$type];
}
function isHTTPS()
{
if (defined('HTTPS') && HTTPS) return true;
if (!isset($_SERVER)) return FALSE;
if (!isset($_SERVER['HTTPS'])) return FALSE;
if ($_SERVER['HTTPS'] === 1) { //Apache
return TRUE;
} elseif ($_SERVER['HTTPS'] === 'on') { //IIS
return TRUE;
} elseif ($_SERVER['SERVER_PORT'] == 443) { //其他
return TRUE;
}
return FALSE;
}
......
This diff is collapsed.
...@@ -153,6 +153,7 @@ class Build extends Base ...@@ -153,6 +153,7 @@ class Build extends Base
$data['electric_price'] = $where['electric_price'] = Request::param('electric_price'); $data['electric_price'] = $where['electric_price'] = Request::param('electric_price');
$data['gas_price'] = $where['gas_price'] = Request::param('gas_price'); $data['gas_price'] = $where['gas_price'] = Request::param('gas_price');
$data['parking_price'] = $where['parking_price'] = Request::param('parking_price'); $data['parking_price'] = $where['parking_price'] = Request::param('parking_price');
$data['parent_id'] = $buildInfo['parent_id'];
$is_inherit = Request::param('is_inherit',1); //物业费等是否继承上一级,1继承,0不继承 $is_inherit = Request::param('is_inherit',1); //物业费等是否继承上一级,1继承,0不继承
...@@ -177,7 +178,6 @@ class Build extends Base ...@@ -177,7 +178,6 @@ class Build extends Base
$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);
if($change) { if($change) {
return $this->returnJson([],'success'); return $this->returnJson([],'success');
} else{ } else{
...@@ -243,6 +243,28 @@ class Build extends Base ...@@ -243,6 +243,28 @@ class Build extends Base
} }
//根据建筑id获取同一级的建筑
public function getCurrent() {
$build_id = Request::param('build_id');
$layoutInfo = Db::name('layout_build')->alias('lb')
->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')
->where(['layout_build_id'=>$build_id])
->field('lb.level,lb.code,lb.layout_build_id,lb.layout_id,lb.village_id,ll.code as ll_code')->find();
$where['layout_id'] = $layoutInfo['layout_id'];
$where['village_id'] = $layoutInfo['village_id'];
$where['level'] = $layoutInfo['level'];
$data = Db::name('layout_build')->where($where)->field('layout_build_id,layout_id,code,level')->select()->toArray();
if($layoutInfo){
$res['code_name'] = explode('-',$layoutInfo['ll_code'])[$layoutInfo['level']-1];
} else {
$res['code_name'] ='';
}
$res['data'] = $data;
return $this->returnJson($res);
}
//查看社区的水电物业费等 //查看社区的水电物业费等
public function costPrice() { public function costPrice() {
...@@ -257,7 +279,7 @@ class Build extends Base ...@@ -257,7 +279,7 @@ class Build extends Base
$where['lb.layout_build_id'] = Request::param('layout_build_id');//建筑id $where['lb.layout_build_id'] = Request::param('layout_build_id');//建筑id
$where['lb.village_id'] = $this->village_id; $where['lb.village_id'] = $this->village_id;
$res = Db::name('layout_build')->alias('lb')->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')->where($where) $res = Db::name('layout_build')->alias('lb')->leftJoin('layout_list ll','ll.layout_id = lb.layout_id')->where($where)
->field('lb.layout_build_id,lb.layout_build_id,lb.property_price,lb.water_price,lb.electric_price,lb.gas_price,lb.parking_price,lb.code,lb.explain,lb.parent_id,lb.create_time,lb.measure_area,lb.address,lb.sort_id,ll.code as code_name, ll.name') ->field('lb.is_inherit,lb.layout_build_id,lb.layout_build_id,lb.property_price,lb.water_price,lb.electric_price,lb.gas_price,lb.parking_price,lb.code,lb.explain,lb.parent_id,lb.create_time,lb.measure_area,lb.address,lb.sort_id,ll.code as code_name, ll.name')
->find(); ->find();
$data = Common::changeField($res); $data = Common::changeField($res);
return $this->returnJson($data,'success'); return $this->returnJson($data,'success');
......
...@@ -22,6 +22,7 @@ class Device extends Base ...@@ -22,6 +22,7 @@ class Device extends Base
$data['device_sn'] = Request::param('device_sn'); $data['device_sn'] = Request::param('device_sn');
$data['village_id'] = $this->village_id; $data['village_id'] = $this->village_id;
$data['build_id'] = Request::param('build_id'); $data['build_id'] = Request::param('build_id');
$data['build_code'] = Request::param('build_code');
$data['device_direction'] = Request::param('device_direction'); $data['device_direction'] = Request::param('device_direction');
$data['device_platform'] = Request::param('device_platform'); $data['device_platform'] = Request::param('device_platform');
...@@ -58,12 +59,19 @@ class Device extends Base ...@@ -58,12 +59,19 @@ class Device extends Base
$page = Request::param('page',1); $page = Request::param('page',1);
$total = Db::name('house_face_device')->where($where)->count(); $total = Db::name('house_face_device')->where($where)->count();
$data = Db::name('house_face_device')->alias('hfd')->where($where)->order('create_time','desc') $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') ->field('hfd.device_id,hfd.build_code,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(); ->page($page,config('app.limit'))->select()->toArray();
$res['total'] = $total; $res['total'] = $total;
$res['data'] = Common::changeField($data); $res['data'] = Common::changeField($data);
return $this->returnJson($res,'success'); return $this->returnJson($res,'success');
} }
//获取设备详情
public function detailDevice(){
$where['device_id'] = Request::param('device_id');
$data = Db::name('house_face_device')->where($where)->find();
return $this->returnJson($data);
}
} }
\ No newline at end of file
...@@ -129,4 +129,38 @@ class News extends Base ...@@ -129,4 +129,38 @@ class News extends Base
} }
//图片上传
public function uploadImgBase64() {
$dir = "/upload/village/".$this->village_id."/";
$base_img = Request::param('base_img');
$res = uploadImgs($dir,$base_img);
if($res['code']==200){
$data['data'] = $res['msg'];
return $this->returnJson($data);
} else {
return $this->returnJson([],$res['msg'],400);
}
}
//excel文件上传
public function uploadImg() {
$file = request()->file('img');
$ext = $file->getOriginalExtension();
if(!in_array($ext,['pjpeg','jpeg','jpg','gif','bmp','png'])) {
return $this->returnJson([],'请上传图片文件',400);
}
$savename = \think\facade\Filesystem::putFile('', $file,'datea');
if(isHTTPS()){
$http = "https://";
} else {
$http = "http://";
}
$data['data'] = $http.$_SERVER['SERVER_NAME']."/upload/".$savename;
file_put_contents('./log.txt',$http.$_SERVER['SERVER_NAME']."/upload/".$savename);
return $this->returnJson($data,'success');
}
} }
\ No newline at end of file
...@@ -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;
...@@ -49,4 +49,48 @@ class Order extends Base ...@@ -49,4 +49,48 @@ class Order extends Base
} }
//下载水费模板
public function downloadImportWater(){
$file_path = "./formwork/importWater.xls";
downloadFile($file_path,"每月水费导入.xls");
}
//批量导入费用
public function importCost() {
$filePath = Request::param('filePath');
$type = Request::param('type');
if(!in_array($type,['water','gas','electric'])) {
return $this->returnJson([],'type类型不正确!',400);
}
if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400);
}
$village_id = $this->village_id ?? 1;
$res = Common::importCost($filePath,$village_id,$type);
if($res['code']==200) {
return $this->returnJson([],'success');
}
}
//下载电费模板
public function downloadImportElectric(){
$file_path = "./formwork/importElectric.xls";
downloadFile($file_path,"每月电费导入.xls");
}
//下载燃气费模板
public function downloadImportGas(){
$file_path = "./formwork/importGas.xls";
downloadFile($file_path,"每月燃气费导入.xls");
}
} }
\ No newline at end of file
...@@ -11,10 +11,10 @@ use think\facade\Request; ...@@ -11,10 +11,10 @@ use think\facade\Request;
class Parking extends Base class Parking extends Base
{ {
//protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class']; protected $middleware = ['app\middleware\CommunityLoginCheck::class','app\middleware\CommunityAfter::class'];
//添加车位区块 //添加车
public function createParkArea() { public function createParkArea() {
$park_block_id = Request::param('park_block_id'); $park_block_id = Request::param('park_block_id');
$data['village_id'] = $this->village_id; $data['village_id'] = $this->village_id;
...@@ -36,7 +36,7 @@ class Parking extends Base ...@@ -36,7 +36,7 @@ class Parking extends Base
} }
} }
//删除车位区块 //删除车
public function deleteParkArea() { public function deleteParkArea() {
$where['village_id'] = $this->village_id; $where['village_id'] = $this->village_id;
$where['park_block_id'] = Request::param('park_block_id'); $where['park_block_id'] = Request::param('park_block_id');
...@@ -54,7 +54,7 @@ class Parking extends Base ...@@ -54,7 +54,7 @@ class Parking extends Base
} }
//车位区域列表 //车列表
public function parkAreaList() { public function parkAreaList() {
$page= Request::param('page',1); $page= Request::param('page',1);
$where['village_id'] = $this->village_id; $where['village_id'] = $this->village_id;
...@@ -65,7 +65,7 @@ class Parking extends Base ...@@ -65,7 +65,7 @@ class Parking extends Base
} }
//添加车位 //添加|修改车位
public function createCarArea() { public function createCarArea() {
$park_car_id = Request::param('park_car_id'); $park_car_id = Request::param('park_car_id');
$data['park_block_id'] = Request::param('park_block_id'); $data['park_block_id'] = Request::param('park_block_id');
...@@ -76,6 +76,7 @@ class Parking extends Base ...@@ -76,6 +76,7 @@ class Parking extends Base
} }
$data['park_code'] = Request::param('park_code'); $data['park_code'] = Request::param('park_code');
$data['sort_id'] = Request::param('sort_id'); $data['sort_id'] = Request::param('sort_id');
$data['type'] = Request::param('type',1);
$data['explain'] = Request::param('explain'); $data['explain'] = Request::param('explain');
$data['village_id'] = $this->village_id; $data['village_id'] = $this->village_id;
...@@ -97,7 +98,7 @@ class Parking extends Base ...@@ -97,7 +98,7 @@ class Parking extends Base
$data['create_time'] = time(); $data['create_time'] = time();
$operation = Db::name('park_car')->insertGetId($data); $operation = Db::name('park_car')->insertGetId($data);
//更新房间表 //更新房间表
if($data['vacancy_id']) { if(isset($data['vacancy_id'])) {
Db::name('house_vacancy')->where(['vacancy_id'=>$data['village_id']])->save(['park_car_id'=>$operation]); Db::name('house_vacancy')->where(['vacancy_id'=>$data['village_id']])->save(['park_car_id'=>$operation]);
} }
} }
...@@ -149,7 +150,7 @@ class Parking extends Base ...@@ -149,7 +150,7 @@ class Parking extends Base
} }
$total = Db::name('park_car')->alias('pc')->leftJoin('house_vacancy hv','hv.vacancy_id = pc.vacancy_id')->where($where)->count(); $total = Db::name('park_car')->alias('pc')->leftJoin('house_vacancy hv','hv.vacancy_id = pc.vacancy_id')->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');
} }
...@@ -161,7 +162,7 @@ class Parking extends Base ...@@ -161,7 +162,7 @@ class Parking extends Base
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name'); $optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库 $optionsString = implode(',',$optionsArr);//这个是的车库
if($optionsString){ if($optionsString){
for($i=2;$i<200;$i++) { for($i=2;$i<3;$i++) {
$phpExcel->getActiveSheet()->getCell('B'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST) $phpExcel->getActiveSheet()->getCell('B'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION) -> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false) -> setAllowBlank(false)
...@@ -172,6 +173,17 @@ class Parking extends Base ...@@ -172,6 +173,17 @@ class Parking extends Base
-> setError('您输入的值不在下拉框列表内.') -> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('车库') -> setPromptTitle('车库')
-> setFormula1('"'.$optionsString.'"');; //这一句为要设置数据有效性的单元格 -> setFormula1('"'.$optionsString.'"');; //这一句为要设置数据有效性的单元格
$phpExcel->getActiveSheet()->getCell('C'.$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('"机动车位,非机动车位"');; //这一句为要设置数据有效性的单元格
} }
} }
...@@ -185,7 +197,7 @@ class Parking extends Base ...@@ -185,7 +197,7 @@ class Parking extends Base
//批量导入车位 //批量导入车位
public function importCarPark() { public function importCarPark() {
$filePath = Request::param('filePath'); $filePath = Request::param('filePath');
$filePath = "./车位导入.xls";
if(!file_exists($filePath)){ if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400); return $this->returnJson([],'文件不存在!',400);
} }
...@@ -201,17 +213,13 @@ class Parking extends Base ...@@ -201,17 +213,13 @@ class Parking extends Base
//添加|修改车辆 //添加|修改车辆
public function createCar() { public function createCar() {
$car_id = Request::param('car_id'); $car_id = Request::param('car_id');
$data['park_block_id'] = Request::param('park_block_id');
$data['park_code'] = Request::param('park_code');
$res = $this->getParkCarId($data); //获取车位id
if($res['code'] !=200){
return $this->returnJson([],$res['msg'],400);
}
$data['park_car_id'] = $res['id'];
$data['phone'] = Request::param('phone'); $data['phone'] = Request::param('phone');
$data['end_time'] = Request::param('end_time'); $data['end_time'] = Request::param('end_time');
$data['name'] = Request::param('name'); $data['name'] = Request::param('name');
$data['brand'] = Request::param('brand');
$data['car_color'] = Request::param('car_color'); $data['car_color'] = Request::param('car_color');
$data['brand'] = Request::param('brand');
$data['license_plate'] = Request::param('license_plate'); $data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1); $data['sort_id'] = Request::param('sort_id',1);
if($car_id) { if($car_id) {
...@@ -223,6 +231,7 @@ class Parking extends Base ...@@ -223,6 +231,7 @@ class Parking extends Base
$operation = Db::name('car')->where(['car_id'=>$car_id])->save($data); $operation = Db::name('car')->where(['car_id'=>$car_id])->save($data);
} else { } else {
$data['create_time'] = time(); $data['create_time'] = time();
$data['village_id'] = $this->village_id;
//判断车牌是否存在 //判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->find(); $is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->find();
if($is_exit) { if($is_exit) {
...@@ -269,20 +278,15 @@ class Parking extends Base ...@@ -269,20 +278,15 @@ class Parking extends Base
$total = Db::name('car')->alias('car')->where($where)->count(); $total = Db::name('car')->alias('car')->where($where)->count();
$data = Db::name('car')->alias('car')->where($where)->order('sort_id','desc')->page($page,config('app.limit'))->select()->toArray(); $data = Db::name('car')->alias('car')->where($where)->order('sort_id','desc')->page($page,config('app.limit'))->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');
} }
//获取单个车辆信息 //获取单个车辆信息
public function detailCar() { public function detailCar() {
$where['car.village_id'] = $this->village_id; $where['village_id'] = $this->village_id;
$where['car.car_id'] = Request::param('car_id'); $where['car_id'] = Request::param('car_id');
$data = Db::name('car')->alias('car') $data = Db::name('car')->where($where)->find();
->leftJoin('park_car pc','pc.park_car_id = car.park_car_id')
->leftJoin('park_block pb','pb.park_block_id = car.park_block_id')
->where($where)
->field('car.*,pc.park_code,pb.name as park_block_name')
->find();
return $this->returnJson(Common::changeField($data),'success'); return $this->returnJson(Common::changeField($data),'success');
} }
...@@ -301,32 +305,8 @@ class Parking extends Base ...@@ -301,32 +305,8 @@ class Parking extends Base
//车辆导入模板下载 //车辆导入模板下载
public function downloadCar() { public function downloadCar() {
$file_dir = "./formwork/importCar.xls"; $file_path = "./formwork/importCar.xls";
$phpExcel = \PHPExcel_IOFactory::load($file_dir); downloadFile($file_path,"车辆导入.xls");
$village_id = $this->village_id??1;
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库
if($optionsString){
for($i=2;$i<200;$i++) {
$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('"'.$optionsString.'"');; //这一句为要设置数据有效性的单元格
}
}
$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");
} }
//批量导入车辆 //批量导入车辆
......
...@@ -64,10 +64,10 @@ class UserBind extends Base ...@@ -64,10 +64,10 @@ class UserBind extends Base
//业主列表| 租客列表 | 家属列表 //业主列表| 租客列表 | 家属列表
public function houseOwnerList(){ public function houseOwnerList(){
$vacancy = new Vacancy($this->app); $vacancy = new Vacancy($this->app);
$page = Request::param('page',1); $page = Request::param('page',1);
$where[] = ['hub.type','=',Request::param('type',0)]; $where[] = ['hub.type','=',Request::param('type',0)];
$where[] = ['hub.village_id','=',$this->village_id];
if(Request::param('phone')) { if(Request::param('phone')) {
$where[] = ['hub.phone','=',Request::param('phone')]; $where[] = ['hub.phone','=',Request::param('phone')];
} }
...@@ -81,8 +81,10 @@ class UserBind extends Base ...@@ -81,8 +81,10 @@ class UserBind extends Base
->where($where) ->where($where)
->order(['hub.pass_time'=>'desc','hub.status'=>'desc']) ->order(['hub.pass_time'=>'desc','hub.status'=>'desc'])
->page($page,config('app.limit')) ->page($page,config('app.limit'))
->field('hub.house_user_bind_id,hub.name,hub.phone,hub.id_card,hub.pass_time,hub.unbind_time,hv.vacancy_code,hv.layout_id') ->field('hub.house_user_bind_id,hub.name,hub.phone,hub.id_card,hub.pass_time,hub.unbind_time,hub.status,hub.type,hv.vacancy_code,hv.layout_id')
->select()->toArray(); ->select()->toArray();
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
$data[$k]['vacancy_address'] = $vacancy->getVacancyAddress($v['vacancy_code'],$v['layout_id']); $data[$k]['vacancy_address'] = $vacancy->getVacancyAddress($v['vacancy_code'],$v['layout_id']);
} }
...@@ -174,10 +176,12 @@ class UserBind extends Base ...@@ -174,10 +176,12 @@ class UserBind extends Base
return $this->returnJson([],'该身份证用户在该房间下以绑定,请勿重复绑定!',400); return $this->returnJson([],'该身份证用户在该房间下以绑定,请勿重复绑定!',400);
} }
//业主只能有一个 //业主只能有一个
if($data['type'] ==0){
$is_owner = Db::name('house_user_bind')->where(['village_id'=>$this->village_id,'vacancy_id'=>$vacancy_id,'type'=>0,'status'=>1])->find(); $is_owner = Db::name('house_user_bind')->where(['village_id'=>$this->village_id,'vacancy_id'=>$vacancy_id,'type'=>0,'status'=>1])->find();
if($is_owner) { if($is_owner) {
return $this->returnJson([],'该房间编号下以绑定业主,请先解绑!',400); return $this->returnJson([],'该房间编号下以绑定业主,请先解绑!',400);
} }
}
$add = Db::name('house_user_bind')->save($data); $add = Db::name('house_user_bind')->save($data);
if($add) { if($add) {
return $this->returnJson([],'success'); return $this->returnJson([],'success');
...@@ -245,7 +249,7 @@ class UserBind extends Base ...@@ -245,7 +249,7 @@ class UserBind extends Base
//查看用户关联到车辆 //查看用户关联到车辆
public function userCar() { public function userCar() {
$phone = Request::param("phone"); $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(); $data = Db::name('car')->where(['phone'=>$phone])->field("car_id,phone,license_plate,create_time,name,car_color,brand")->order('create_time','desc')->select()->toArray();
return $this->returnJson(Common::changeField($data),'success'); return $this->returnJson(Common::changeField($data),'success');
} }
......
This diff is collapsed.
...@@ -10,7 +10,7 @@ use think\facade\Request; ...@@ -10,7 +10,7 @@ use think\facade\Request;
class Admin extends Base class Admin extends Base
{ {
//protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class']; protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class'];
//添加或修改物业管理员 //添加或修改物业管理员
public function createAdmin() { public function createAdmin() {
$property_admin_id = Request::param('property_admin_id'); $property_admin_id = Request::param('property_admin_id');
......
...@@ -13,7 +13,7 @@ class Base extends BaseController ...@@ -13,7 +13,7 @@ class Base extends BaseController
{ {
protected $uid; //物业后台管理员管理员id protected $uid; //物业后台管理员管理员id
// protected $village_id; //小区id
protected $property_id; //物业id protected $property_id; //物业id
public function __construct(App $app) public function __construct(App $app)
......
...@@ -11,7 +11,7 @@ use think\facade\Request; ...@@ -11,7 +11,7 @@ use think\facade\Request;
class Index extends Base class Index extends Base
{ {
//protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class']; protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class'];
//添加| 修改 小区 //添加| 修改 小区
public function createCommunity() { public function createCommunity() {
......
...@@ -11,7 +11,7 @@ use think\facade\Request; ...@@ -11,7 +11,7 @@ use think\facade\Request;
class Order extends Base class Order extends Base
{ {
//protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class']; protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class'];
public function orderList() { public function orderList() {
......
...@@ -13,7 +13,7 @@ use think\facade\Request; ...@@ -13,7 +13,7 @@ use think\facade\Request;
class Property extends Base class Property extends Base
{ {
//protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class']; protected $middleware = ['app\middleware\PropertyLoginCheck::class','app\middleware\PropertyAfter::class'];
//添加|删除 物业工作人员 //添加|删除 物业工作人员
public function addWorker() { public function addWorker() {
......
...@@ -40,4 +40,30 @@ return [ ...@@ -40,4 +40,30 @@ return [
//token加密的key //token加密的key
'jwt_key' => 'zhihuishequ', 'jwt_key' => 'zhihuishequ',
//支付宝支付相关参数
'pay_alipay_sign_type'=>'RSA2',
'pay_alipay_appid'=>'2021002110635559',
'pay_alipay_open'=>'1',
//应用私钥
'pay_alipay_merchant_private_key'=>'MIIEogIBAAKCAQEAvrbXi8/ePxzFfIOcF5flf/YILuW0q7OVt+9jHZoSn/dkY6J7mYNate4tYq+QhPtBm7dKDu9WqF9nTKnwgoDBdZdDwudANDYNxBLS+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wM2T9H5z8PmodDLvPnqO1+IEqFvoSdBf4Hyy0SNaurrWrsBDPO1ei41yD2tGxwHSCMN2NvChAnyHMblzdU2OvIjnaJrNeEeD/lBmWJs2Z/I2NHkjO/zcWShIldf8UTl64vJfGQbwIDAQAB',
//微信app支付参数
'weixinPay' => [
'pay_weixin_appid'=>'wx8dbf4b4b823f34e7',
'pay_weixin_mchid'=>'1586820961',
'pay_weixin_appsecret'=>'5eb1fb7502cc2b24be7b67e9fe04870c',
'pay_weixin_key'=>'41914f15f59dc19fef30385f46eb4ce4',
],
//异步通知地址
'notifyurl' =>'http://ruer.com/api/PayReturn/payReturn',
]; ];
...@@ -28,9 +28,9 @@ return [ ...@@ -28,9 +28,9 @@ return [
// 配置Reids // 配置Reids
'redis' => [ 'redis' => [
'type' => 'redis', 'type' => 'redis',
'host' => '127.0.0.1', 'host' => env('redis.host', '127.0.0.1'),
'port' => '6379', 'port' => env('redis.port', 6379),
'password' => '', 'password' => env('redis.port', ''),
'select' => '0', 'select' => '0',
// 全局缓存有效期(0为永久有效) // 全局缓存有效期(0为永久有效)
'expire' => 0, 'expire' => 0,
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace think; namespace think;
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
header('Access-Control-Allow-Origin: *');
// 执行HTTP应用并响应 // 执行HTTP应用并响应
$http = (new App())->http; $http = (new App())->http;
......
https://localhost/upload/
\ 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