Example #1
0
 public static function PickUpLocationListFilter($json_params)
 {
     $Redis = YiiRedis::getInstance();
     $redisKey = 'locationList_pickUp_' . md5($json_params);
     if ($Redis->hGet('currental_area', $redisKey)) {
         $Rs = $Redis->hGet('currental_area', $redisKey);
     } else {
         $Rs = RcManager::PickUpLocationListRQ($json_params);
         $Rs_array = json_decode($Rs, true);
         if ($Rs_array['status']) {
             $Redis->hSet('currental_area', $redisKey, $Rs);
         }
     }
     return $Rs;
 }
Example #2
0
 public function actionTest()
 {
     ini_set('max_execution_time', '0');
     // $Redis = YiiRedis::getInstance();
     $return_arr = array();
     //要返回的数组
     $return_key = 0;
     //获取国家列表
     // if ($Redis->hGet('currental_area', 'countryList')) {
     //   $Rs_countryList_josn = $Redis->hGet('currental_area', 'countryList');
     //    $Rs_countryList_array=json_decode($Rs_countryList_josn,true);
     //  } else {
     $Rs_countryList_josn = RcManager::PickUpCountryListRQ();
     $Rs_countryList_array = json_decode($Rs_countryList_josn, true);
     //    if($Rs_countryList_array['status']){
     //       $Redis->hSet('currental_area', 'countryList', $Rs_countryList_josn);
     //    }
     //}
     //{"country":"\u4e2d\u56fd"}
     if ($Rs_countryList_array['status']) {
         $countryList_data = $Rs_countryList_array['data'];
         if (!is_array($countryList_data)) {
             exit('国家不是数组格式');
         }
         //获取城市列表
         //$countryList_data=array('Dominica');
         $countryList_data = array('美国-加州');
         foreach ($countryList_data as $k_contry => $v_contry) {
             $contry_json = json_encode(array('country' => $v_contry));
             //  $city_redisKey= 'cityList_pickUp_'.md5($contry_json);
             //   if ($Redis->hGet('currental_area',$city_redisKey)&&false) {
             //      $Rs_city_josn = $Redis->hGet('currental_area', $city_redisKey);
             //    $Rs_cityt_array=json_decode($Rs_city_josn,true);
             //}else {
             $Rs_city_josn = RcManager::PickUpCityListRQ($contry_json);
             $Rs_cityt_array = json_decode($Rs_city_josn, true);
             //    if($Rs_cityt_array['status']&&false){
             //       $Redis->hSet('currental_area',$city_redisKey, $Rs_city_josn);
             //  }
             // }
             if ($Rs_cityt_array['status']) {
                 $cityList_data = $Rs_cityt_array['data'];
                 if (is_array($cityList_data)) {
                     //获取门店列表
                     foreach ($cityList_data as $k_city => $v_city) {
                         //{"country":"\u4e2d\u56fd","city":"Beijing - \u5317\u4eac"}
                         $country_city_json = json_encode(array('country' => $v_contry, 'city' => $v_city));
                         //  $location_redisKey= 'locationList_pickUp_'.md5($country_city_json);
                         //  if ($Redis->hGet('currental_area',$location_redisKey)&&false) {
                         //      $Rs_location_json = $Redis->hGet('currental_area', $location_redisKey);
                         //       $Rs_locaton_array=json_decode($Rs_location_json,true);
                         //   }else {
                         $Rs_location_json = RcManager::PickUpLocationListRQ($country_city_json);
                         $Rs_locaton_array = json_decode($Rs_location_json, true);
                         //     if($Rs_locaton_array['status']&&false){
                         //        $Redis->hSet('currental_area',$location_redisKey, $Rs_location_json);
                         //     }
                         //   }
                         sleep(1);
                         if ($Rs_locaton_array['status']) {
                             $locaton_data = $Rs_locaton_array['data'];
                             if (is_array($locaton_data)) {
                                 foreach ($locaton_data as $k_location => $v_location) {
                                     if (!empty($v_location['id']) && !empty($v_location['value'])) {
                                         $location_id = $v_location['id'];
                                         $location_value = $v_location['value'];
                                         $return_arr[$return_key] = array('locationId' => $location_id, 'locationValue' => $location_value, 'city' => $v_city, 'country' => $v_contry);
                                         $return_key++;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     echo json_encode($return_arr);
 }