/** * 对bos提供的特别接口 * 24对返回数据进行整理 * url:/index.php?r=CarrentalApi/rc/GetFilterSearch */ public function actionGetFilterSearch() { $json_params = Yii::app()->request->getParam('json_params'); //客户端请求的json参数 $Redis = YiiRedis::getInstance(); //测试用例[S] $json_params_go = Yii::app()->request->getParam('go'); if ($json_params_go == 'go') { // $json_params='{"PickUp":{"Location":{"country":"UK","city":"Manchester"},"Date":{"year":"2014","month":"12","day":"1","hour":"10","minute":"30"}},"DropOff":{"Location":{"country":"UK","city":"Manchester"},"Date":{"year":"2014","month":"12","day":"2","hour":"10","minute":"30"}},"DriverAge":26}'; $json_params = '{"PickUp":{"Location":{"country":"UK","city":"Manchester"},"Date":{"year":"2014","month":"12","day":"1","hour":"10","minute":"30"}},"DropOff":{"Location":{"country":"UK","city":"Manchester"},"Date":{"year":"2014","month":"12","day":"3","hour":"10","minute":"30"}},"DriverAge":26}'; $array_params = json_decode($json_params, true); $array_params['remoteIp'] = '106.2.184.106'; $json_params = json_encode($array_params); } //测试用例[E] if ($Redis->get('GetFilterSearch_' . md5($json_params))) { $Rs = $Redis->get('GetFilterSearch_' . md5($json_params)); $Rs_array = json_decode($Rs, true); } else { $Rs = RcManager::SearchRQ($json_params); $Rs_array = json_decode($Rs, true); if ($Rs_array['status']) { $Redis->set('GetFilterSearch_' . md5($json_params), $Rs); } } if ($Rs_array['status'] && !empty($Rs_array['data'])) { $Redis->set('GetFilterSearch_' . md5($json_params), $Rs); $matchList_filter = array(); //整理后的车辆列表数组 $Rs_array_data = $Rs_array['data']; foreach ($Rs_array_data as $Rs_key => $Rs_val) { if (!empty($Rs_val['Match'])) { $match = $Rs_val['Match']; $match_vehicle = $match['Vehicle']['@attributes']; $matchList_filter[$Rs_key]['CarCode'] = $match_vehicle['id']; //车辆ID $matchList_filter[$Rs_key]['Name'] = $match['Vehicle']['Name']['@text']; //车辆名称 $matchList_filter[$Rs_key]['Description'] = !empty($match['Vehicle']['Description']['@text']) ? $match['Vehicle']['Description']['@text'] : ''; //车辆描述 $matchList_filter[$Rs_key]['CompanyID'] = $match['Supplier']['@text']; //公司名称 $matchList_filter[$Rs_key]['SuppID'] = 'rentalcars'; $matchList_filter[$Rs_key]['GroupCode'] = $match_vehicle['group']; $matchList_filter[$Rs_key]['Doors'] = $match_vehicle['doors']; $matchList_filter[$Rs_key]['Seats'] = $match_vehicle['seats']; $matchList_filter[$Rs_key]['Automatic'] = $match_vehicle['automatic']; $matchList_filter[$Rs_key]['Aircon'] = $match_vehicle['aircon']; $matchList_filter[$Rs_key]['Airbag'] = $match_vehicle['airbag']; $matchList_filter[$Rs_key]['Petrol'] = $match_vehicle['petrol']; $matchList_filter[$Rs_key]['ImageURL'] = $match['Vehicle']['ImageURL']['@text']; $matchList_filter[$Rs_key]['LargeImageURL'] = $match['Vehicle']['LargeImageURL']['@text']; $matchList_filter[$Rs_key]['LogoUrl'] = $match['Supplier']['@attributes']['small_logo']; $matchList_filter[$Rs_key]['Longitude'] = $match['Supplier']['@attributes']['long']; $matchList_filter[$Rs_key]['Latitude'] = $match['Supplier']['@attributes']['lat']; } } $return_array = array('status' => true, 'data' => $matchList_filter); $return_json = json_encode($return_array); exit($return_json); } echo $Rs; }