Example #1
0
 /**
  *10.2 得到门店的条款信息(对里程,保险,税费做了格式化处理)
  * @param $json_params
  * @return bool|string
  */
 public static function RentalTermsFilterRQ($json_params)
 {
     $Redis = YiiRedis::getInstance();
     $request_time = time();
     $redisKey = 'rentalTermsRQ_' . md5($json_params);
     if ($Redis->get($redisKey)) {
         $Rs = $Redis->get($redisKey);
         $Rs_array = json_decode($Rs, true);
         ApiLogManage::addRentalcars('RentalTermsFilterRQ', $json_params, '', $Rs, $request_time, time(), 1);
         //记录日志
     } else {
         $Rs = RcManager::RentalTermsRQ($json_params);
         $Rs_array = json_decode($Rs, true);
         if ($Rs_array['status']) {
             $Redis->set($redisKey, $Rs, 60 * 60 * 30);
             //30
         }
     }
     //数据整理[S]
     if ($Rs_array['status']) {
         $Rs_filter_arr = array();
         //整理的数据
         foreach ($Rs_array['data'] as $k => $v) {
             if (!empty($v['type']) && is_array($v['content'])) {
                 $type = $v['type'];
                 $country_arr = $v['content'];
                 switch ($type) {
                     case 'Inclusive':
                         $Rs_filter_arr['Inclusive']['Content'] = $v['content'];
                         //得到条件的详细信息[S]
                         foreach ($country_arr as $content) {
                             if (!empty($content['Caption']) && strpos($content['Caption'], '租金包括') != false) {
                                 $zujin_str = $content['Body'];
                                 $zujin_arr = explode("*", $zujin_str);
                                 foreach ($zujin_arr as $key => $val) {
                                     if (!empty($val)) {
                                         if (strpos($val, "限制公里数") !== false || strpos($val, "限制里程数") !== false) {
                                             // $licehng=substr($val,strpos($val,'适用'));
                                             $Rs_filter_arr['Inclusive']['Licheng'] = trim($val);
                                         } elseif (strpos($val, "保险") !== false) {
                                             $baoxian_arr = explode("-", $val);
                                             $baoxian_filter_arr = array();
                                             foreach ($baoxian_arr as $k => $str) {
                                                 $tmp = array();
                                                 preg_match('/^[\\x{4e00}-\\x{9fa5}]{0,20}/u', $str, $tmp);
                                                 if (!empty($tmp[0])) {
                                                     array_push($baoxian_filter_arr, $tmp[0]);
                                                 }
                                             }
                                             $Rs_filter_arr['Inclusive']['Baoxian'] = $baoxian_filter_arr;
                                         } elseif (strpos($val, "稅") !== false || strpos($val, "费") !== false) {
                                             $Rs_filter_arr['Inclusive']['Shuifei'][] = trim(strip_tags($val));
                                         }
                                     }
                                 }
                             }
                         }
                         //得到条件的详细信息[E]
                         break;
                     case 'PaymentInfo':
                         $Rs_filter_arr['PaymentInfo']['Content'] = $v['content'];
                         break;
                     case 'Extras':
                         $Rs_filter_arr['Extras']['Content'] = $v['content'];
                         break;
                     case 'PersonalTouch':
                         $Rs_filter_arr['PersonalTouch']['Content'] = $v['content'];
                         break;
                     case 'RentalTerms':
                         $Rs_filter_arr['RentalTerms']['Content'] = $v['content'];
                         break;
                 }
             }
         }
         return $return_json = json_encode(array('status' => true, 'data' => $Rs_filter_arr));
     }
     //增加返回字段数据[E]
     //return $Rs;
     return $Rs;
 }