Commit f30d1b87 authored by 蔡闯's avatar 蔡闯

物业服务时间修改

parent 89bc9a1f
......@@ -157,9 +157,6 @@ class Index extends Base
$cars = Db::name('car')->where(['uid'=>$this->uid,'village_id'=>$v['village_id']])->field('car_id,license_plate,brand')->select()->toArray();
$data[$k]['cars'] = $cars;
$car_total = count($cars);
if($car_total ==1) {
$data[$k]['cars'] = $cars[0];
}
$data[$k]['car_total'] = $car_total;
$data[$k]['type_zh'] = $userType[$v['type']];
}
......@@ -174,33 +171,32 @@ class Index extends Base
return $this->returnJson($data);
}
//修改车辆
public function changeCar() {
$car_id = Request::param('car_id');
$data['license_plate'] = Request::param('license_plate');
$is_exit = Db::name('car')->where('uid','<>',$this->uid)->where($data)->find();
if($is_exit){
return $this->returnJson([],'该车牌号已存在!',400);
}
$data['name'] = Request::param('name');
$data['car_color'] = Request::param('car_color');
$data['village_id'] = Request::param('village_id');
$data['brand'] = Request::param('brand');
$data['car_type'] = Request::param('car_type');
$data['car_color'] = Request::param('car_color');
$change = Db::name('car')->where(['car_id'=>$car_id])->save($data);
if($change) {
return $this->returnJson([],'操作成功!');
} else {
return $this->returnJson([],'操作失败!',400);
}
}
// //修改车辆
// public function changeCar() {
// $car_id = Request::param('car_id');
// $data['license_plate'] = Request::param('license_plate');
// $is_exit = Db::name('car')->where('uid','<>',$this->uid)->where($data)->find();
// if($is_exit){
// return $this->returnJson([],'该车牌号已存在!',400);
// }
// $data['name'] = Request::param('name');
// $data['car_color'] = Request::param('car_color');
// $data['village_id'] = Request::param('village_id');
// $data['brand'] = Request::param('brand');
// $data['car_type'] = Request::param('car_type');
//
// $change = Db::name('car')->where(['car_id'=>$car_id])->save($data);
//
// if($change) {
// return $this->returnJson([],'操作成功!');
// } else {
// return $this->returnJson([],'操作失败!',400);
// }
//
// }
//用户添加车辆
public function addCar() {
public function changeCar() {
$uid = $this->uid;
$car_id = Request::param('car_id');
$data['phone'] = Db::name('user')->where(['uid'=>$uid])->value('phone');
......@@ -209,11 +205,11 @@ class Index extends Base
$data['car_color'] = Request::param('car_color');
$data['license_plate'] = Request::param('license_plate');
$data['sort_id'] = Request::param('sort_id',1);
$data['car_type'] = Request::param('car_type');
$data['uid'] = $uid;
$data['village_id'] = Request::param('village_id');
$data['car_color'] = Request::param('car_color');
if($car_id) {
//判断车牌是否存在
//判断车牌是否存在changeCar
$is_exit = Db::name('car')->where(['license_plate'=>$data['license_plate']])->where('car_id','<>',$car_id)->find();
if($is_exit) {
return $this->returnJson([],'系统中已存在该车牌!',400);
......@@ -228,10 +224,11 @@ class Index extends Base
}
$operation = Db::name('car')->save($data);
}
if($operation) {
if($operation !== false) {
return $this->returnJson([],'success');
} else {
return $this->returnJson([],'操作失败!',400);
return $this->returnJson([],'修改失败!',400);
}
}
......@@ -239,7 +236,7 @@ class Index extends Base
public function deleteCar() {
$car_id = Request::param('car_id');
$delete = Db::name('car')->where(['car_id'=>$car_id,'uid'=>$this->uid])->delete();
if($delete) {
if($delete !== false) {
return $this->returnJson();
} else {
return $this->returnJson([],'删除失败!',400);
......@@ -319,7 +316,7 @@ class Index extends Base
$save['status'] = $status;
$save['pass_time'] = time();
$change = Db::name('house_user_bind')->where(['house_user_bind_id'=>$bind_id])->save($save);
if($change) {
if($change !== false) {
return $this->returnJson();
} else {
return $this->returnJson([],'操作失败!',400);
......
......@@ -48,17 +48,23 @@ class Payreturn extends BaseController
}
}
//根据获取到的订单id,更改状态
//根据获取到的订单id,更改状态,更改房间的物业服务时间
private function changePayStatus($out_trade_no) {
$where['order_num'] = $out_trade_no;
$save['pay_time'] = time();
$save['is_pay'] = 1;
$cost_ids = DB::name('pay_order')->where(['order_num'=>$out_trade_no])->value('cost_ids');
$cost_ids_arr = json_decode($cost_ids);
$costInfo = Db::name('cost')->where('cost_id','in',$cost_ids_arr)->where(['type'=>'property'])->order('cost_month','desc')->field('cost_month,vacancy_id')->find();
Db::startTrans();
try{
if($costInfo) {
$property_end_time = $costInfo['cost_month'];
DB::name('house_vacancy')->where(['vacancy_id'=>$costInfo['vacancy_id']])->save(['property_end_time'=>$property_end_time]);
}
Db::name('pay_order')->where($where)->save($save);
Db::name('cost')->where('cost_id','in',$cost_ids_arr)->save($save);
Db::commit();
return true;
}catch(\Exception $e){
......
......@@ -90,6 +90,13 @@ class Vacancy extends Base
$data['phone'] = $add['phone']= $phone;
$data['property_start_time'] = date('Y-m',strtotime(Request::param('property_start_time')));
$data['property_end_time'] = date('Y-m',strtotime(Request::param('property_end_time')));
if($data['property_start_time'] && $data['property_end_time']) {
//判断物业服务开始时间和结束时间是否合理
$res = $this->checkVacancyPropertyTime($data['property_start_time'],$data['property_end_time']);
if($res['code'] !=200) {
return $this->returnJson([],$res['msg'],400);
}
}
$data['village_name'] = Db::name('house_village')->where(['village_id'=>$data['village_id']])->value('village_name');
$data['area'] = Request::param('area');
$data['status'] = Request::param('status',1);
......@@ -199,6 +206,29 @@ class Vacancy extends Base
return ['code'=>200,'msg'=>'success!'];
}
}
//判断输入的物业开始时间和结束时间是否合理
public function checkVacancyPropertyTime($stat_time,$end_time){
if($stat_time ==$end_time) {
return ['code'=>400,'msg'=>"开始时间和结束时间不能相同!"];
}
$new_time = date('Y-m',time());
if($stat_time == $new_time) {
return ['code'=>400,'msg'=>"开始时间不能早于当前月份!"];
}
if($stat_time > $end_time || $stat_time =$end_time) {
return ['code'=>400,'msg'=>"开始时间不能大于结束时间!"];
}
$new_year = explode('-',$new_time)[0];
$end_year = explode('-',$end_time)[0];
$time_diff = $new_year - $end_year;
if($time_diff > 3) {
return ['code'=>400,'msg'=>"结束时间不能设置不能超过2年!"];
}
}
......
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