/** * 新EUB跟踪号报表导出的sql */ public static function getEubTruckNumberReport() { self::initDB(); $sql = 'SELECT uo.`id`,oot.`tracknumber`,oot.`createdTime`, uou.`email`,uo.`recordNumber`,oa.`account` FROM `om_order_tracknumber` AS oot LEFT JOIN `om_unshipped_order` AS uo ON oot.`omOrderId` = uo.`id` LEFT JOIN `om_unshipped_order_userInfo` AS uou ON oot.`omOrderId` = uou.`omOrderId` LEFT JOIN `om_account` AS oa ON oot.`addUser` = oa.`id`'; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return $ret; } else { self::$errCode = "004"; self::$errMsg = "update error"; return false; } }
/** * 新eub跟踪号导出报表 */ public function act_eubTrucknumber2() { $trucknumberData = OmEUBTrackNumberModel::getEubTruckNumberReport(); if (empty($trucknumberData)) { self::$errCode = '3301'; self::$errMsg = '未找到跟踪号数据!'; return false; } $fileName = "eub_track_number_" . date("Y-m-d_H_i_s") . ".xls"; $excel = new ExportDataExcel('browser'); $excel->filename = WEB_PATH . "temp/" . $fileName; $excel->initialize(); $tableTitle = array('订单编号', '订单号', '帐号', '买家邮箱', '跟踪号', '申请时间'); $excel->addRow($tableTitle); foreach ($trucknumberData as $k => $v) { $rowData = array($v['id'], $v['recordNumber'], $v['account'], $v['email'], $v['tracknumber'], date('Y-m-d H:i:s', $v['id'])); $excel->addRow($rowData); } $excel->finalize(); unset($trucknumberData); return true; }
function act_applyTheLineEUBTrackNumber() { global $memc_obj; //调用memcache获取sku信息 //var_dump($SYSTEM_ACCOUNTS); require_once WEB_PATH . "lib/PHPExcel.php"; //PHPExcel //exit; $addUser = $_SESSION['sysUserId']; $filePath = WEB_PATH . "html/upload/eub/"; //var_dump($_FILES); exit; if (!empty($_FILES['theline_upfile']['tmp_name'])) { $uploadfile = date("Y") . date("m") . date("d") . rand(1, 3009) . ".xls"; $filePath .= $uploadfile; //echo $filePath; if (!move_uploaded_file($_FILES['theline_upfile']['tmp_name'], $filePath)) { self::$errCode = '003'; self::$errMsg = "文件上传失败!"; echo self::$errMsg; return false; } } else { self::$errCode = '003'; self::$errMsg = "文件上传不成功!"; echo self::$errMsg; return false; } //var_dump($addUser); $PHPExcel = new PHPExcel(); //var_dump($PHPExcel); exit; $PHPReader = new PHPExcel_Reader_Excel2007(); //var_dump($PHPReader); exit; //exit; //var_dump($PHPReader->canRead($filePath)); exit; if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); //var_dump($PHPReader); exit; if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } //exit; $PHPExcel = $PHPReader->load($filePath); $excellists = excel2array($PHPExcel, $filePath, 2, 0); //echo "<pre>";print_r($excellists); exit; $adjust_time = date('Y-m-d H:i:s'); $recordnumbers = array(); $tracknumbers = array(); foreach ($excellists as $key => $excellist) { $recordnumbers[] = array_shift($excellist); $tracknumbers[] = array_shift($excellist); } $total = count($recordnumbers); BaseModel::begin(); //开始事务 for ($ii = 1; $ii < $total; $ii++) { $recordnumber = $recordnumbers[$ii]; $tracknumber = $tracknumbers[$ii]; //盘点数量 $row = $ii; if (!preg_match('/^LN[0-9]{9}CN$/', $tracknumber)) { self::$errMsg .= " 第" . $row . "行" . $tracknumber . " 跟踪号格式有误<br>"; } if ($tracknumber == "") { self::$errMsg .= " 第" . $row . "行跟踪号为空请查证<br>"; } if (!OmEUBTrackNumberModel::applyTheLineEUBTrackNumber($recordnumber, $tracknumber)) { BaseModel::rollback(); } } self::$errCode .= OmEUBTrackNumberModel::$errCode; self::$errMsg .= OmEUBTrackNumberModel::$errMsg; BaseModel::commit(); BaseModel::autoCommit(); return true; }