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

2021-1-6

parent 8e6df942
......@@ -2,4 +2,5 @@
/.vscode
/vendor
*.log
.env
\ No newline at end of file
.env
/public/upload
\ No newline at end of file
......@@ -14,6 +14,13 @@ use think\Validate;
abstract class BaseController
{
protected $convertArr = [
"water" => '水费',
"property" => '物业费',
"electric" => '电费',
"gas" => '燃气费',
"parking" => '停车费'
];
/**
* Request实例
* @var \think\Request
......
......@@ -11,6 +11,7 @@ class Index extends Base
{
public function index() {
return "这是我请求的内容";
}
......@@ -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,16 +4,187 @@
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
{
//查看当前房间下的未缴费的水电物业等
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;
}
}
\ No newline at end of file
<?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
$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]);
......
......@@ -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) {
......@@ -127,6 +164,7 @@ function downloadFile($file,$file_name) {
//取得文件大小
$file_Size=filesize($file);
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:".$file_Size);
......@@ -154,6 +192,48 @@ function createPhoneCode($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;
}
......
......@@ -5,6 +5,7 @@ use app\BaseController;
use think\facade\Db;
use think\facade\Request;
class Common extends BaseController
{
......@@ -30,8 +31,9 @@ class Common extends BaseController
}
//对返回的数据进行转换
public static function changeField($data,$field="create_time") {
//对数组中的时间字段进行日期转换
public static function changeField($data,$field="create_time",$format="Y-m-d H:i:s") {
$prompt = "暂无";
if(empty($data)) {
return $data;
}
......@@ -39,22 +41,34 @@ class Common extends BaseController
if(is_array($v)) {
if(is_array($field)) {
foreach ($field as $value) {
$data[$k][$value] = date('Y-m-d H:i:s',$v[$value]);
if($v[$value] != 0 || !is_null($v[$value])){
$data[$k][$value] = date($format,$v[$value]);
} else {
$data[$k][$value] = $prompt;
}
}
} else {
$data[$k][$field] = date('Y-m-d H:i:s', $v[$field]);
if($v[$field] != 0 || !is_null($v[$field])){
$data[$k][$field] = date($format,$v[$field]);
} else {
$data[$k][$field] = $prompt;
}
}
} else {
if(is_array($field)) {
foreach ($field as $value) {
if(isset($data[$value])){
$data[$value] = date('Y-m-d H:i:s',$data[$value]);
if(isset($data[$value]) || $data[$value] !=0){
$data[$value] = date($format,$data[$value]);
} else{
$data[$value] = $prompt;
}
}
break;
} else {
if(isset($data[$field])) {
$data[$field] = date('Y-m-d H:i:s', $data[$field]);
if(isset($data[$field]) || $data[$field] !=0) {
$data[$field] = date($format, $data[$field]);
} else {
$data[$field] = $prompt;
}
break;
}
......@@ -154,6 +168,7 @@ class Common extends BaseController
$sheet = $objPHPExcel->getSheet(0);
$dataAll = $objPHPExcel->getSheet(0)->toArray(); //获取导入的数据;
$highestRow = $sheet->getHighestRow(); // 取得总行数
//获取社区布局
$layout_list = Db::name('layout_list')->where($where)->column('layout_id','code');
......@@ -162,73 +177,80 @@ class Common extends BaseController
$errorData =[]; //存放导入失败的数据;
for($j=1;$j<$highestRow;$j++)
{
$msg = "";
$vacancyCode = $dataAll[$j][0]; //房间编号
$layout_list_code = $dataAll[$j][7];//布局
if($layout_list_code) {
$layout_id = $layout_list[$layout_list_code];
} else {
$msg .="社区布局未选择!";
}
$res_vacancy_code = self::getVacancyCode($vacancyCode,$layout_id);
if(!empty($dataAll[$j][0]) && !empty($dataAll[$j][1]) && !empty($dataAll[$j][2]) && !empty($dataAll[$j][3]) && !empty($dataAll[$j][4]) &&!empty($dataAll[$j][7]) &&!empty($dataAll[$j][8])){
$msg = "";
$vacancyCode = $dataAll[$j][0]; //房间编号
$layout_list_code = $dataAll[$j][7];//布局
if($layout_list_code) {
$layout_id = $layout_list[$layout_list_code];
$data['layout_id'] = $layout_id;
$res_vacancy_code = self::getVacancyCode($vacancyCode,$layout_id);
if($res_vacancy_code['code'] !=200) {
$msg .= "房间编号不正确!";
}
$vacancy_code = $res_vacancy_code['msg'];
$data['vacancy_code'] = $vacancy_code;
$parent_id = $res_vacancy_code['parent_id'];
$data['parent_id'] = $parent_id;
} else {
$msg .="社区布局未选择!";
if($res_vacancy_code['code'] !=200) {
$msg .= "房间编号不正确!";
}
$vacancy_code = $res_vacancy_code['msg'];
$parent_id = $res_vacancy_code['parent_id'];
$name = $dataAll[$j][1];//业主名字
$id_card = $dataAll[$j][2];//布局;//身份证id
if(!isCreditNo($id_card)) {
$msg .= "身份证id不符合!";
}
$phone = $dataAll[$j][3];//布局;//手机号
if(!isPhoneNo($phone)) {
$msg .="手机号不符合!";
}
}
$name = $dataAll[$j][1];//业主名字
$id_card = $dataAll[$j][2];//布局;//身份证id
if(!isCreditNo($id_card)) {
$msg .= "身份证id不符合!";
}
$phone = $dataAll[$j][3];//布局;//手机号
if(!isPhoneNo($phone)) {
$msg .="手机号不符合!";
}
$area = $dataAll[$j][4];//面积
$car_block_name = $dataAll[$j][5];//车库位置
$park_code = $dataAll[$j][6];//车位编号
if($car_block_name && $park_code) {
$park_block_id = $park_block_list[$car_block_name];
$park_car_id = Db::name('park_car')->where(['village_id'=>$village_id,'park_block_id'=>$park_block_id,'park_code'=>$park_code])->value('park_car_id');
$data['park_car_id'] = $park_car_id;
$data['park_block_id'] = $park_block_id;
}
$area = $dataAll[$j][4];//面积
$car_block_name = $dataAll[$j][5];//车库位置
$park_code = $dataAll[$j][6];//车位编号
if($car_block_name && $park_code) {
$park_block_id = $park_block_list[$car_block_name];
$park_car_id = Db::name('park_car')->where(['village_id'=>$village_id,'park_block_id'=>$park_block_id,'park_code'=>$park_code])->value('park_car_id');
}
$house_type = $dataAll[$j][8];//住宅类型
switch ($house_type) {
case "住宅" :
$type =1;
break;
case "商铺" :
$type = 2;
break;
case "办公" :
$type = 3;
break;
default :
$msg.= "住宅类型未选择!";
}
$house_type = $dataAll[$j][8];//住宅类型
switch ($house_type) {
case "住宅" :
$type =1;
break;
case "商铺" :
$type = 2;
break;
case "办公" :
$type = 3;
break;
default :
$msg.= "住宅类型未选择!";
}
$data['vacancy_code'] = $vacancy_code;
$data['layout_id'] = $layout_id;
$data['name'] = $bind['name'] = $name;
$data['id_card'] = $bind['id_card']= $id_card;
$data['phone'] = $bind['phone'] = $phone;
$data['area'] = $area;
$data['park_block_id'] = $park_block_id;
$data['park_car_id'] = $park_car_id;
$data['house_type'] = $type;
$data['create_time'] = $bind['create_time'] = $bind['pass_time']= time();
$data['village_id'] = $bind['village_id'] = $village_id;
$data['parent_id'] = $parent_id;
if(empty($msg)) { //表明没有错误
$bind['vacancy_id'] = Db::name('house_vacancy')->insertGetId($data);
//导入到userbind表中
$bind['type'] = 0;
$bind['status'] = 1;
Db::name('house_user_bind')->save($bind);
} else {
$dataAll[$j][] = $msg;
$data['name'] = $bind['name'] = $name;
$data['id_card'] = $bind['id_card']= $id_card;
$data['phone'] = $bind['phone'] = $phone;
$data['area'] = $area;
$data['house_type'] = $type;
$data['create_time'] = $bind['create_time'] = $bind['pass_time']= time();
$data['village_id'] = $bind['village_id'] = $village_id;
if(empty($msg)) { //表明没有错误
$bind['vacancy_id'] = Db::name('house_vacancy')->insertGetId($data);
//导入到userbind表中
$bind['type'] = 0;
$bind['status'] = 1;
Db::name('house_user_bind')->save($bind);
} else {
$dataAll[$j][] = $msg;
$errorData[] = $dataAll[$j];
}
}else {
$dataAll[$j][] = "数据不能为空!";
$errorData[] = $dataAll[$j];
}
}
......@@ -487,36 +509,20 @@ class Common extends BaseController
}
$license_plate = $dataAll[$i][2];
$car_color = $dataAll[$i][3];
$park_block_name = $dataAll[$i][4];
$park_code = $dataAll[$i][5];
if($park_block_name){
if($optionsArr[$park_block_name]){
$park_block_id = $optionsArr[$park_block_name];
//检测当前的车库中是否存在该车位
$is_exit = Db::name('park_car')->where(['village_id'=>$village_id,'park_block_id'=>$park_block_id,'park_code'=>$park_code])->value('park_car_id');
if(!$is_exit){
$msg.="车位不存在!";
}
}
}
$brand = $dataAll[$i][4];
$data['name'] = $name;
$data['phone'] = $phone;
$data['license_plate'] = $license_plate;
$data['car_color'] = $car_color;
$data['park_block_id'] = $park_block_id;
$data['park_code'] = $park_code;
$data['park_car_id'] = $is_exit;
$data['create_time'] = time();
$data['village_id'] = $village_id;
$data['brand'] = $brand;
if(empty($msg)){
$insertData[] = $data;
} else {
$dataAll[$i][] = $msg;
$errorData[] = $dataAll[$i];
}
}
if(!empty($insertData)){
......@@ -525,7 +531,7 @@ class Common extends BaseController
//导出错误的数据
$file = "./formwork/importCar.xls";
$phpExcel = \PHPExcel_IOFactory::load($file);
$title = ['A','B','C','D','E','F','G'];
$title = ['A','B','C','D','E','F'];
$i = 2;
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库
......@@ -560,7 +566,6 @@ class Common extends BaseController
}
//车位导入
public static function importCarPark($filePath,$village_id) {
$where['village_id'] = $village_id;
......@@ -577,14 +582,18 @@ class Common extends BaseController
$msg="";
$park_code = $dataAll[$i][0];
$park_block_name = $dataAll[$i][1];
$type_name = $dataAll[$i][2];
if($type_name == "非机动车位"){
$data['type'] =0;
}
if($park_block_name) {
$park_block_id = $optionsArr[$park_block_name];
$data['park_block_id'] = $park_block_id;
} else{
$msg.="车库必选选!";
}
$data['park_code'] = $park_code;
$data['park_block_id'] = $park_block_id;
//查询当前的车位是否已存在
$is_exit = Db::name('park_car')->where(['village_id'=>$village_id,'park_block_id'=>$park_block_id,'park_code'=>$park_code])->value('park_car_id');
......@@ -610,7 +619,7 @@ class Common extends BaseController
//导出错误的数据
$file = "./formwork/importCarPark.xls";
$phpExcel = \PHPExcel_IOFactory::load($file);
$title = ['A','B','C'];
$title = ['A','B','C','D'];
$i = 2;
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库
......@@ -645,6 +654,122 @@ class Common extends BaseController
}
}
//每月水费导入
public static function importCost($filePath,$village_id,$type){
$where['village_id'] = $village_id;
$objReader = \PHPExcel_IOFactory::createReader('Excel5');//配置成2003版本,因为office版本可以向下兼容
$objPHPExcel = $objReader->load($filePath,$encode='utf-8');//$file 为解读的excel文件
$sheet = $objPHPExcel->getSheet(0);
$dataAll = $objPHPExcel->getSheet(0)->toArray(); //获取导入的数据;
$highestRow = $sheet->getHighestRow(); // 取得总行数
$errorData =[]; //存放导入失败的数据;
$insertData = [];//存放最后需要插入到数据库的数据
for($i=1;$i<$highestRow;$i++) {
$msg="";
$vacancy_code = $dataAll[$i][0];
//判断房间号是否存在
$vacancyInfo = Db::name('house_vacancy')->alias('hv')
->leftJoin('layout_build lb','lb.layout_build_id = hv.parent_id')
->where(['hv.village_id'=>$village_id,'hv.vacancy_code'=>$vacancy_code])
->field('hv.vacancy_id,lb.water_price,lb.electric_price,lb.gas_price,hv.water_fee,hv.electric_fee,hv.gas_fee,hv.is_inherit')->find();
if($vacancyInfo) {
$data['vacancy_id'] = $vacancyInfo['vacancy_id'];
} else {
$msg.="物业编号不存在!";
}
switch ($type){
case "water":
if($vacancyInfo['is_inherit'] ==1) {
$price = $vacancyInfo['water_price'];
} else {
$price = $vacancyInfo['water_fee'];
}
$outFileName = "水费导入失败.xls";
break;
case "electric":
if($vacancyInfo['is_inherit'] ==1) {
$price = $vacancyInfo['electric_price'];
} else {
$price = $vacancyInfo['electric_fee'];
}
$outFileName = "电费导入失败.xls";
break;
case "gas":
if($vacancyInfo['is_inherit'] ==1) {
$price = $vacancyInfo['gas_price'];
} else {
$price = $vacancyInfo['gas_fee'];
}
$outFileName = "燃气费导入失败.xls";
break;
default :
$outFileName = "未知错误.xls";
return ['code'=>400,'msg'=>'小区费用未设置,请先设置费用!'];
}
//查看月份的费用是否存在
$data['cost_month'] = $dataAll[$i][1];
//判断月份是否超过了当前时间,不能导入超前月份
if(strtotime(date('Y-m',time())) <= strtotime($data['cost_month'])) {
$msg.="不允许导入超过当前月份的数据!";
}
$data['village_id'] = $village_id;
$data['type'] = $type;
$is_exit = Db::name('cost')->where($data)->find();
if($is_exit) {
$msg.="该条记录已存在!";
}
$data['price'] = $price;
$data['area'] = $dataAll[$i][2];
$data['total_money'] = $data['pay_money'] = number_format($price*$data['area'],2);
$data['is_pay'] = 0;
$data['create_time'] = time();
if(empty($msg)){
$insertData[] = $data;
} else {
$dataAll[$i][3] = $msg;
$errorData[] = $dataAll[$i];
}
}
if(!empty($insertData) || !empty($errorData)) {
Db::name('cost')->insertAll($insertData);
if($errorData){
//导出错误的数据
if($type == "water") {
$file = "./formwork/importWater.xls";
} else if($type == "electric") {
$file = "./formwork/importElectric.xls";
} else {
$file = "./formwork/importGas.xls";
}
$phpExcel = \PHPExcel_IOFactory::load($file);
$title = ['A','B','C','D'];
$i = 2;
foreach ($errorData as $k =>$v) {
foreach ($title as $key=>$value) {
$phpExcel->getActiveSheet()->setCellValue($value.$i,$v[$key]);
}
$i++;
}
$objWriter = new \PHPExcel_Writer_Excel5($phpExcel);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename='.$outFileName);
header('Cache-Control: max-age=0');
$objWriter->save("php://output");
} else{
return ['code'=>200,'data'=>[]];
}
} else {
return ['code'=>400,'msg'=>'文件内容为空!'];
}
}
//验证短信验证码是否正确
public static function rightCode($phone,$code) {
$is_exit = Db::name('send_code')->where(['phone'=>$phone,'code'=>$code])->where('expires_time',">",time())->find();
......@@ -660,6 +785,7 @@ class Common extends BaseController
Db::name('house_vacancy')->where(['phone'=>$phone])->save(['uid'=>$uid]);
//汽车关联
Db::name('car')->where(['phone'=>$phone])->save(['uid'=>$uid]);
}
//通过房间编号和布局id获取房间地址
......@@ -695,7 +821,7 @@ class Common extends BaseController
$data = Db::name('house_user_bind')->alias('hub')->leftJoin('house_vacancy hv','hv.vacancy_id = hub.vacancy_id')->where(['hub.village_id'=>$village_id,'hub.uid'=>$uid])->whereIn('hub.status',[1,2,4])
->field('hub.house_user_bind_id,hub.vacancy_id,hub.type,hv.layout_id,hv.vacancy_code')->select()->toArray();
foreach ($data as $key =>$val) {
$data[$key]['vacancy_address'] = \app\common\controller\Common::getVacancyAddress($val['vacancy_code'],$val['layout_id']);
$data[$key]['vacancy_address'] = self::getVacancyAddress($val['vacancy_code'],$val['layout_id']);
}
return $data;
......
......@@ -153,6 +153,7 @@ class Build extends Base
$data['electric_price'] = $where['electric_price'] = Request::param('electric_price');
$data['gas_price'] = $where['gas_price'] = Request::param('gas_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不继承
......@@ -177,7 +178,6 @@ class Build extends Base
$data['is_inherit'] = $is_inherit;
$change = Db::name('layout_build')->where(['layout_build_id'=>$layout_build_id])->save($data);
if($change) {
return $this->returnJson([],'success');
} else{
......@@ -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() {
......@@ -257,7 +279,7 @@ class Build extends Base
$where['lb.layout_build_id'] = Request::param('layout_build_id');//建筑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)
->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();
$data = Common::changeField($res);
return $this->returnJson($data,'success');
......
......@@ -22,6 +22,7 @@ class Device extends Base
$data['device_sn'] = Request::param('device_sn');
$data['village_id'] = $this->village_id;
$data['build_id'] = Request::param('build_id');
$data['build_code'] = Request::param('build_code');
$data['device_direction'] = Request::param('device_direction');
$data['device_platform'] = Request::param('device_platform');
......@@ -58,12 +59,19 @@ class Device extends Base
$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')
->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();
$res['total'] = $total;
$res['data'] = Common::changeField($data);
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
}
//图片上传
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;
//关于订单的接口
use app\admin\controller\Common;
use app\common\controller\Common;
use think\facade\Db;
use think\facade\Request;
......@@ -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;
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() {
$park_block_id = Request::param('park_block_id');
$data['village_id'] = $this->village_id;
......@@ -36,7 +36,7 @@ class Parking extends Base
}
}
//删除车位区块
//删除车
public function deleteParkArea() {
$where['village_id'] = $this->village_id;
$where['park_block_id'] = Request::param('park_block_id');
......@@ -54,7 +54,7 @@ class Parking extends Base
}
//车位区域列表
//车列表
public function parkAreaList() {
$page= Request::param('page',1);
$where['village_id'] = $this->village_id;
......@@ -65,7 +65,7 @@ class Parking extends Base
}
//添加车位
//添加|修改车位
public function createCarArea() {
$park_car_id = Request::param('park_car_id');
$data['park_block_id'] = Request::param('park_block_id');
......@@ -76,6 +76,7 @@ class Parking extends Base
}
$data['park_code'] = Request::param('park_code');
$data['sort_id'] = Request::param('sort_id');
$data['type'] = Request::param('type',1);
$data['explain'] = Request::param('explain');
$data['village_id'] = $this->village_id;
......@@ -97,7 +98,7 @@ class Parking extends Base
$data['create_time'] = time();
$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]);
}
}
......@@ -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();
$res['total'] = $total;
$res['data'] = $data;
$res['data'] = Common::changeField($data);
return $this->returnJson($res,'success');
}
......@@ -161,7 +162,7 @@ class Parking extends Base
$optionsArr = Db::name('park_block')->where(['village_id'=>$village_id])->column('name');
$optionsString = implode(',',$optionsArr);//这个是的车库
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)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
......@@ -172,6 +173,17 @@ class Parking extends Base
-> setError('您输入的值不在下拉框列表内.')
-> setPromptTitle('车库')
-> 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
//批量导入车位
public function importCarPark() {
$filePath = Request::param('filePath');
$filePath = "./车位导入.xls";
if(!file_exists($filePath)){
return $this->returnJson([],'文件不存在!',400);
}
......@@ -201,17 +213,13 @@ class Parking extends Base
//添加|修改车辆
public function createCar() {
$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['end_time'] = Request::param('end_time');
$data['name'] = Request::param('name');
$data['brand'] = Request::param('brand');
$data['car_color'] = Request::param('car_color');
$data['brand'] = Request::param('brand');
$data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1);
if($car_id) {
......@@ -223,6 +231,7 @@ class Parking extends Base
$operation = Db::name('car')->where(['car_id'=>$car_id])->save($data);
} else {
$data['create_time'] = time();
$data['village_id'] = $this->village_id;
//判断车牌是否存在
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->find();
if($is_exit) {
......@@ -269,20 +278,15 @@ class Parking extends Base
$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();
$res['total'] = $total;
$res['data'] = $data;
$res['data'] = Common::changeField($data);
return $this->returnJson($res,'success');
}
//获取单个车辆信息
public function detailCar() {
$where['car.village_id'] = $this->village_id;
$where['car.car_id'] = Request::param('car_id');
$data = Db::name('car')->alias('car')
->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();
$where['village_id'] = $this->village_id;
$where['car_id'] = Request::param('car_id');
$data = Db::name('car')->where($where)->find();
return $this->returnJson(Common::changeField($data),'success');
}
......@@ -301,32 +305,8 @@ class Parking extends Base
//车辆导入模板下载
public function downloadCar() {
$file_dir = "./formwork/importCar.xls";
$phpExcel = \PHPExcel_IOFactory::load($file_dir);
$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");
$file_path = "./formwork/importCar.xls";
downloadFile($file_path,"车辆导入.xls");
}
//批量导入车辆
......
......@@ -64,10 +64,10 @@ class UserBind extends Base
//业主列表| 租客列表 | 家属列表
public function houseOwnerList(){
$vacancy = new Vacancy($this->app);
$page = Request::param('page',1);
$where[] = ['hub.type','=',Request::param('type',0)];
$where[] = ['hub.village_id','=',$this->village_id];
if(Request::param('phone')) {
$where[] = ['hub.phone','=',Request::param('phone')];
}
......@@ -81,8 +81,10 @@ class UserBind extends Base
->where($where)
->order(['hub.pass_time'=>'desc','hub.status'=>'desc'])
->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();
foreach ($data as $k => $v) {
$data[$k]['vacancy_address'] = $vacancy->getVacancyAddress($v['vacancy_code'],$v['layout_id']);
}
......@@ -174,9 +176,11 @@ class UserBind extends Base
return $this->returnJson([],'该身份证用户在该房间下以绑定,请勿重复绑定!',400);
}
//业主只能有一个
$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) {
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();
if($is_owner) {
return $this->returnJson([],'该房间编号下以绑定业主,请先解绑!',400);
}
}
$add = Db::name('house_user_bind')->save($data);
if($add) {
......@@ -245,7 +249,7 @@ class UserBind extends Base
//查看用户关联到车辆
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();
$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');
}
......
......@@ -16,7 +16,7 @@ class Vacancy extends Base
//房间列表
public function vacancyList() {
$page = Request::param('page',1);
$where = [];
$where[] = ['hv.village_id','=',$this->village_id];
if(Request::param('phone')) {
$where[] = ['hv.phone','=',Request::param('phone')];
}
......@@ -26,12 +26,14 @@ class Vacancy extends Base
$total = Db::name('house_vacancy')->alias('hv')
->where($where)
->count();
$data = Db::name('house_vacancy')->alias('hv')->field('hv.vacancy_id,hv.vacancy_code,hv.name,hv.phone,hv.create_time,hv.village_name,hv.village_id,hv.area,hv.id_card')
$data = Db::name('house_vacancy')->alias('hv')->field('hv.layout_id,hv.vacancy_code,hv.vacancy_id,hv.vacancy_code,hv.name,hv.phone,hv.create_time,hv.village_name,hv.village_id,hv.area,hv.id_card')
->where($where)
->order('create_time','desc')
->page($page,config('app.limit'))
->select()->toArray();
foreach ($data as $k =>$v) {
$data[$k]['vacancy_address'] = $this->getVacancyAddress($v['vacancy_code'],$v['layout_id']);
}
$res['total'] = $total;
$res['data'] = Common::changeField($data);
return $this->returnJson($res,'success');
......@@ -47,12 +49,13 @@ class Vacancy extends Base
$data['vacancy_address'] = $vacancyAddress;
unset($data['village_name']);//用连表查询的社区名称
if($data['is_inherit'] ==1 ) {
$p_info = Db::name('layout_build')->where(['layout_build_id'=>$data['parent_id']])->field('property_price,water_price,electric_price,gas_price,parking_price')->find();
$data['property_price'] = $p_info['property_price'];
$data['water_price'] = $p_info['water_price'];
$data['electric_price'] = $p_info['electric_price'];
$data['gas_price'] = $p_info['gas_price'];
$data['parking_price'] = $p_info['parking_price'];
$p_info = Db::name('layout_build')->where(['layout_build_id'=>$data['parent_id']])
->field('property_price,water_price,electric_price,gas_price,parking_price')->find();
$data['property_fee'] = $p_info['property_price'];
$data['water_fee'] = $p_info['water_price'];
$data['electric_fee'] = $p_info['electric_price'];
$data['gas_fee'] = $p_info['gas_price'];
$data['parking_fee'] = $p_info['parking_price'];
}
return $this->returnJson(Common::changeField($data),'success');
}
......@@ -60,20 +63,19 @@ class Vacancy extends Base
//添加| 修改 房间
public function createVacancy() {
$vacancy_id = Request::param('vacancy_id');
$data['layout_id'] = Request::param('layout_id');
$data['village_id'] = $add['village_id']= $this->village_id;
$vacancy_code = Request::param('vacancy_code');
if($vacancy_id) {
$res = $this->checkVacancyCode($vacancy_code,$vacancy_id);
$res = $this->checkVacancyCode($vacancy_code,$vacancy_id,$data['layout_id'] );
} else {
$res = $this->checkVacancyCode($vacancy_code);
$res = $this->checkVacancyCode($vacancy_code,0,$data['layout_id'] );
}
if($res['code'] !=200) {
return $this->returnJson([],$res['msg'],400);
}
$data['vacancy_code'] = $vacancy_code ;
$data['name'] = $add['name'] = Request::param('name'); //业主姓名
$data['id_card'] = $add['id_card'] = Request::param('id_card'); //身份证id /
$phone = Request::param('phone'); //业主手机号
if(!isPhoneNo($phone)) {
......@@ -95,7 +97,7 @@ class Vacancy extends Base
$data['gas_fee'] = Request::param('gas_fee');
$data['parking_fee'] = Request::param('parking_fee');
$data['parent_id'] = Request::param('parent_id');
$data['layout_id'] = Request::param('layout_id');
$add['type'] = $add['status'] = 1;
$park_code = Request::param('park_code');
......@@ -166,24 +168,32 @@ class Vacancy extends Base
}
//检查房间编号是否合法
public function checkVacancyCode($vacancy_code,$vacancy_id=0) {
public function checkVacancyCode($vacancy_code,$vacancy_id=0,$layout_id) {
if($vacancy_id == 0){
$vacancyInfo = Db::name('house_vacancy')->where(['village_id'=>$this->village_id,'vacancy_code'=>$vacancy_code])->field('vacancy_id')->find();
$vacancyInfo = Db::name('house_vacancy')->where(['village_id'=>$this->village_id,'vacancy_code'=>$vacancy_code,'layout_id'=>$layout_id])->field('vacancy_id')->find();
} else{
$vacancyInfo = Db::name('house_vacancy')->where(['village_id'=>$this->village_id,'vacancy_code'=>$vacancy_code])->where('vacancy_id','<>',$vacancy_id)->field('vacancy_id,vacancy_code')->find();
$vacancyInfo = Db::name('house_vacancy')->where(['village_id'=>$this->village_id,'vacancy_code'=>$vacancy_code,'layout_id'=>$layout_id])->where('vacancy_id','<>',$vacancy_id)->field('vacancy_id,vacancy_code')->find();
}
if($vacancyInfo) {
return ['code'=>400,'msg'=>'房间编号已存在!'];
return ['code'=>400,'msg'=>'物业编号已存在!'];
}
$array = explode ('-',$vacancy_code);
//查看布局是否黑
$layoutCode = Db::name('layout_list')->where(['layout_id'=>$layout_id])->value('code');
if(count($array) != count(explode('-',$layoutCode))){
return ['code'=>400,'msg'=>'房间位置不合法!'];
}
//去掉最后一个房间编号的
array_pop($array);
$count = Db::name('layout_build')->where('layout_build_id','in',$array)->count();
if($count != count($array)) {
return ['code'=>400,'msg'=>'房间编号不合法!'];
return ['code'=>400,'msg'=>'房间位置不合法!'];
} else {
return ['code'=>200,'msg'=>'success!'];
}
}
//通过房间编号获取房间地址
......@@ -198,9 +208,9 @@ class Vacancy extends Base
$room_code = array_pop($arr);
$string = '';
foreach ($arr as $v) {
$code_name = Db::name('layout_build')->where(['layout_build_id'=>$v])->field('code,level')->find();
$key = $code_name['level'] -1;
$string.=$code_name['code'].$codeArr[$key];
$code_name = Db::name('layout_build')->where(['layout_build_id'=>$v])->field('code,level')->find();
$key = $code_name['level'] -1;
$string.=$code_name['code'].$codeArr[$key];
}
return $string.$room_code.$rom;
......@@ -217,6 +227,8 @@ class Vacancy extends Base
$res = Common::importVacancy($filePath,$village_id);
if($res['code']==200) {
return $this->returnJson([],'success');
} elseif($res['code'] ==400) {
return $this->returnJson([],$res['msg'],400);
}
}
......@@ -227,8 +239,8 @@ class Vacancy extends Base
if($ext != 'xls') {
return $this->returnJson([],'请上传xls文件',400);
}
$savename = \think\facade\Filesystem::putFile('', $file);
$data['filePath'] = "./public/".$savename;
$savename = \think\facade\Filesystem::putFile('', $file,'datea');
$data['filePath'] = "./upload/".$savename;
return $this->returnJson($data,'success');
}
......@@ -237,12 +249,12 @@ class Vacancy extends Base
public function downloadImportVacancy() {
$file = "./formwork/importVacancy.xls";
$phpExcel = \PHPExcel_IOFactory::load($file);
$village_id = $this->village_id;
$village_id = $this->village_id ?? 1;
$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++) {
for($i=2;$i<3;$i++) {
$phpExcel->getActiveSheet()->getCell('H'.$i)->getDataValidation()-> setType(\PHPExcel_Cell_DataValidation::TYPE_LIST)
-> setErrorStyle(\PHPExcel_Cell_DataValidation::STYLE_INFORMATION)
-> setAllowBlank(false)
......@@ -265,11 +277,23 @@ class Vacancy extends Base
-> setPromptTitle('车库位置')
-> setFormula1('"'.$optionsCarBlockString.'"');; //这一句为要设置数据有效性的单元格
}
if($optionsCarBlockString) {
$phpExcel->getActiveSheet()->getCell('I'.$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('Content-Disposition: attachment;filename="房间导入.xls"');
header('Cache-Control: max-age=0');
$objWriter->save("php://output");
}
......@@ -277,70 +301,81 @@ class Vacancy extends Base
//当前房间下的费用明细
public function vacancyCost(){
$convertArr = $this->convertArr;
$cost_month = Request::param('month');
$page = Request::param('page',1);
$vacancy_id = Request::param('vacancy_id');
$isPay = Request::param('is_pay');
$type = Request::param('type');
$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;
}
if($isPay) {
$where['is_pay'] = $isPay;
}
if($type && $type == "other") {
$where['is_default'] = 0; //自定义收费的
} elseif($type == "other") {
$where['is_default'] = 1;
}
$data = Db::name('cost')->where($where)->order('cost_id','desc')->field('cost_id,price,type,total_money,cost_month,is_pay,area,pay_time,prefer_money,pay_money,explain,is_default')->page($page,config('app.limit'))->select()->toArray();
foreach ($data as $k => $v){
$data[$k]['type'] = $convertArr[$v['type']];
}
$total = Db::name('cost')->where($where)->count();
$res['total'] = $total;
$res['data'] = $data;
$res['data'] = Common::changeField($data,'pay_time');
return $this->returnJson($res);
}
//每月账单详情
public function detailCost() {
$where['cost_id'] = Request::param('cost_id');
$where['village_id'] = $this->village_id;
$data = Db::name('cost')->where($where)->find();
switch ($data['type']){
case "property":
$data['type'] ="物业费";
break;
case "water":
$data['type'] ="水费";
break;
case "gas":
$data['type'] ="燃气费";
break;
case "electric":
$data['type'] ="电费";
break;
case "park":
$data['type'] ="停车费";
break;
}
return $this->returnJson(Common::changeField($data,['create_time','pay_time']));
}
//修改某个房间的费用明细
public function changeCost() {
$where['cost_id'] = Request::param('cost_id');
$where['village_id'] = $this->village_id;
$where['is_default'] = 1;
$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['prefer_money'] = Request::param('prefer_money',0);
$data['explain'] = Request::param('explain');
if($data['prefer_money'] !=0 && !isset($data['explain'])) {
return $this->returnJson([],'优惠说明必填!',400);
}
$data['type'] = $real_type;
$data['pay_money'] = $data['total_money']-$data['prefer_money'];
$data['is_pay'] =Request::param('is_pay',0);
$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)]);
......@@ -350,6 +385,39 @@ class Vacancy extends Base
}
}
//添加|修改自定义收费
public function createCustomizeCost(){
$cost_id =Request::param('cost_id');
$type = Request::param("type");
if(empty($type)){
return $this->returnJson([],'收费类目必填!');
}
$data['type'] = $type;
$data['pay_money'] = $data['total_money'] = Request::param('pay_money');
$data['explain'] = Request::param('explain');
$data['is_pay'] = Request::param('is_pay',0);
if($cost_id) {
$where['cost_id'] = $cost_id;
$operation = Db::name('cost')->where($where)->save($data);
} else{
$data['village_id'] = $this->village_id;
$data['vacancy_id'] = Request::param('vacancy_id');
$data['create_time'] = time();
$data['is_default'] = 0;
$operation = Db::name('cost')->insert($data);
}
if($operation) {
return $this->returnJson();
} else {
return $this->returnJson([],'操作成功!',400);
}
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ use think\facade\Request;
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() {
$property_admin_id = Request::param('property_admin_id');
......
......@@ -13,7 +13,7 @@ class Base extends BaseController
{
protected $uid; //物业后台管理员管理员id
// protected $village_id; //小区id
protected $property_id; //物业id
public function __construct(App $app)
......
......@@ -11,7 +11,7 @@ use think\facade\Request;
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() {
......
......@@ -11,7 +11,7 @@ use think\facade\Request;
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() {
......
......@@ -13,7 +13,7 @@ use think\facade\Request;
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() {
......
......@@ -40,4 +40,30 @@ return [
//token加密的key
'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+Wpa03l/FpgJCSGe6ZAfb9EXKbOpkYMyKqWpFPF1261vwb0xYRgMZGeGXphGHTaXpFyHj9hR0WxAxHQVGFJeJP4S3SswI7klK9ASd2a1PzGad2XVT/MQUseNMKsHl32tklhU/qjLYsmOJb4w79gySKDC85mFAgL6KyVVKW0juroIRb1IxLUYEBUwChzQf3r+0TJ6fJ9yGh19lKS5pS4Hr/AZbA5wX+PBMe7H4nODlGGkPXhUCwIDAQABAoIBADVp2jajMli0wy7bYXVOKo3LJ4GS/iX0tyL73eOlij/ZNvmcwUc+fcJkgbuY9j34bOiizhAewkOH7NOQ6PZz/zri8ax9vgKhfPuEVihavDNsXMbEMAupqes6XUOg6P7Z/czuVLeTDCb8dYjgK2O0jEboSFg6kmyd800tRA1ZiPIlJI9vRmea8PsTLWhkU1einClBCqIUTyxN3Ecm3cms1lFH6H+IMevrzTyISOkCjwqq6KtU+mEMJi0HtHyVqqXZFOhQjHq9Pd00lDzz5m2064gPk5J5NpqEdvfO4WmFZrmQbVB8vmKkFvr5dfzKhU1U/ju8WeqtjgdRlkDUf4G9s0kCgYEA8RemXJDxF3u/eLnx1SaIkGftsxScV0ZEo1qZVlnPLhnzenhlEWtnGd6uPMFBBv3QsaCWoSg1d0igf5Pgb3B3PtLbsig9tARsjWNMUflizpVYVEYGrAUgRYdqDTK3Twdl1/AzW0Ep83+9FMCFzSLtiHRo85cveH+08UxZvkHaEbUCgYEAyoG8U25ykRMbxEy3aw5goP2fWKnNKQuLh7fkY/achmfUEsWGJ2qj/pC/L6M567p+0fgfoH1ofX8ilrzsE0Aisivlu4gXDinHrTw+XsHovCQwbpJMiaFG//tYi6HC5YNvXsOVYQbx5uStrOct58/6vReH1apgH/eYA3TqkBQ7Zr8CgYBCsfoxzV8E0hUL/tSp1LkeycF2MxN1CVlfn2af/sRTypYSoU/EW+PvwiyNXiDxIDIlkXlaJ9dyokLUSEJkUcaLOKXSSVOYg0jMbFXmr4joAWSoG58o41okIevyrr8LO86uyCJM8l/6nrHeFcxuDWWMxDdse7yEJ0AVKLwC6BC9qQKBgE/N7symUwnvENs8LHBJGzV2naxQRmStgxA6HQxz7F1fX4kCRIsWEIjKvD1mwvWt6jqO4M/bfCkwyA3FZ/dyJ/o1KHTN/d/8AQ+5FQ88tZ4nWNrKVtVKNHO+trdYSTkvod0jkKPLG9uVNQhVlparNLH+Ku6+FOGkLkj2c1XSU1J7AoGAMR+mjwXaGsRI7+ST7zDVdelJfB6rZyeUBlSruYTEDOo1uG327Dky5DRczRfwEESS30Dxd6oYXUj/buqWx8BRzJ5VbiXK7ynQViBGm6u8LSSK6O3NstIwCz2SV9Y2kyF/J049ZlKOswbdq/r68PFej1lSSr/zf6XDLCJ8lAytUsM=',
//应用公钥
'public_key'=>'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvrbXi8/ePxzFfIOcF5flf/YILuW0q7OVt+9jHZoSn/dkY6J7mYNate4tYq+QhPtBm7dKDu9WqF9nTKnwgoDBdZdDwudANDYNxBLS+Wpa03l/FpgJCSGe6ZAfb9EXKbOpkYMyKqWpFPF1261vwb0xYRgMZGeGXphGHTaXpFyHj9hR0WxAxHQVGFJeJP4S3SswI7klK9ASd2a1PzGad2XVT/MQUseNMKsHl32tklhU/qjLYsmOJb4w79gySKDC85mFAgL6KyVVKW0juroIRb1IxLUYEBUwChzQf3r+0TJ6fJ9yGh19lKS5pS4Hr/AZbA5wX+PBMe7H4nODlGGkPXhUCwIDAQAB',
//支付宝公钥
'pay_alipay_public_key'=>'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtl27/bcRervEf1YJoSGyQusBAh9CtcwyzZzUBfHtclYUDQZ154SijHfNxWX71AtMgPnTdeSzFC6Ky6WC9/MSAz2OrSbhhi7PX+f+ydgnBL/CoPw5O699MHuCTQzuOKRVoEwLcgjWm3nJNELTY9RVGQ2GkAD+Tj4wih2FXoFmVyGMdoz8dsYFBo/fgxOhb+mkYVy+uJfu4vuh7DwM2T9H5z8PmodDLvPnqO1+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 [
// 配置Reids
'redis' => [
'type' => 'redis',
'host' => '127.0.0.1',
'port' => '6379',
'password' => '',
'host' => env('redis.host', '127.0.0.1'),
'port' => env('redis.port', 6379),
'password' => env('redis.port', ''),
'select' => '0',
// 全局缓存有效期(0为永久有效)
'expire' => 0,
......
......@@ -13,7 +13,7 @@
namespace think;
require __DIR__ . '/../vendor/autoload.php';
header('Access-Control-Allow-Origin: *');
// 执行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