public function view_addOrUpdateSpuSalerForAnyOn() { $platformId = $_POST['platformId'] ? post_check($_POST['platformId']) : ''; $platformList = getAllPlatformInfo(); $platformArr = array(); foreach ($platformList as $value) { if ($platformId == $value['id']) { $platformArr = $value; } } if (empty($platformArr)) { $status = "<font color=red>系统找不到平台信息,请咨询订单系统的平台列表信息是否正确!</font><br/>"; echo $status; exit; } $useId = $_SESSION['userId']; $personName = getPersonNameById($useId); if (empty($personName)) { $status = "<font color=red>系统找不到登录人信息!</font><br/>"; echo $status; exit; } if (isset($_POST['submit']) && $_POST['submit'] != '') { $uploadfile = 'addOrUpdateSpuSaler_' . $platformArr['platform'] . '_' . $platformSuffix . date("Y") . date("m") . date("d") . date("H") . date('i') . date('s') . '_' . $personName . ".xls"; if (move_uploaded_file($_FILES['upfile']['tmp_name'], 'upload/' . $uploadfile)) { echo "<font color=BLUE>文件上传成功!</font><br>"; } else { echo "<font color=red> 文件上传失败!</font>"; exit; } $fileName = 'upload/' . $uploadfile; $filePath = $fileName; $PHPExcel = new PHPExcel(); $PHPReader = new PHPExcel_Reader_Excel2007(); if (!$PHPReader->canRead($filePath)) { $PHPReader = new PHPExcel_Reader_Excel5(); if (!$PHPReader->canRead($filePath)) { echo 'no Excel'; return; } } $PHPExcel = $PHPReader->load($filePath); $currentSheet = $PHPExcel->getSheet(0); $highestRow = $currentSheet->getHighestRow(); //表格中的最大行数 if ($personName != '朱清庭' && $highestRow > 5000) { echo "表格不能超过5000行,请重新整理表格导入,谢谢!"; exit; } $status = ''; $flag = true; //标识检测结果 ini_set("max_execution_time", 0); //设置脚本运行时间无限制 for ($i = 2; $i <= $highestRow; $i++) { //先检查导入表格的正确性 $spu = trim($currentSheet->getCell('A' . $i)->getValue()); //spu $spu = preg_replace("/(\\s|\\ \\;| | )/", "", $spu); $salerName = trim($currentSheet->getCell('B' . $i)->getValue()); //对应销售人名称 $salerName = preg_replace("/(\\s|\\ \\;| | )/", "", $salerName); $spu = strpos($spu, '_') === false ? str_pad($spu, 3, '0', STR_PAD_LEFT) : $spu; if (empty($spu)) { $status .= "<font color=red>第 {$i} 行,SPU为空!</font><br/>"; continue; } if (empty($salerName)) { $status .= "<font color=red>第 {$i} 行,销售人为空!</font><br/>"; continue; } $autoCreateSpuList = isAutoCreateSpuExist($spu); if (empty($autoCreateSpuList)) { $status .= "<font color=red>第 {$i} 行,找不到 {$spu} 的生成信息,请先将该SPU信息添加到生成SPU列表中!</font><br/>"; continue; } $salerId = getPersonIdByName($salerName); if (empty($salerId)) { $status .= "<font color=red>第 {$i} 行,找不到该销售人!</font><br/>"; continue; } if ($autoCreateSpuList[0]['isSingSpu'] == 1) { $tName = 'pc_spu_saler_single'; //单料号表 } else { $tName = 'pc_spu_saler_combine'; //组合料号表 } $dataSpuSaler = array(); $dataSpuSaler['spu'] = $spu; $dataSpuSaler['platformId'] = $platformId; $dataSpuSaler['salerId'] = $salerId; $dataSpuSaler['addTime'] = time(); $select = 'salerId,isAgree'; $where = "WHERE is_delete=0 AND spu='{$spu}' AND platformId='{$platformId}'"; $oldSalerList = OmAvailableModel::getTNameList($tName, $select, $where); if (empty($oldSalerList)) { OmAvailableModel::addTNameRow2arr($tName, $dataSpuSaler); if (!error_log(date('Y-m-d_H:i') . "——平台:{$platformId} {$spu} {$salerName} 添加成功 BY {$personName} \r\n", 3, WEB_PATH . "log/spuSalerImport.txt")) { echo "{$spu} 日志输出错误,请联系管理员,谢谢"; exit; } $status .= "<font color=green>{$spu} 对应销售 {$salerName} 添加成功</font><br/>"; } elseif ($oldSalerList[0]['salerId'] != $salerId || $oldSalerList[0]['isAgree'] != 2) { $dataUpdate = array(); $dataUpdate['salerId'] = $salerId; $dataUpdate['addTime'] = time(); if ($oldSalerList[0]['salerId'] != $salerId) { $dataUpdate['isHandsOn'] = 1; } $dataUpdate['isAgree'] = 2; OmAvailableModel::updateTNameRow2arr($tName, $dataUpdate, $where); if (!error_log(date('Y-m-d_H:i') . "——平台:{$platformId} {$spu} {$salerName} 修改成功 BY {$personName} \r\n", 3, WEB_PATH . "log/spuSalerImport.txt")) { echo "{$spu} 日志输出错误,请联系管理员,谢谢"; exit; } $status .= "<font color=orange>{$spu} 对应销售 {$salerName} 修改成功</font><br/>"; } else { $status .= "<font>{$spu} 对应销售 {$salerName} 无修改</font><br/>"; } } } echo $status; exit; }
public function view_getNoPassSpuList() { $omAvailableAct = new OmAvailableAct(); $spu = isset($_GET['spu']) ? post_check($_GET['spu']) : ''; $purchaseId = isset($_GET['purchaseId']) ? post_check($_GET['purchaseId']) : ''; $pid = isset($_GET['pid']) ? post_check($_GET['pid']) : ''; $isCounterAudit = isset($_GET['isCounterAudit']) ? post_check($_GET['isCounterAudit']) : ''; $tName = 'pc_spu_archive_no_pass_record'; $select = '*'; $where = 'WHERE 1=1 '; if (!empty($spu)) { $where .= "AND spu='{$spu}' "; } if (!empty($pid)) { $where .= "AND categoryPath REGEXP '^{$pid}(-[0-9]+)*\$' "; } if (intval($purchaseId) != 0) { $where .= "AND purchaseId='{$purchaseId}' "; } if ($isCounterAudit == 1 || $isCounterAudit == 2) { $where .= "AND isCounterAudit='{$isCounterAudit}' "; } $total = $omAvailableAct->act_getTNameCount($tName, $where); $num = 100; //每页显示的个数 $page = new Page($total, $num, '', 'CN'); $where .= 'order by id desc '; $where .= $page->limit; $spuNoPassList = $omAvailableAct->act_getTNameList($tName, $select, $where); if (!empty($spuNoPassList)) { $platformList = getAllPlatformInfo(); $platformArr = array(); $spuStatusArr = displayAllSpuStatus(); foreach ($platformList as $value) { $platformArr[$value['id']] = $value['platform']; } $countSpuNoPass = count($spuNoPassList); for ($i = 0; $i < $countSpuNoPass; $i++) { $spuNoPassList[$i]['platformName'] = $platformArr[$spuNoPassList[$i]['platformId']]; $spuNoPassList[$i]['spuStatusName'] = $spuStatusArr[$spuNoPassList[$i]['spuStatus']]['statusName']; } } if (!empty($_GET['page'])) { if (intval($_GET['page']) <= 1 || intval($_GET['page']) > ceil($total / $num)) { $n = 1; } else { $n = (intval($_GET['page']) - 1) * $num + 1; } } else { $n = 1; } if ($total > $num) { //输出分页显示 $show_page = $page->fpage(array(0, 2, 3, 4, 5, 6, 7, 8, 9)); } else { $show_page = $page->fpage(array(0, 2, 3)); } $navlist = array(array('url' => 'index.php?mod=autoCreateSpu&act=getAutoCreatePrefixList', 'title' => 'SPU管理'), array('url' => 'index.php?mod=autoCreateSpu&act=getNoPassSpuList', 'title' => 'SPU审核不通过管理')); $this->smarty->assign('navlist', $navlist); $this->smarty->assign('onevar', 2); $this->smarty->assign('twovar', 25); $this->smarty->assign('show_page', $show_page); $this->smarty->assign('title', 'SPU审核不通过管理'); //取得搜索类别的记录 $pidArr = explode('-', $pid); $this->smarty->assign('pidArr', $pidArr); $this->smarty->assign('spuNoPassList', empty($spuNoPassList) ? null : $spuNoPassList); $this->smarty->display("spuNoPassList.htm"); }