コード例 #1
0
ファイル: RcManager.php プロジェクト: lovecheng/brs-demo2
 /**
  *8 到还车门店营业时间
  * @param $json_params
  * @return string
  */
 public static function DropOffOpenTimeRQ($json_params)
 {
     $request_time = time();
     $request_param = json_decode($json_params, true);
     $return_status = '';
     //返回客户端错误状态
     //判断客户端请求的国家,城市 ,地点名称是否存在
     if (!empty($request_param['location_id']) && !empty($request_param['year']) && !empty($request_param['month']) && !empty($request_param['day'])) {
         $request_location_id = intval($request_param['location_id']);
         $request_year = intval($request_param['year']);
         $request_month = intval($request_param['month']);
         $request_day = intval($request_param['day']);
         if ($request_year >= 2004 && $request_month >= 1 && $request_month <= 12 && $request_day >= 1 && $request_day <= 31) {
             $request_xml = '
                 <DropOffOpenTimeRQ>
                     <Credentials username="******" password="******" remoteIp="' . CARRENTALAPI_REMOTEIP . '" />
                     <Location id="' . $request_location_id . '"/>
                     <Date year="' . $request_year . '" month="' . $request_month . '" day="' . $request_day . '"/>
                 </DropOffOpenTimeRQ>';
             $request_data = array('xml' => $request_xml);
             $dropOffOpenTimeRS = GetUrlContent::fileGetContent($request_data, CARRENTALAPI_URL, 30, 'POST');
             //得到出发地国家xml列表信息
             $rusult = SimpleXML::xml2arrayFull($dropOffOpenTimeRS);
             if (!empty($rusult['OpenTime'])) {
                 $return_json = json_encode(array('status' => true, 'data' => $rusult['OpenTime']));
                 ApiLogManage::addRentalcars('DropOffOpenTimeRQ', $json_params, $dropOffOpenTimeRS, $return_json, $request_time, time(), 1);
                 //记录日志
                 return $return_json;
             } else {
                 $return_status = '0x080102_请求内容不存在或请求超时';
                 $return_json = json_encode(array('status' => false, 'error_msg' => $return_status));
                 ApiLogManage::addRentalcars('DropOffOpenTimeRQ', $json_params, $dropOffOpenTimeRS, $return_json, $request_time, time(), 10);
                 //记录日志
                 return $return_json;
             }
         } else {
             $return_status = '0x080101_请求的时候必须符合格式 year (>2004) month(1-12) day(1-31)';
         }
     } else {
         $return_status = '0x080100_地点(location_id),年(year),月(month),日(day)不可为空';
     }
     $return_json = json_encode(array('status' => false, 'error_msg' => $return_status));
     ApiLogManage::addRentalcars('DropOffOpenTimeRQ', $json_params, '', $return_json, $request_time, time(), 2);
     //记录日志
     return $return_json;
 }