/**
  * TransitCenterAct::actIndex()
  * 列出符合条件的数据并分页显示
  * @param string $condition 查询条件
  * @param integer $curpage 页码
  * @param integer $pagenum 每页个数
  * @return array 
  */
 public function actIndex()
 {
     $data = array();
     $condition = '';
     $transitCenter = new TransitCenterModel();
     //接收参数生成条件
     $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1;
     $type = isset($_GET['type']) ? trim($_GET['type']) : '';
     $key = isset($_GET['key']) ? post_check(trim($_GET['key'])) : '';
     $condition .= "1";
     if ($type && $key) {
         if (!in_array($type, array('cn_title', 'en_title'))) {
             redirect_to("index.php?mod=transitCenter&act=index");
         }
         $condition .= ' AND ' . $type . " = '" . $key . "'";
     }
     //获取符合条件的数据并分页
     $pagenum = 20;
     $total = $transitCenter->modListCount($condition);
     $res = $transitCenter->modList($condition, $curpage, $pagenum);
     $page = new Page($total, $pagenum, '', 'CN');
     $pageStr = "";
     if ($res) {
         if ($total > $pagenum) {
             $pageStr = $page->fpage(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9));
         } else {
             $pageStr = $page->fpage(array(0, 1, 2, 3));
         }
     } else {
         $pageStr = '暂无数据';
     }
     //封装数据返回
     $data['key'] = $key;
     $data['type'] = $type;
     $data['lists'] = $res;
     $data['pages'] = $pageStr;
     self::$errCode = TransitCenterModel::$errCode;
     self::$errMsg = TransitCenterModel::$errMsg;
     if (self::$errCode != 0) {
         show_message($this->smarty, self::$errMsg, "");
         return false;
     }
     return $data;
 }
