Exemplo n.º 1
0
 /**
  * TrackInquiryAct::actIndex()
  * 网站首页
  * @return array 
  */
 public function actIndex()
 {
     $data = array();
     $data['config'] = OpenApiAct::act_getWebConfig();
     $data['carriers'] = self::act_trackName();
     return $data;
 }
Exemplo n.º 2
0
 /**
  * OpenApiAct::act_getCountriesStandard()
  * 获取全部或部分标准国家并存入mencache
  * @param string $type ALL全部,CN中文,EN英文
  * @param string $country 国家,默认空
  * @param int $is_new 是否强制更新(默认0不强制)
  * @return  array 
  */
 public function act_getCountriesStandard()
 {
     $type = isset($_REQUEST['type']) ? post_check($_REQUEST['type']) : "ALL";
     $country = isset($_REQUEST['country']) ? post_check($_REQUEST['country']) : "";
     $is_new = isset($_REQUEST['is_new']) ? $_REQUEST['is_new'] : 0;
     if (!in_array($is_new, array(0, 1))) {
         self::$errCode = 10001;
         self::$errMsg = '强制更新参数有误!';
         return false;
     }
     if (!in_array($type, array("ALL", "EN", "CN"))) {
         self::$errCode = 309;
         self::$errMsg = '参数TYPE类型错误!';
         return false;
     }
     if ($type == "ALL") {
         $country = "";
     }
     //防止重复CACHE
     $cacheName = md5("trans_countries_standard_{$type}{$country}");
     $memc_obj = new Cache(C('CACHEGROUP'));
     $countriesInfo = $memc_obj->get_extral($cacheName);
     if (!empty($countriesInfo) && empty($is_new)) {
         return unserialize($countriesInfo);
     } else {
         $countriesInfo = OpenApiModel::getCountriesStandard($type, $country, $is_new);
         $isok = $memc_obj->set_extral($cacheName, serialize($countriesInfo));
         if (!$isok) {
             self::$errCode = 308;
             self::$errMsg = 'memcache缓存出错!';
             //return false;
         }
         return $countriesInfo;
     }
 }
Exemplo n.º 3
0
 /**
  * TrackShipFeeAct::actShipFee()
  * 运费计算结果页面
  * @return array 
  */
 public function actShipFee()
 {
     $data = array();
     $addId = isset($_REQUEST["addId"]) ? abs(intval($_REQUEST["addId"])) : 0;
     $country = isset($_REQUEST["country"]) ? post_check($_REQUEST["country"]) : '';
     $unit = isset($_REQUEST["unit"]) ? post_check($_REQUEST["unit"]) : '';
     $longs = isset($_REQUEST["longs"]) ? post_check($_REQUEST["longs"]) : '';
     $widths = isset($_REQUEST["widths"]) ? post_check($_REQUEST["widths"]) : '';
     $heights = isset($_REQUEST["heights"]) ? post_check($_REQUEST["heights"]) : '';
     $unitW = isset($_REQUEST["unitW"]) ? post_check($_REQUEST["unitW"]) : '';
     $weight = isset($_REQUEST["weights"]) ? post_check($_REQUEST["weights"]) : '';
     $maxItem = 4;
     $moreItem = 0;
     $topNum = 3;
     if (!in_array($addId, array(1), true)) {
         show_message($this->smarty, "The delivery address parameter error!", "");
         exit;
     }
     if (empty($country)) {
         show_message($this->smarty, "Recipient countries parameter error!", "");
         exit;
     }
     if (!in_array($unit, array('CM', 'IN', 'M'), true)) {
         show_message($this->smarty, "A unit of volume parameters error!", "");
         exit;
     }
     if (!in_array($unitW, array('KG', 'LB', 'OZ'), true)) {
         show_message($this->smarty, "A unit of weight parameters error!", "");
         exit;
     }
     if (is_numeric($longs) && is_numeric($widths) && is_numeric($heights)) {
         if ($longs <= 0 || $widths <= 0 || $heights <= 0) {
             show_message($this->smarty, "Size (L/W/H) parameter error!", "");
             exit;
         } else {
             if ($unit == 'CM') {
                 $volWeight = round($longs * $widths * $heights / 6000, 4);
             }
             if ($unit == 'IN') {
                 $volWeight = round($longs * $widths * $heights * 30.48 / 6000, 4);
             }
             if ($unit == 'M') {
                 $volWeight = round($longs * $widths * $heights * 100 / 6000, 4);
             }
         }
     }
     if (is_numeric($weight)) {
         if ($weight <= 0) {
             show_message($this->smarty, "The weight parameter error!", "");
             exit;
         } else {
             if ($unitW == 'KG') {
                 $weight = round($weight, 4);
             }
             if ($unitW == 'LB') {
                 $weight = round($weight * 0.4535924, 4);
             }
             if ($unitW == 'OZ') {
                 $weight = round($weight * 0.0283495, 4);
             }
         }
     }
     if ($volWeight > $weight) {
         $realWeight = $volWeight;
     } else {
         $realWeight = $weight;
     }
     if (empty($realWeight)) {
         show_message($this->smarty, "Weight is 0, please check!", "");
         exit;
     }
     $countrys = json_decode(OpenApiAct::act_getCountriesStandard(), true);
     $data['countrys'] = $countrys['data'];
     $data['addId'] = $addId;
     $data['country'] = $country;
     $data['unit'] = $unit;
     $data['unitW'] = $unitW;
     $data['longs'] = $longs;
     $data['widths'] = $widths;
     $data['heights'] = $heights;
     $data['weights'] = $weight;
     $data['openFees'] = TrackShipFeeAct::actGetShipFee($addId, $country, $realWeight);
     $data['maxItem'] = $maxItem;
     $data['topNum'] = $topNum;
     $data['moreItem'] = count($data['openFees']) - ($maxItem + 1);
     return $data;
 }