success($result['msg'],$result['data']); }else{ return $this->fail($result['msg']); } } public function setContract():Json { //获取参数 $params = $this->request->post(['party_a','party_b','num','start_time','end_time','rent_type','car_id']); //验证参数 if(empty($params['party_a']) || empty($params['party_b']) || empty($params['num']) || empty($params['start_time']) || empty($params['end_time']) || empty($params['rent_type'])){ return $this->fail('缺少必要的参数'); } //验证时间格式 if(!checkDateIsValid($params['start_time']) || !checkDateIsValid($params['end_time'])){ return $this->fail('时间格式错误'); } if(!in_array($params['rent_type'],[1,2])){ return $this->fail('rent_type数据格式错误'); } if($params['rent_type'] == 2){ if(empty($params['car_id'])){ return $this->fail('缺少必要参数'); } } //生成数据 $result = VehicleLogic::rentRecord($params); //返回数据 if($result['code'] == 1){ return $this->success($result['msg']); }else{ return $this->fail($result['msg']); } } public function getRentRecord():Json { //获取参数 $params = $this -> request -> get('contract_id'); if(empty($params)){ return $this->fail('确实必要参数'); } //获取数据 $result = VehicleLogic::rendRecordInfo($params); //返回数据 if($result['code'] == 1){ return $this->success($result['msg'],$result['data']); }else{ return $this->fail($result['msg']); } } public function updateRentRecord():Json { //获取参数 $param = $this->request->post('contract_id'); if(empty($param)){ return $this->fail('缺少必要参数'); } //获取数据 $result = VehicleLogic::rendRecordEdit($param); //返回数据 if($result['code'] == 1){ return $this->success($result['msg']); }else{ return $this->fail($result['msg']); } } public function getCompanyCars():Json { $params = $this->request->get(['company_id','company_type']); if(empty($params['company_id']) || empty($params['company_type'])){ return $this->fail('缺少必要参数'); } $result = VehicleLogic::getCompanyCars($params); //返回数据 if($result['code'] == 1){ return $this->success($result['msg'],$result['data']); }else{ return $this->fail($result['msg']); } } //获取车辆当前位置 public function getCarLocal():Json { $params = $this->request->get(['car_id','gps_imei']); if(empty($params['car_id']) || empty($params['gps_imei'])){ return $this->fail('缺少必要参数'); } $result = VehicleLogic::getCarLocal($params); //返回数据 if($result['code'] == 1){ return $this->success($result['msg'],$result['data']); }else{ return $this->fail($result['msg']); } } }