public function view_modify() { $this->smarty->assign('title', '修改运费价目'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; $chid = isset($_GET['chid']) ? intval($_GET['chid']) : 0; //渠道ID $chname = isset($_GET['chname']) ? post_check($_GET['chname']) : ""; //渠道别名 if (empty($id) || !is_numeric($id) || empty($chname)) { redirect_to("index.php?mod=channelPrice&act=index"); exit; } if (in_array($chname, array('ups_calcfree', 'usps_calcfree', 'usps_first_class', 'ups_ground_commercia', 'sv_sure_post'))) { $zoneList = CountriesUsazoneModel::listZone(); $this->smarty->assign('zoneList', $zoneList); //分区列表 } $channelPrice = new ChannelPriceAct(); $res = $channelPrice->actModify($chname, $id); $carrierId = ChannelPriceModel::getCarrierId($chid); if (in_array($chname, array('usps_first_class', 'ups_ground_commercia', 'sv_sure_post'))) { $weights = explode("-", $res['pr_kilo_next']); $minW = $weights[0]; $maxW = $weights[1]; } $this->smarty->assign('chid', $chid); $this->smarty->assign('carrierId', $carrierId); $this->smarty->assign('pr_group', $res['pr_group']); $this->smarty->assign('pr_kilo', $res['pr_kilo']); $this->smarty->assign('pr_discount', $res['pr_discount']); $this->smarty->assign('pr_handlefee', $res['pr_handlefee']); $this->smarty->assign('pr_country', stripslashes($res['pr_country'])); $this->smarty->assign('pr_kilo_next', $res['pr_kilo_next']); $this->smarty->assign('weight_from', $minW); $this->smarty->assign('weight_to', $maxW); $this->smarty->assign('pr_file', $res['pr_file']); $this->smarty->assign('pr_isfile', $res['pr_isfile']); $this->smarty->assign('pr_air', $res['pr_air']); $this->smarty->assign('pr_other', $res['pr_other']); $this->smarty->assign('id', $res['id']); $this->smarty->assign('chname', $chname); if ($chname == 'hkpostsf_hk' || $chname == 'hkpostrg_hk') { $this->smarty->display('channelPriceModifyHk.htm'); } else { if ($chname == 'ems_shenzhen') { $this->smarty->display('channelPriceModifyEms.htm'); } else { if (in_array($chname, array('eub_shenzhen', 'eub_fujian', 'eub_jiete'))) { $this->smarty->display('channelPriceModifyEub.htm'); } else { if ($chname == 'dhl_shenzhen') { $this->smarty->display('channelPriceModifyDhl.htm'); } else { if ($chname == 'fedex_shenzhen') { $this->smarty->display('channelPriceModifyFedex.htm'); } else { if ($chname == 'globalmail_shenzhen') { $this->smarty->display('channelPriceModifyGlobalmail.htm'); } else { if (in_array($chname, array('ups_us', 'ups_uk', 'ups_fr', 'ups_ger'))) { $this->smarty->display('channelPriceModifyUpsus.htm'); } else { if ($chname == 'ups_calcfree') { $this->smarty->display('channelPriceModifyUps.htm'); } else { if ($chname == 'usps_calcfree') { $this->smarty->display('channelPriceModifyUsps.htm'); } else { if (in_array($chname, array('sto_shenzhen', 'zto_shenzhen', 'yto_shenzhen', 'yundaex_shenzhen', 'best_shenzhen', 'jym_shenzhen', 'gto_shenzhen'))) { $countrylist = TransOpenApiModel::getCountriesChina(); //中国城市名称列表 $this->smarty->assign('countrylist', $countrylist); $this->smarty->display('channelPriceModifyChina.htm'); } else { if (in_array($chname, array('ruston_packet_py', 'ruston_packet_gh', 'ruston_large_package'))) { $this->smarty->display('channelPriceModifyRuston.htm'); } else { if (in_array($chname, array('sg_dhl_gm_gh', 'sg_dhl_gm_py'))) { $this->smarty->display('channelPriceModifySGDHLGM.htm'); } else { if (in_array($chname, array('ruishi_xb_py', 'ruishi_xb_gh'))) { $this->smarty->display('channelPriceModifyRuishi.htm'); } else { if (in_array($chname, array('bilishi_xb_py', 'bilishi_xb_gh'))) { $this->smarty->display('channelPriceModifyBilishi.htm'); } else { if ($chname == 'usps_first_class') { $this->smarty->display('channelPriceModifySVUSPS.htm'); } else { if ($chname == 'ups_ground_commercia') { $this->smarty->display('channelPriceModifySVUPS.htm'); } else { if ($chname == 'sv_sure_post') { $this->smarty->display('channelPriceModifySVSurePost.htm'); } else { if (in_array($chname, array('aoyoubao_py', 'aoyoubao_gh'))) { $this->smarty->display('channelPriceModifyAyb.htm'); } else { $this->smarty->display('channelPriceModify.htm'); } } } } } } } } } } } } } } } } } } }
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'); }
/** * TransOpenApiAct::act_getCountriesChina() * 获取全部或某个地区ID的区域信息 * @param int $areaId 区域ID * @param int $is_new 是否强制更新,默认0不强制 * @return array */ public function act_getCountriesChina() { $areaId = isset($_REQUEST['areaId']) ? post_check($_REQUEST['areaId']) : ""; $flag = preg_match("/^(all|\\d+)\$/", $areaId); $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 (empty($areaId) || !$flag) { self::$errCode = 307; self::$errMsg = '区域ID参数传递错误!'; return false; } if ($areaId == "all") { $areaId = ""; } $cacheName = md5("trans_countries_china_" . $areaId); $memc_obj = new Cache(C('CACHEGROUP')); $countryInfo = $memc_obj->get_extral($cacheName); if (!empty($countryInfo) && empty($is_new)) { return unserialize($countryInfo); } else { $countryInfo = TransOpenApiModel::getCountriesChina($areaId); $isok = $memc_obj->set_extral($cacheName, serialize($countryInfo), 3600); if (!$isok) { self::$errCode = 306; self::$errMsg = 'memcache缓存出错!'; //return false; } return $countryInfo; } }