$system_name = "运输方式管理系统"; $system_url = "http://tran.valsun.cn/"; $type = "email"; //消息发送类型 $from = "管拥军"; //发送人 $to = "管拥军,夏良,陈前,王凤珠,陈晓兰B,于雅杰,魏凤玲,叶霄,王友芝,范雪琴,胡涛"; //接收者 $res = TransOpenApiModel::getCarrierById($carrierId); if (empty($carrierId) || empty($res)) { print_r($argv); echo "运输方式ID有误!\n"; exit; } //各运输方式下渠道跟踪号使用统计 $chArr = TransOpenApiModel::getCarrierChannel($carrierId); $total = TrackNumberModel::modListCount("carrierId = '{$carrierId}'"); $used = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND orderId > 0"); $last = TrackNumberModel::modListCount("carrierId = '{$carrierId}' AND orderId = 0"); $title = "【跟踪号可用数量预警】" . date('Y-m-d', time()) . " 运输方式{$res['carrierNameCn']}"; $table = '<p style="' . $css_height . '"><b>大家好:</b><br/>以下为运输方式<b>' . $res['carrierNameCn'] . '</b>跟踪号可用数量预警简报,请查阅</p>'; $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");
/** * TransOpenApiAct::act_getCarrierChannel() * 获取某个运输方式的渠道信息并存入memcache * @param int $carrierId * @param int $chId * @param int $is_new 是否强制更新(默认0不强制) * @return array */ public function act_getCarrierChannel() { $carrierId = isset($_REQUEST['carrierId']) ? post_check($_REQUEST['carrierId']) : 0; $channelId = isset($_REQUEST['channelId']) ? post_check($_REQUEST['channelId']) : 0; $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 ($carrierId == "all") { $carrierId = 0; } else { $carrierId = abs(intval($_REQUEST['carrierId'])); } $cacheName = md5("trans_channel_list_" . $carrierId . $channelId); $memc_obj = new Cache(C('CACHEGROUP')); $channelInfo = $memc_obj->get_extral($cacheName); if (!empty($channelInfo) && empty($is_new)) { return unserialize($channelInfo); } else { if (empty($carrierId)) { if ($channelId) { $channelInfo = TransOpenApiModel::getCarrierChannel(0, $channelId); } else { $channelInfo = TransOpenApiModel::getCarrierChannel(); } } else { $channelInfo = TransOpenApiModel::getCarrierChannel($carrierId); } $isok = $memc_obj->set_extral($cacheName, serialize($channelInfo)); if (!$isok) { self::$errCode = 306; self::$errMsg = 'memcache缓存出错!'; //return false; } return $channelInfo; } }
/** * 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; }
/** * TrackNumberAct::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['countrys'] = TransOpenApiModel::getCountriesStandard(); $data['lists'] = TransOpenApiModel::getCarrier(2); $data['res'] = TrackNumberModel::modModify($id); self::$errCode = TrackNumberModel::$errCode; self::$errMsg = TrackNumberModel::$errMsg; if (self::$errCode != 0) { show_message($this->smarty, self::$errMsg, ""); return false; } $data['chList'] = TransOpenApiModel::getCarrierChannel($data['res']['carrierId']); return $data; }