Exemple #2
0
 public function view_query()
 {
     $ship_add = isset($_POST['ship_add']) ? abs(intval($_POST['ship_add'])) : 0;
     //发货地址ID
     $ship_country = isset($_POST['ship_country']) ? abs(intval($_POST['ship_country'])) : 0;
     //发往国家ID
     $ship_weight = isset($_POST['ship_weight']) ? abs(floatval($_POST['ship_weight'])) : 0;
     //重量
     $ship_carrier = isset($_POST['ship_carrier']) ? abs(intval($_POST['ship_carrier'])) : 0;
     //运输方式ID
     $ship_postcode = isset($_POST['ship_postcode']) ? trim($_POST['ship_postcode']) : '';
     //待定
     $ship_tid = isset($_POST['ship_tid']) ? intval($_POST['ship_tid']) : 0;
     $errMsg = "";
     //错误信息
     $this->smarty->assign('title', '运费查询结果');
     $queryObj = new ShipfeeQueryModel();
     $addrlist = $queryObj->getAllShipAddrList();
     //发货地列表
     $this->smarty->assign('addrlist', $addrlist);
     if ($ship_add == 5) {
         $countrylist = TransOpenApiModel::getCountriesChina();
         //中国地区名称列表
         $this->smarty->assign('countrylist', $countrylist);
     } else {
         $countrylist = $queryObj->getStandardCountryName();
         //标准国家名称列表
         $this->smarty->assign('countrylist', $countrylist);
         $transitlist = TransitCenterModel::modList(1, 1, 200);
         $this->smarty->assign('transitlist', $transitlist);
     }
     $carrierlist = TransOpenApiModel::getCarrierByAdd($ship_add);
     //获得所有的运输方式
     $this->smarty->assign('carrierlist', $carrierlist);
     $this->smarty->assign('ship_add', $ship_add);
     $this->smarty->assign('ship_tid', $ship_tid);
     $this->smarty->assign('ship_country', $ship_country);
     $this->smarty->assign('ship_weight', $ship_weight);
     $this->smarty->assign('ship_carrier', $ship_carrier);
     $this->smarty->assign('ship_postcode', $ship_postcode);
     if (empty($ship_add)) {
         $errMsg .= "发货地址有误!<br/>";
     }
     if (empty($ship_country) && $ship_add != 2) {
         $errMsg .= "发往国家/地区有误!<br/>";
     }
     if (empty($ship_weight)) {
         $errMsg .= "重量输入有误!<br/>";
     }
     //是否存在国家/地区
     if ($ship_add == 1) {
         $countryinfo = $queryObj->getStdCountryNameById($ship_country);
         if (empty($countryinfo)) {
             $errMsg .= "发往国家不存在!<br/>";
         }
     }
     if ($ship_add == 5) {
         $countryinfo = TransOpenApiModel::getCountriesChina($ship_country);
         if (empty($countryinfo)) {
             $errMsg .= "发往地区不存在!<br/>";
         }
     }
     //根据发货地ID获取相应的发货方式列表
     $shiplist = $queryObj->getShipListByShipaddr($ship_add);
     if (!empty($ship_carrier)) {
         //如果选择了运输方式 验证改运输方式是否存在于选择的发货地
         $exist = FALSE;
         foreach ($shiplist as $shval) {
             if ($shval['id'] == intval($ship_carrier)) {
                 $exist = TRUE;
                 unset($shiplist);
                 $shiplist = array($shval);
                 break;
             }
         }
         if (!$exist) {
             $errMsg .= "发货地和发货方式不匹配!";
         }
     }
     // 计算每一种发货方式的运费
     $shipfeeResult = array();
     //运费计算结果集
     foreach ($shiplist as $shipval) {
         $result = array();
         $channel = $queryObj->getChannelInfo($shipval['id']);
         if (empty($channel)) {
             //没找到合适的渠道信息 则跳过该运输方式
             continue;
         }
         foreach ($channel as $ch) {
             $result['chname'] = $ch['channelName'];
             //渠道名
             $result['carriername'] = $shipval['carrierNameCn'];
             //运输方式名
             $carriercountryname = $queryObj->translateStdCountryNameToShipCountryName($countryinfo['countryNameEn'], $shipval['id']);
             if ($ship_add == 5) {
                 $res = $queryObj->calculateShipfee($ch['channelAlias'], $ship_weight, $ship_country, array('postCode' => $ship_postcode, 'transitId' => $ship_tid));
             } else {
                 $res = $queryObj->calculateShipfee($ch['channelAlias'], $ship_weight, $carriercountryname, array('postCode' => $ship_postcode, 'transitId' => $ship_tid));
             }
             if (!$res) {
                 //FALSE 跳过
                 continue;
             }
             $result['totalfee'] = $res['totalfee'];
             $result['shipfee'] = $res['fee'];
             $result['rate'] = $res['discount'];
             $shipfeeResult[] = $result;
         }
     }
     $this->smarty->assign('errMsg', $errMsg);
     $this->smarty->assign('lists', $shipfeeResult);
     $this->smarty->display('shipfeeQuery.htm');
 }
 /**
  * CountriesUsazoneAct::actModify()
  * 返回某个美国邮政分区信息
  * @param int $id 查询ID
  * @return array 
  */
 public function actModify()
 {
     $data = array();
     $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0;
     if (empty($id)) {
         show_message($this->smarty, "ID不能为空?", "");
         return false;
     }
     $data['id'] = $id;
     $data['lists'] = TransitCenterModel::modList(1, 1, 200);
     $data['res'] = CountriesUsazoneModel::modModify($id);
     if (empty($data['res'])) {
         show_message($this->smarty, "数据为空,请返回确认条件!", "");
         return false;
     }
     self::$errCode = CountriesUsazoneModel::$errCode;
     self::$errMsg = CountriesUsazoneModel::$errMsg;
     if (self::$errCode != 0) {
         show_message($this->smarty, self::$errMsg, "");
         return false;
     }
     return $data;
 }