/** * ApiVisitStatAct::actIndex() * 列出符合条件的数据并分页显示 * @param string $condition 查询条件 * @param integer $curpage 页码 * @param integer $pagenum 每页个数 * @return array */ public function actIndex() { $data = array(); $condition = ''; $trackEmailStat = new ApiVisitStatModel(); //接收参数生成条件 $apiId = isset($_GET['apiId']) ? abs(intval($_GET['apiId'])) : 0; $curpage = isset($_GET['page']) ? abs(intval($_GET['page'])) : 1; $timeNode = isset($_GET['timeNode']) ? post_check(trim($_GET['timeNode'])) : ''; $condition .= "1"; if (!empty($apiId)) { $condition .= " AND apiId = '{$apiId}'"; } if (!empty($timeNode)) { if (!in_array($timeNode, array('firstTime', 'lastTime'))) { redirect_to("index.php?mod=apiVisitStat&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 . "'"; } } //获取符合条件的数据并分页 $pagenum = 20; $total = $trackEmailStat->modListCount($condition); $res = $trackEmailStat->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['apiId'] = $apiId; $data['lists'] = $res; $data['pages'] = $pageStr; $data['timeNode'] = $timeNode; $data['startTime'] = $startTime ? date('Y-m-d', $startTime) : ''; $data['endTime'] = $endTime ? date('Y-m-d', $endTime) : ''; $data['apiList'] = TransOpenApiModel::getApiCompetenceList(); self::$errCode = trackEmailStatModel::$errCode; self::$errMsg = trackEmailStatModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } return $data; }
public function view_index() { $this->smarty->assign('title', '跟踪号信息报表导出'); $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('carrierList', $carrierList); //运输方式列表 $statusList = C('TRACK_STATUS_DETAIL'); $this->smarty->assign('statusList', $statusList); //跟踪号状态列表 $this->smarty->display('trackWarnExport.htm'); }
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_modify() { $this->smarty->assign('title', '修改小语种国家'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=countriesSmall&act=index"); exit; } $countriesSmall = new CountriesSmallAct(); $res = $countriesSmall->actModify($id); $countriesList = TransOpenApiModel::getCountriesStandard(); $this->smarty->assign('lists', $countriesList); //标准国家列表 $this->smarty->assign('small_name', $res['small_country']); $this->smarty->assign('en_name', $res['countryName']); $this->smarty->assign('code_name', $res['conversionType']); $this->smarty->assign('id', $res['id']); $this->smarty->display('countriesSmallModify.htm'); }
public function view_modify() { $this->smarty->assign('title', '修改运输方式国家'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=countriesShip&act=index"); exit; } $countriesShip = new CountriesShipAct(); $res = $countriesShip->actModify($id); $countriesList = TransOpenApiModel::getCountriesStandard(); $this->smarty->assign('countries', $countriesList); //标准国家列表 $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('lists', $carrierList); //运输方式列表 $this->smarty->assign('carrier_name', $res['carrier_country']); $this->smarty->assign('en_name', $res['countryName']); $this->smarty->assign('ship_id', $res['carrierId']); $this->smarty->assign('id', $res['id']); $this->smarty->display('countriesShipModify.htm'); }
public function view_modify() { $this->smarty->assign('title', '修改运输平台'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=carrierPlatForm&act=index"); exit; } $carrierPlatForm = new CarrierPlatFormAct(); $res = $carrierPlatForm->actModify($id); $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('lists', $carrierList); //运输方式列表 $platFormlist = TransOpenApiModel::getPlatForm("ALL"); //平台列表 $this->smarty->assign('platFormlist', $platFormlist); $this->smarty->assign('ship_id', $res['carrierId']); $this->smarty->assign('plat_id', $res['platId']); $this->smarty->assign('ship_name', $res['shipName']); $this->smarty->assign('ship_service', $res['shipService']); $this->smarty->assign('id', $res['id']); $this->smarty->display('carrierPlatFormModify.htm'); }
/** * TrackWarnNodeDataAct::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'] = TransOpenApiModel::getTrackNodeList(61); //预警节点列表 $data['res'] = TrackWarnNodeDataModel::modModify($id); if (empty($data['res'])) { show_message($this->smarty, "数据为空,请返回确认条件!", ""); return false; } self::$errCode = TrackWarnNodeDataModel::$errCode; self::$errMsg = TrackWarnNodeDataModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } return $data; }
/** * TransOpenApiModel::assignTrackNumbers() * 分配跟踪号 * @param int $carrierId 运输方式ID * @param int $orderId 订单编号ID * @param int $channelId 渠道ID(可选) * @param string $country 所属国家(可选) * @return array */ public static function assignTrackNumbers($carrierId, $orderId, $country = '', $channelId = 0) { self::initDB(); $where = ''; if (empty($country)) { $where = "carrierId = '{$carrierId}' AND orderId = '{$orderId}' AND (countrys = '' OR countrys IS NULL)"; } else { $where = "carrierId = '{$carrierId}' AND orderId = '{$orderId}' AND countrys = '{$country}'"; } //已经分配的订单跟踪号再次分配时直接返回原来的跟踪号 $res = TrackNumberModel::assignTrackNumber($where); if (!empty($res['trackNumber'])) { return array("trackNumber" => $res['trackNumber']); } //兼容渠道 if (empty($channelId) && $carrierId != 2) { $where = ''; } else { $where = " AND channelId = '{$channelId}'"; } //新订单跟踪号分配 if (empty($country)) { $where = "carrierId = '{$carrierId}' AND orderId = 0 AND is_lock = 0 AND (countrys = '' OR countrys IS NULL)" . $where; } else { $where = "carrierId = '{$carrierId}' AND orderId = 0 AND is_lock = 0 AND countrys = '{$country}'" . $where; } $res = TrackNumberModel::assignTrackNumber($where); if (empty($res['trackNumber'])) { self::$errCode = 10001; self::$errMsg = "当前运输方式已无跟踪号可以分配"; return false; } $tracknum = $res['trackNumber']; $id = $res['id']; //增加锁机制防止并发异常 $res = TrackNumberModel::updateTrackNumber($id, array("is_lock" => 1), true); if (!$res) { self::$errCode = 10002; self::$errMsg = "订单ID{$orderId}=锁定{$id}=跟踪号:{$tracknum}失败,请不要过度频繁申请跟踪号!"; return false; } //更新分配的跟踪号信息 $data = array("orderId" => $orderId, "assignTime" => time()); $res = TrackNumberModel::updateTrackNumber($id, $data, true); if (!$res) { self::$errCode = TrackNumberModel::$errCode; self::$errMsg = TrackNumberModel::$errMsg; return false; } else { return array("trackNumber" => $tracknum); } }
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'); }
} $pages = ceil(count($idArr) / $nums); for ($i = 1; $i <= $pages; $i++) { for ($j = 0; $j < $nums; $j++) { $id = array_pop($idArr); if (!empty($id)) { $idArrs[] = $id; } } $ids = implode(",", $idArrs); echo date('Y-m-d H:i:s') . "===第{$i}/{$pages}批==={$ids}\n"; unset($idArrs); $data = TransOpenApiModel::getErpOrderInfo($ids); $data = json_decode($data, true); foreach ($data as $v) { $vals = array('weight' => $v['realWeight'], 'cost' => $v['ordershipfee'], 'toCountry' => $v['ebay_countryname'], 'recordId' => $v['recordnumber'], 'platAccount' => $v['ebay_account'], 'platForm' => $v['PlatForm'], 'toCity' => $v['ebay_city'], 'toUserId' => $v['ebay_userid'], 'toUserEmail' => $v['ebay_usermail'], 'toMarkTime' => $v['ShippedTime'], 'fhTime' => $v['fhTime']); print_r($vals); $res = TransOpenApiModel::updateTrackOrderInfo($v['ebay_id'], $vals); echo $v['ebay_id'], "=====更新完成,状态", $res, "\n"; } echo date('Y-m-d H:i:s') . "===第{$i}/{$pages}批===数据同步完毕\n"; unset($data); } } if (!count($numberList)) { print_r($argv); echo "无数据,请确认你输入的条件!\n"; } echo "\n\n全部数据抓取执行完毕,完成时间" . date('Y-m-d H:i:s', time()) . "\n"; $dbConn->close(); exit;
public function view_modify() { $this->smarty->assign('title', '修改运输方式'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=carrierManage&act=index"); exit; } $carrierManage = new CarrierManageAct(); $res = $carrierManage->actModify($id); $this->smarty->assign('cn_name', $res['carrierNameCn']); $this->smarty->assign('en_name', $res['carrierNameEn']); $this->smarty->assign('ship_ali', $res['carrierAli']); $this->smarty->assign('ship_abb', $res['carrierAbb']); $this->smarty->assign('ship_index', $res['carrierIndex']); $this->smarty->assign('ship_logo', $res['carrierLogo']); $this->smarty->assign('ship_type', $res['type']); $this->smarty->assign('min_weight', $res['weightMin']); $this->smarty->assign('max_weight', $res['weightMax']); $this->smarty->assign('ship_day', $res['timecount']); $this->smarty->assign('ship_note', $res['note']); $this->smarty->assign('is_track', $res['is_track']); $this->smarty->assign('id', $res['id']); $platFormlist = TransOpenApiModel::getPlatForm("ALL"); //平台列表 $this->smarty->assign('platFormlist', $platFormlist); $res = CarrierManageModel::listCarrierPlatForm($id); //运输方式对应平台列表 $platList = array(); foreach ($res as $v) { array_push($platList, $v['platformId']); } $this->smarty->assign('platList', $platList); $addrlist = TransOpenApiModel::getShipAddress(); //发货地列表 $this->smarty->assign('addrlist', $addrlist); $res = ShippingAddressModel::getAddByCarrierId($id); $ship_add = isset($res['id']) ? $res['id'] : 0; $this->smarty->assign('ship_add', $ship_add); $this->smarty->display('carrierManageModify.htm'); }
$channelId = TransOpenApiModel::getCarrierChannelByPostName($detailInfo['numberInfo']['carrierId'], $val['postion']); if (!empty($channelId)) { $detailInfo['numberInfo']['channelId'] = $channelId; } else { $detailInfo['numberInfo']['channelId'] = $chidArr[$v['carrierId']]; } if (eregi("^(R.+SG)", $v['trackNumber'])) { $detailInfo['numberInfo']['channelId'] = 70; } if (eregi("^(E.+SG)", $v['trackNumber'])) { $detailInfo['numberInfo']['channelId'] = 71; } } $detailInfo['trackingEventList'][$key]['place'] = $val['postion']; $detailInfo['trackingEventList'][$key]['details'] = $val['event']; $detailInfo['trackingEventList'][$key]['date'] = date('Y-m-d H:i:s', $val['trackTime']); } print_r($detailInfo['numberInfo']); $res_warn = TransOpenApiModel::autoWarnInfo($detailInfo); //自动预警 echo $res_warn, "=====", date('Y-m-d h:i:s', time()), "\n"; } } } if (!count($numberList)) { print_r($argv); echo "无数据,请确认你输入的条件!\n"; } echo "\n\n全部数据抓取执行完毕,完成时间" . date('Y-m-d H:i:s', time()) . "\n"; $dbConn->close(); exit;
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'); }
/** * CarrierOpenAct::act_updateCarrierOpen() * 修改开放运输方式 * @param string $carrierAbb 简称 * @param string $carrierIndex 字母索引 * @param string $carrierAging 时效 * @param string $carrierNote 备注 * @param float $carrierDis 原价后折扣 * @param string $carrierId 运输方式ID * @return bool */ public function act_updateCarrierOpen() { $id = isset($_POST["id"]) ? abs(intval(trim($_POST["id"]))) : 0; $carrierAbb = isset($_POST["carrierAbb"]) ? post_check($_POST["carrierAbb"]) : ""; $carrierEn = isset($_POST["carrierEn"]) ? post_check($_POST["carrierEn"]) : ""; $carrierIndex = isset($_POST["carrierIndex"]) ? post_check($_POST["carrierIndex"]) : ""; $carrierId = isset($_POST["carrierId"]) ? abs(intval(trim($_POST["carrierId"]))) : 0; $carrierDis = isset($_POST["carrierDiscount"]) ? floatval(trim($_POST["carrierDiscount"])) : 0; $carrierAging = isset($_POST["carrierAging"]) ? post_check($_POST["carrierAging"]) : ""; $carrierNote = isset($_POST["carrierNote"]) ? post_check($_POST["carrierNote"]) : ""; $act = isset($_REQUEST["act"]) ? post_check($_REQUEST["act"]) : ""; $mod = isset($_REQUEST["mod"]) ? post_check($_REQUEST["mod"]) : ""; if (!AuthUser::checkLogin($mod, $act)) { self::$errCode = 10010; self::$errMsg = "对不起,您无数据编辑权限!"; return false; } if (empty($id) || !is_numeric($id)) { self::$errCode = 10000; self::$errMsg = "ID有误!"; return false; } if (empty($carrierId)) { self::$errCode = 10000; self::$errMsg = "运输方式参数有误!"; return false; } if (empty($carrierAbb) || !preg_match("/^[A-Z_]{1,20}\$/", $carrierAbb)) { self::$errCode = 10001; self::$errMsg = "运输方式简称参数有误!"; return false; } if (empty($carrierEn) || !preg_match("/^[A-Za-z]{1,50}\$/", $carrierEn)) { self::$errCode = 10002; self::$errMsg = "运输方式英文名称参数有误!"; return false; } if (empty($carrierIndex) || !preg_match("/^[A-Z]{1}\$/", $carrierIndex)) { self::$errCode = 10003; self::$errMsg = "字母索引参数有误!"; return false; } $carrierAdds = TransOpenApiModel::getShipAddByCarrierId($carrierId); $carrierAdd = !empty($carrierAdds) ? $carrierAdds['addressId'] : 0; $uid = $_SESSION[C('USER_AUTH_SYS_ID')]; $data = array("carrierAbb" => $carrierAbb, "carrierEn" => $carrierEn, "carrierIndex" => $carrierIndex, "carrierAdd" => $carrierAdd, "carrierId" => $carrierId, "carrierDiscount" => $carrierDis, "carrierAging" => $carrierAging, "carrierNote" => $carrierNote, "editTime" => time(), "edit_user_id" => $uid); $res = CarrierOpenModel::updateCarrierOpen($id, $data); self::$errCode = CarrierOpenModel::$errCode; self::$errMsg = CarrierOpenModel::$errMsg; return $res; }
/** * ChannelManageAct::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'] = TransOpenApiModel::getCarrier(2); $data['res'] = ChannelManageModel::modModify($id); self::$errCode = ChannelManageModel::$errCode; self::$errMsg = ChannelManageModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } return $data; }
/** * TrackWarnExportModel::exportXls() * 导出xls文件 * @param array $res 结果值 * @return string 文件路径 */ private function exportXls($tharr, $res) { $data = array(); $tdarr = array(); $dates = array(); $pos = array(); $filename = 'track_number_info_' . date('Y-m-d', time()) . '_' . $_SESSION[C('USER_AUTH_SYS_ID')]; $statusList = C('TRACK_STATUS_DETAIL'); $fileurl = WEB_URL . "temp/" . $filename . ".xls"; $filepath = WEB_PATH . "html/temp/" . $filename . ".xls"; array_push($data, $tharr); foreach ($res as $v) { $nodeList = TransOpenApiModel::getTrackNodeList($v['carrierId'], $v['channelId']); $detail = TransOpenApiModel::getTrackInfoLocal($v['trackNumber'], $v['carrierId']); $i = 0; foreach ($nodeList as $n) { foreach ($detail as $val) { $keys = explode(" ", $n['nodeKey']); foreach ($keys as $key) { if (strpos($val['event'], $key) !== false && !in_array($val['event'], array('未妥投'))) { $dates[$i] = !empty($val['trackTime']) ? date('Y-m-d H:i:s', $val['trackTime']) : ''; $pos[$i] = $val['postion']; break; } } } $i++; } $tdarr = array($v['carrierNameCn'], $v['channelName'], $v['orderSn'], $v['recordId'], $v['trackNumber'], $v['weight'], $v['cost'], date('Y-m-d H:i:s', $v['scanTime']), $v['toCountry'], $v['lastEvent'], $v['lastPostion'], date('Y-m-d H:i:s', $v['lastTime']), $statusList[$v['status']], $dates[0], $pos[0], $dates[1], $pos[1], $dates[2], $pos[2], $v['platAccount'], $v['platForm']); array_push($data, $tdarr); } require_once WEB_PATH . "lib/php-export-data.class.php"; $excel = new ExportDataExcel('file'); $excel->filename = $filepath; $excel->initialize(); foreach ($data as $row) { $excel->addRow($row); } $excel->finalize(); unset($data); if (file_exists($filepath)) { return $fileurl; } else { return "fail"; } }
public function view_modify() { $this->smarty->assign('title', '修改运输方式名预警'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=trackWarnCarrier&act=index"); exit; } $trackWarnCarrier = new TrackWarnCarrierAct(); $res = $trackWarnCarrier->actModify($id); $erpCarrierList = TransOpenApiAct::act_getErpCarrierList(); $this->smarty->assign('shipErp', $erpCarrierList); //ERP运输方式列表 $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('lists', $carrierList); //运输方式列表 $trackCarrierList = TransOpenApiModel::getTrackCarrierList(); $this->smarty->assign('shipTrack', $trackCarrierList); //跟踪号系统运输方式列表 $this->smarty->assign('carrier_name', $res['trackName']); $this->smarty->assign('ship_erp', $res['erpName']); $this->smarty->assign('ship_id', $res['carrierId']); $this->smarty->assign('id', $res['id']); $this->smarty->display('trackWarnCarrierModify.htm'); }
/** * TransOpenApiModel::getTrackCarrierList() * 获取跟踪号运输方式列表 * @return array */ public static function getTrackCarrierList() { self::initDB(); $sql = "SELECT id,carrierName FROM trans_track_carrier_name WHERE is_delete = 0 ORDER BY id ASC"; $query = self::$dbConn->query($sql); if ($query) { $res = self::$dbConn->fetch_array_all($query); return $res; } else { self::$errCode = 10000; self::$errMsg = "获取数据失败"; return false; } }
/** * TransOpenApiAct::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 { if ($type == "ALL") { $countriesInfo = TransOpenApiModel::getCountriesStandard(); } else { $countriesInfo = TransOpenApiModel::getCountriesStandard($type, $country); } $isok = $memc_obj->set_extral($cacheName, serialize($countriesInfo)); if (!$isok) { self::$errCode = 308; self::$errMsg = 'memcache缓存出错!'; //return false; } return $countriesInfo; } }
/** * TrackWarnInfoModel::trackNumberInfo() * 实时获取某个跟踪号的跟踪信息 * @param integer $carrierId 运输方式ID * @param integer $lan 跟踪语言 * @param string $trackNumber 跟踪号 * @return json string */ public static function trackNumberInfo($carrierId, $trackNumber, $lan) { self::initDB(); $data = array(); $trackName = ""; $sql = "SELECT trackName FROM " . self::$prefix . self::$tab_track_carrier . " WHERE carrierId = '{$carrierId}'"; $query = self::$dbConn->query($sql); if ($query) { $res = self::$dbConn->fetch_array($query); $trackName = isset($res['trackName']) ? trim($res['trackName']) : ""; } else { self::$errCode = 10000; self::$errMsg = "获取数据失败"; return false; } if (empty($trackName)) { self::$errCode = 10001; self::$errMsg = "跟踪名称没有获取到,请选择正确的运输方式!"; return false; } $res = TransOpenApiModel::getTrackInfo($trackNumber, $trackName, $lan); $res = json_decode($res, true); if (isset($res[trackingEventList])) { foreach ($res[trackingEventList] as $v) { array_push($data, array("postion" => $v['place'], "event" => $v['details'], "trackTime" => $v['date'])); } } else { if ($res['ReturnValue'] == '-1') { array_push($data, array("postion" => "暂无", "event" => $res['ReturnValue'] . "(跟踪号或运输方式有误或暂无跟踪信息)", "trackTime" => "暂无")); } else { array_push($data, array("postion" => "物流系统服务器", "event" => $res['ReturnValue'], "trackTime" => date('Y-m-d H:i:s', time()))); } } return json_encode($data); }
if (!is_array($res['data']) || !count($res['data'])) { print_r($argv); exit("没有数据被获取,请确认条件!"); } $res = $res['data']; foreach ($res as $v) { $timestr = date('Y-m-d h:i:s', time()); $v['ebay_tracknumber'] = str_replace(array('CNEE', 'CNRB', 'SGEM'), array('CN,EE', 'CN,RB', 'SG,EM'), $v['ebay_tracknumber']); $numArr = preg_split("/[\\|和,\\s]+/", $v['ebay_tracknumber']); foreach ($numArr as $val) { $flag = TransOpenApiModel::checkTrackNumber($val, $carrierId); if (!$flag) { if (empty($val)) { continue; } $res = TransOpenApiModel::getCountriesStandardByName($v['ebay_countryname']); $countryId = isset($res['id']) ? $res['id'] : 0; $data = array('trackNumber' => $val, 'orderSn' => $v['ebay_id'], 'weight' => round($v['orderweight'] / 1000, 3), 'cost' => $v['ordershipfee'], 'carrierId' => $carrierId, 'toCountry' => $v['ebay_countryname'], 'countryId' => $countryId, 'scanTime' => $v['scantime'], 'recordId' => $v['recordnumber'], 'platAccount' => $v['ebay_account'], 'platForm' => $v['PlatForm']); $res = TransOpenApiModel::addTrackNumber($data); if ($res) { echo $res, "======", $v['ebay_id'], "=====", $val, "===添加成功===[{$timestr}]\n"; } else { echo $res, "======", $v['ebay_id'], "=====", $val, "===添加失败===[{$timestr}]\n"; echo "原因:[", TransOpenApiModel::$errMsg, "]\n"; } } else { echo $val, "===已添加===[{$timestr}]\n"; } } } exit;
/** * ChannelPriceAct::act_delChannelPrice() * 删除运费价目 * @param int $id 运费价目ID * @return bool */ public function act_delChannelPrice() { $id = isset($_POST["id"]) ? intval(trim($_POST["id"])) : 0; $chname = isset($_POST["chname"]) ? $_POST["chname"] : ""; $act = isset($_REQUEST["act"]) ? post_check($_REQUEST["act"]) : ""; $mod = isset($_REQUEST["mod"]) ? post_check($_REQUEST["mod"]) : ""; if (!AuthUser::checkLogin($mod, $act)) { self::$errCode = 30002; self::$errMsg = "对不起,您无数据删除权限!"; return false; } if (empty($id) || !is_numeric($id)) { self::$errCode = 30000; self::$errMsg = "运费价目ID有误!"; return false; } if (!in_array($chname, self::$chnameArr)) { self::$errCode = 30001; self::$errMsg = "渠道运费参数有误!"; return false; } $res = ChannelPriceModel::delChannelPrice($chname, $id); self::$errCode = ChannelPriceModel::$errCode; self::$errMsg = ChannelPriceModel::$errMsg; if (empty(self::$errCode)) { $cacheFee = TransOpenApiModel::updateCacheTableFee($chname, $data); } return $res; }
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_modify() { $this->smarty->assign('title', '修改运输方式节点预警'); $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0; if (empty($id) || !is_numeric($id)) { redirect_to("index.php?mod=trackWarnNode&act=index"); exit; } $trackWarnNode = new TrackWarnNodeAct(); $res = $trackWarnNode->actModify($id); $carrierList = TransOpenApiModel::getCarrier(2); $this->smarty->assign('lists', $carrierList); //运输方式列表 $this->smarty->assign('node_name', $res['nodeName']); $this->smarty->assign('node_key', $res['nodeKey']); $this->smarty->assign('node_days', $res['nodeDays']); $this->smarty->assign('ship_id', $res['carrierId']); $this->smarty->assign('node_chid', $res['channelId']); $this->smarty->assign('node_place', $res['nodePlace']); $this->smarty->assign('id', $res['id']); $this->smarty->display('trackWarnNodeModify.htm'); }
/** * TrackWarnStatModel::getViewPic() * 列出某个运输方式各节点的效率 * @param integer $carrierId 运输方式ID * @param integer $channelId 渠道ID * @param integer $is_warn 是否包含预警天数 0包含,1不包含 * @param string $statType 统计类型 * @param string $condition 条件 * @param string $title 图形标题 * @return json string */ public static function getViewPic($carrierId, $channelId, $statType, $condition, $title, $is_warn, $countryId) { self::initDB(); $data = array(); $channelArr = array(); $nodeArr = array(); $res = array(); $total = 0; $realTotal = 0; $channelArr = TransOpenApiModel::getCarrierChannel($carrierId, $channelId); foreach ($channelArr as $k => $ch) { $nodeArr = TransOpenApiModel::getTrackNodeList($carrierId, $ch['id']); $res[$k]['data'] = array(); $res[$k]['name'] = $ch['channelName']; $key = 0; $percent = 0; $nodeStr = ""; $nodeEffStr = ""; //X轴 if ($statType != 'internalTime') { if ($k == 0) { // foreach ($nodeArr as $v) { array_push($data, $v['nodeName']); } } } else { array_push($data, $ch['channelName']); } //Y轴 if ($statType != 'internalTime') { foreach ($nodeArr as $nd) { if ($statType == 'nodeEff' || $statType == 'nodeEffPer') { if ($key == 0) { $nodeEffStr = " AND nodeEff like '1%'"; } else { $nodeStr = str_pad($nodeStr, $key, "_", STR_PAD_LEFT); $nodeEffStr = " AND nodeEff like '{$nodeStr}1%'"; } } $callFunction = 'get' . $statType; if ($statType == 'nodeEffPer' && $key == 0) { $total = self::getNodeEffTotal($carrierId, $ch['id'], $condition, $nd['id'], $countryId); } $realTotal = self::$callFunction($carrierId, $ch['id'], $condition . $nodeEffStr, $nd['id'], $countryId); if ($statType == 'nodeEffPer') { $percent = round($realTotal / $total, 4) * 100; array_push($res[$k]['data'], $percent); } else { array_push($res[$k]['data'], $realTotal); } $key++; } } else { $nodeWarnStr = $is_warn ? " AND warnLevel > 0" : ''; $total = self::getInternalTime($carrierId, $ch['id'], $condition . $nodeWarnStr, "", $countryId); array_push($res[$k]['data'], $total[0]); array_push($res[$k]['data'], $total[1]); array_push($res[$k]['data'], $total[2]); } } switch ($statType) { case "nodeEff": $unit = "件"; $y_title = "包裹数量"; break; case "nodeTime": $unit = "天"; $y_title = "平均处理天数"; break; case "nodeEffPer": $unit = "%"; $y_title = "百分比"; break; case "internalTime": $unit = ""; $y_title = ""; unset($data); if ($carrierId == 46 || $carrierId == 47) { $priceUnit = "\$"; } else { $priceUnit = "¥"; } $data = array('国内平均处理时间(天)', '平均处理重量(KG)', "平均处理运费({$priceUnit})"); break; } $categories = json_encode($data); $series = json_encode($res); $data = "\$('#container').highcharts({\n\t\t\t\t\t\tchart: {\n\t\t\t\t\t\t\ttype: 'spline'\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\ttext: '{$title}'\n\t\t\t\t\t\t},\n\t\t\t\t\t\txAxis: {\n\t\t\t\t\t\t\tcategories: {$categories},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tyAxis: {\n\t\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\t\ttext: '{$y_title}'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\tformatter: function() {\n\t\t\t\t\t\t\t\t\treturn this.value +'{$unit}'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttooltip: {\n\t\t\t\t\t\t\tcrosshairs: true,\n\t\t\t\t\t\t\tshared: true\n\t\t\t\t\t\t},\n\t\t\t\t\t\tplotOptions: {\n\t\t\t\t\t\t\tspline: {\n\t\t\t\t\t\t\t\tmarker: {\n\t\t\t\t\t\t\t\t\tradius: 4,\n\t\t\t\t\t\t\t\t\tlineColor: '#666666',\n\t\t\t\t\t\t\t\t\tlineWidth: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tseries: {$series}\n\t\t\t\t\t});"; if ($statType == 'internalTime') { exit($data); } return $data; }
function consume_tracknum($v) { $type = strtolower($v['ebay_carrier']); switch ($type) { case "中国邮政挂号": $carrierId = 2; break; case "香港小包挂号": $carrierId = 4; break; case "ems": $carrierId = 5; break; case "eub": $carrierId = 6; break; case "dhl": $carrierId = 8; break; case "fedex": $carrierId = 9; break; case "global mail": $carrierId = 10; break; case "ups ground": $carrierId = 46; break; case "usps": $carrierId = 47; break; case "顺丰快递": $carrierId = 48; break; case "圆通快递": $carrierId = 49; break; case "申通快递": $carrierId = 50; break; case "韵达快递": $carrierId = 51; break; case "新加坡小包挂号": $carrierId = 52; break; case "德国邮政挂号": $carrierId = 53; break; case "ups美国专线": $carrierId = 62; break; case "ups英国专线": $carrierId = 96; break; case "ups法国专线": $carrierId = 97; break; case "ups德国专线": $carrierId = 98; break; case "俄速通挂号": $carrierId = 79; break; case "俄速通大包": $carrierId = 81; break; case "飞腾dhl": $carrierId = 59; break; case "自提": $carrierId = 68; break; case "surepost": $carrierId = 65; break; case "ups surepost": $carrierId = 95; break; case "usps firstclass": $carrierId = 91; break; case "ups ground commercia": $carrierId = 92; break; case "俄速通平邮": case "香港小包平邮": case "新加坡dhl gm平邮": case "瑞士小包平邮": case "中国邮政平邮": $carrierId = 61; break; case "新加坡dhl gm挂号": $carrierId = 83; break; case "郑州小包挂号": $carrierId = 86; break; case "瑞士小包挂号": $carrierId = 88; break; case "比利时小包eu": $carrierId = 89; break; case "澳邮宝挂号": $carrierId = 93; break; default: $carrierId = 0; print_r($v); return true; } if (empty($carrierId)) { return false; } $trackNumber = $v['ebay_tracknumber']; if (empty($trackNumber)) { $trackNumer = 'WD' . str_pad($v['ebay_id'], 9, "0", STR_PAD_LEFT) . 'CN'; } $timestr = date('Y-m-d H:i:s'); $trackNumber = str_replace(array('CNEE', 'CNRB', 'SGEM'), array('CN,EE', 'CN,RB', 'SG,EM'), $v['ebay_tracknumber']); $numArr = preg_split("/[和,\\s]+/", $trackNumber); foreach ($numArr as $val) { $flag = TransOpenApiModel::checkTrackNumber($val, $carrierId); if (!$flag) { $res = TransOpenApiModel::getCountriesStandardByName($v['ebay_countryname']); $countryId = isset($res['id']) ? $res['id'] : 0; $data = array('trackNumber' => $val, 'orderSn' => $v['ebay_id'], 'weight' => $v['realWeight'], 'cost' => $v['ordershipfee'], 'carrierId' => $carrierId, 'toCountry' => $v['ebay_countryname'], 'countryId' => $countryId, 'scanTime' => $v['scantime'], 'recordId' => $v['recordnumber'], 'platAccount' => $v['ebay_account'], 'platForm' => $v['PlatForm'], 'toCity' => $v['ebay_city'], 'toUserId' => $v['ebay_userid'], 'toUserEmail' => $v['ebay_usermail'], 'toMarkTime' => $v['ShippedTime'], 'fhTime' => $v['fhTime']); $res = TransOpenApiModel::addTrackNumber($data); if ($res) { echo $res, "===", $v['ebay_id'], "===", $val, "===添加成功==={$timestr}\n"; } else { echo $res, "===", $v['ebay_id'], "===", $val, "===添加失败==={$timestr}\n"; echo "原因:[", TransOpenApiModel::$errMsg, "]\n"; } } else { echo $v['ebay_id'], "===", $val, "===已添加==={$timestr}\n"; } } return true; }
/** * ApiCompetenceAct::actModify() * 返回某个API开放授权 * @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, "API开放授权ID不能为空?", ""); return false; } $data['id'] = $id; $data['gids'] = ApiCompetenceModel::getGlobalUser(); $data['lists'] = TransOpenApiModel::getCarrierOpenList(); $data['res'] = ApiCompetenceModel::modModify($id); self::$errCode = ApiCompetenceModel::$errCode; self::$errMsg = ApiCompetenceModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } return $data; }
$table .= '<table border="1" cellpadding="0" cellspacing="0" width="791"><tr><td height="25px"><b>运输方式</b></td><td><b>跟踪号总数</b></td><td><b>已用数量</b></td><td><b>剩余数量</b></td></tr>'; $table .= '<tr><td height="20px">' . $res['carrierNameCn'] . '</td><td>' . $total . '</td><td>' . $used . '</td><td>' . $last . '</td></tr>'; $flag = false; foreach ($chArr as $v) { $total_ch = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND channelId = '{$v['id']}'"); $used_ch = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND channelId = '{$v['id']}' AND orderId > 0"); $last_ch = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND channelId = '{$v['id']}' AND orderId = 0"); if ($carrierId == 88) { $total_cur = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND countrys = 'Switzerland'"); $used_cur = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND countrys = 'Switzerland' AND orderId > 0"); $last_cur = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND countrys = 'Switzerland' AND orderId = 0"); $table .= '<tr><td height="20px">' . $res['carrierNameCn'] . '->非瑞士国家</td><td>' . ($total - $total_cur) . '</td><td>' . ($used - $used_cur) . '</td><td>' . ($last - $last_cur) . '</td></tr>'; $table .= '<tr><td height="20px">' . $res['carrierNameCn'] . '->瑞士国家</td><td>' . $total_cur . '</td><td>' . $used_cur . '</td><td>' . $last_cur . '</td></tr>'; } if ($last_ch <= $warnNum) { $flag = true; } if ($carrierId == 2) { $table .= '<tr><td height="20px">' . $res['carrierNameCn'] . "->" . $v['channelName'] . '渠道</td><td>' . $total_ch . '</td><td>' . $used_ch . '</td><td>' . $last_ch . '</td></tr>'; } } $table .= '</table>'; $table .= '<p style="' . $css_height . '">详情请登录:<a href="' . $system_url . '" target="_blank">' . $system_name . '</a><br/></br>' . date('Y-m-d') . '<br/>' . $system_name . '</p>'; echo $table, "\n"; //跟踪号可用数低于多少发预警邮件 if ($flag || $last <= $warnNum) { $message = TransOpenApiModel::sendMessage("{$type}", "{$from}", "{$to}", $table, "{$title}"); echo $message, "\n"; } echo "\n\n完成时间" . date('Y-m-d H:i:s') . "\n"; exit;
/** * TrackWarnStatAct::act_viewPic() * 列出某个运输方式各渠道各节点的(处理、时效)效率 * @param integer $carrierId 运输方式ID * @param integer $channelId 渠道ID * @param string $timeNode 时间条件 * @param string $statType 统计类型 * @return json string */ public function act_viewPic() { $condition = "1"; $title = ""; $countryStr = ""; $carrierId = isset($_POST['carrierId']) ? abs(intval($_POST['carrierId'])) : 0; $channelId = isset($_POST['channelId']) ? abs(intval($_POST['channelId'])) : 0; $countryId = isset($_POST['countryId']) ? abs(intval($_POST['countryId'])) : 0; $timeNode = isset($_GET['timeNode']) ? post_check(trim($_GET['timeNode'])) : ''; $statType = isset($_POST['statType']) ? post_check(trim($_POST['statType'])) : ''; $is_warn = isset($_POST['is_warn']) ? post_check(trim($_POST['is_warn'])) : 0; $act = isset($_REQUEST["act"]) ? post_check($_REQUEST["act"]) : ""; $mod = isset($_REQUEST["mod"]) ? post_check($_REQUEST["mod"]) : ""; if (!AuthUser::checkLogin($mod, $act)) { self::$errCode = 10000; self::$errMsg = "对不起,您无跟踪号统计查看权限!"; return false; } if (empty($carrierId)) { self::$errCode = 10001; self::$errMsg = "运输方式参数有误"; return false; } if (empty($timeNode) || !in_array($timeNode, array('scanTime'))) { self::$errCode = 10002; self::$errMsg = "时间条件参数有误"; return false; } if (empty($statType) || !in_array($statType, array('nodeEff', 'nodeEffPer', 'nodeTime', 'internalTime', 'todayWarnPer'))) { self::$errCode = 10003; self::$errMsg = "统计类型参数有误"; return false; } if (!in_array($is_warn, array(0, 1))) { self::$errCode = 10004; self::$errMsg = "预警天数参数有误"; return false; } if (!empty($timeNode)) { $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 (empty($countryId)) { $countryStr = " 国家"; } else { $res = TransOpenApiModel::getCountriesStandardById($countryId); $countryStr = " ({$res['countryNameCn']})"; } switch ($statType) { case "nodeEff": $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理效率统计" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理效率统计"; break; case "nodeTime": $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理时效统计" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理时效统计"; break; case "nodeEffPer": $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道节点处理效率百分比" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道节点处理效率百分比"; break; case "internalTime": $title = $_GET['startTime'] == $_GET['endTime'] ? "{$_GET['startTime']}{$countryStr}各运输渠道处理时效" : "{$_GET['startTime']}——{$_GET['endTime']}{$countryStr}各运输渠道处理时效"; break; } if (in_array($statType, array('todayWarnPer'))) { $res = ""; $nodeArr = TransOpenApiModel::getRandTrackNodeList($carrierId); foreach ($nodeArr as $key => $nd) { $condition = array(1, $timeNode, $startTime, $endTime, $key, "container" . $key); $res .= TrackWarnStatModel::getViewTodayPic($carrierId, $channelId, $statType, $condition, "{$nd['nodeName']}节点--各渠道预警率信息一览表", $is_warn, $countryId); } } else { $res = TrackWarnStatModel::getViewPic($carrierId, $channelId, $statType, $condition, $title, $is_warn, $countryId); } self::$errCode = TrackWarnStatModel::$errCode; self::$errMsg = TrackWarnStatModel::$errMsg; return $res; }
function check_cancel_order() { global $dbConn, $carrierId, $trackNumber; echo date('Y-m-d H:i:s', time()), "===检查订单状态开始===\n"; empty($carrierId) ? $condition = 1 : ($condition = "carrierId={$carrierId}"); $sql = "SELECT orderSn,lastTime FROM trans_track_number WHERE {$condition} AND trackNumber = '{$trackNumber}'"; $query = $dbConn->query($sql); $res = $dbConn->fetch_array($query); $id = isset($res['orderSn']) ? $res['orderSn'] : 0; $lastTime = isset($res['lastTime']) ? $res['lastTime'] : 0; if (!empty($id)) { $data = TransOpenApiModel::getOrderInfo($id); $data = json_decode($data, true); print_r($data); $status = isset($data[0]['ebay_status']) ? intval($data[0]['ebay_status']) : 0; if (in_array($status, array(663, 613, 666, 615, 669, 674, 670, 681, 716, 717, 723, 721))) { $res = TransOpenApiModel::updateTrackOrderInfo($id, array('status' => 8)); echo $id, "=====更新退件完成,状态", $res, "\n"; } } echo date('Y-m-d H:i:s', time()), "===检查订单状态结束===\n"; }