Esempio n. 1
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;
 }