public function view_index() { $this->smarty->assign('title', '跟踪号信息统计'); $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('carrierList', $carrierList); //运输方式列表 $queryObj = new ShipfeeQueryModel(); $countrylist = $queryObj->getStandardCountryName(); //标准国家名称列表 $this->smarty->assign('countrylist', $countrylist); $this->smarty->display('trackWarnStat.htm'); }
public function view_index() { $trackWarnInfo = new TrackWarnInfoAct(); $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1; $countryId = isset($_GET['countryId']) ? intval($_GET['countryId']) : 0; $carrierId = isset($_GET['carrierId']) ? intval($_GET['carrierId']) : 0; $channelId = isset($_GET['channelId']) ? intval($_GET['channelId']) : 0; $type = isset($_GET['type']) ? trim($_GET['type']) : ''; $key = isset($_GET['key']) ? post_check(trim($_GET['key'])) : ''; $timeNode = isset($_GET['timeNode']) ? post_check(trim($_GET['timeNode'])) : ''; $warnLevel = isset($_GET['warnLevel']) ? intval($_GET['warnLevel']) : ''; $is_warn = isset($_GET['is_warn']) ? intval($_GET['is_warn']) : 1; $status = isset($_GET['status']) ? intval($_GET['status']) : -1; //读取用户细颗粒权限 $competences = $_SESSION['competences']; if (!empty($competences['competence'])) { $competences = json_decode($competences['competence'], true); } if (!in_array($carrierId, $competences['carrierId'])) { if (isset($competences['carrierId'])) { $carrierId = implode(",", $competences['carrierId']); } } if (!in_array($channelId, $competences['channelId'])) { if (isset($competences['channelId'])) { $channelId = implode(",", $competences['channelId']); } } $condition = "1"; if (!empty($countryId)) { $condition .= " AND countryId = '{$countryId}'"; } if ($status >= 0) { $condition .= " AND status = '{$status}'"; } if (!empty($carrierId)) { $condition .= " AND carrierId IN({$carrierId})"; } if (!empty($channelId)) { $condition .= " AND channelId IN({$channelId})"; } if (!empty($timeNode)) { if (!in_array($timeNode, array('scanTime', 'lastTime', 'trackTime'))) { redirect_to("index.php?mod=trackWarnInfo&act=index"); } $startTime = isset($_GET['startTime']) ? strtotime(trim($_GET['startTime']) . " 00:00:00") : strtotime(date("Y-m-d", time()) . " 00:00:00"); $endTime = isset($_GET['endTime']) ? strtotime(trim($_GET['endTime']) . " 23:59:59") : strtotime(date("Y-m-d", time()) . " 23:59:59"); if ($startTime && $endTime) { $condition .= ' AND ' . $timeNode . " BETWEEN '" . $startTime . "' AND " . "'" . $endTime . "'"; } } if ($type && $key) { if (!in_array($type, array('orderSn', 'trackNumber', 'recordId', 'platAccount', 'platForm'))) { redirect_to("index.php?mod=trackWarnInfo&act=index"); } $condition .= ' AND ' . $type . " = '" . $key . "'"; } if ($warnLevel === 0) { //全部节点预警 $condition .= " AND warnLevel > 0"; } elseif ($warnLevel === -1) { //没预警节点 $condition .= " AND warnLevel = 0"; } elseif (!empty($warnLevel)) { //某个预警节点 $warnStr = str_pad($warnStr, $warnLevel - 1, "_", STR_PAD_LEFT); switch ($is_warn) { case 1: $condition .= " AND warnLevel like '{$warnStr}1%'"; break; case 2: $condition .= " AND warnLevel like '{$warnStr}0%' AND nodeEff like '{$warnStr}1%'"; break; case 3: $condition .= " AND nodeEff like '{$warnStr}1%'"; break; default: $condition .= " AND warnLevel like '{$warnStr}1%'"; } } // 暂时下线以下条件 // if($condition == '1') { // $startTime = strtotime("-1 day"." 00:00:00"); // $endTime = strtotime(date('Y-m-d')." 23:59:59"); // $timeNode = 'scanTime'; // $condition .= " AND {$timeNode} BETWEEN {$startTime} AND {$endTime}"; // } // 获取符合条件的数据并分页 $pagenum = 20; //每页显示的个数 $res = $trackWarnInfo->actList($condition, $curpage, $pagenum); $total = $trackWarnInfo->actListCount($condition); //页面总数量 $startTimeValue = $startTime ? date('Y-m-d', $startTime) : ''; $endTimeValue = $endTime ? date('Y-m-d', $endTime) : ''; $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 = '暂无数据'; } $queryObj = new ShipfeeQueryModel(); $countrylist = $queryObj->getStandardCountryName(); //标准国家名称列表 $carrierList = TransOpenApiModel::getCarrier(2); $statusList = C('TRACK_STATUS_DETAIL'); //替换页面内容变量 $this->smarty->assign('title', '运输方式跟踪号预警管理'); $this->smarty->assign('key', $key); //关键词 $this->smarty->assign('type', $type); //条件选项 $this->smarty->assign('countryId', $countryId); //国家ID $this->smarty->assign('carrierId', $carrierId); //运输方式ID $this->smarty->assign('status', $status); //跟踪号状态 $this->smarty->assign('is_warn', $is_warn); //跟踪号状态 $this->smarty->assign('lists', $res); //数据集 $this->smarty->assign('carrierList', $carrierList); //运输方式列表 $this->smarty->assign('countrylist', $countrylist); $this->smarty->assign('statusList', $statusList); //跟踪号状态列表 $this->smarty->assign('pageStr', $pageStr); //分页输出 $this->smarty->assign('timeNode', $timeNode); //时间条件 $this->smarty->assign('startTimeValue', $startTimeValue); //开始时间 $this->smarty->assign('endTimeValue', $endTimeValue); //结束时间 $this->smarty->display('trackWarnInfo.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_getBestCarrier() * 固定运输方式费用接口(已废弃) * @param string $country 国家 * @param float $weight 重量 * @param int $shaddr 发货地ID(预留) * @param string $postcode 邮政编码 * @param string $noShipId 邮政编码 * @return json string; */ public function act_getBestCarrier() { $endTime = strtotime("2014-03-31 00:00:01"); if ($endTime < time()) { self::$errCode = 90000; self::$errMsg = '此接口服务已过期,请联系物流系统负责人更换!'; return; } $country = isset($_REQUEST['country']) ? rawurldecode(trim($_REQUEST['country'])) : ''; $weight = isset($_REQUEST['weight']) ? abs(floatval($_REQUEST['weight'])) : 0; $shipaddr = isset($_REQUEST['shaddr']) ? post_check($_REQUEST['shaddr']) : ''; $postcode = isset($_REQUEST['postcode']) ? post_check($_REQUEST['postcode']) : ''; $noShipId = isset($_REQUEST['noshipid']) ? post_check($_REQUEST['noshipid']) : ''; //print_r($_REQUEST);exit; if (empty($country) || empty($weight) || empty($shipaddr)) { //参数不完整 self::$errCode = 301; self::$errMsg = '参数信息不完整'; return; } $queryobj = new ShipfeeQueryModel(); $stdc = $queryobj->translateMinorityLangToStd($country); //将小语种转换为标准英文 $countrystd = ''; if (empty($stdc)) { //没找到 则默认为标准的英文名 $countrystd = $country; } else { $countrystd = $stdc['countryName']; } $data = array('postcode' => $postcode); /*根据发货地获取相应的发货方式列表*/ $shiplist = $queryobj->getShipListByShipaddr($shipaddr, $noShipId); /* 计算每一种发货方式的运费 */ $shipcalculateresult = 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['channelId'] = $ch['id']; //渠道ID $result['carrierId'] = $ch['carrierId']; //运输方式ID $result['carriername'] = $shipval['carrierNameCn']; //运输方式名 $result['paname'] = ''; //分区名称 $carriercountryname = $queryobj->translateStdCountryNameToShipCountryName($countrystd, $shipval['id']); if (empty($carriercountryname)) { //对照表中没有找到对应的信息 则默认为标准国家名称 $carriercountryname = $countrystd; } $re = $queryobj->calculateShipfee($ch['channelAlias'], $weight, $carriercountryname, $data); if (!$re) { continue; } $result['shipfee'] = $re['fee']; $result['rate'] = $re['discount']; $shipcalculateresult[] = $result; } } $minship = array(); $eubFee = array(); $mineubship = array(); foreach ($shipcalculateresult as $val) { if (empty($minship)) { $minship = $val; } if ($val['shipfee'] < $minship['shipfee']) { $minship = $val; } if ($val['carrierId'] == '6' && ($val['shipfee'] < $mineubship['shipfee'] || empty($mineubship))) { $mineubship = $val; } } if (empty($minship)) { self::$errCode = 303; self::$errMsg = '没有找到最优运输方式'; return; } self::$errCode = 300; self::$errMsg = 'ok'; // 如果运输方式为中国邮政平邮或挂号且总重量少于2KG if (in_array($minship['carrierId'], array(1, 2)) && $weight <= 2) { if (!empty($mineubship['shipfee']) && !empty($minship['shipfee']) && ($mineubship['shipfee'] - $minship['shipfee'] <= 2 || $mineubship['shipfee'] / $minship['shipfee'] - 1 <= 0.09)) { return array('fee' => $mineubship['shipfee'], 'carrierId' => $mineubship['carrierId'], 'channelId' => $mineubship['channelId']); } } return array('fee' => $minship['shipfee'], 'carrierId' => $minship['carrierId'], 'channelId' => $minship['channelId']); }