function act_addPendingProducts($set) { $list = PendingProductsModel::updatePendingProducts($set); if ($list) { return $list; } else { self::$errCode = PendingProductsModel::$errCode; self::$errMsg = PendingProductsModel::$errMsg; return false; } }
public static function addgetWhInfo($set) { self::initDB(); $sql = "INSERT INTO wh_sample_info {$set}"; echo $sql . '<br>'; if (!self::$dbConn->query($sql)) { self::$errCode = "1801"; self::$errMsg = "wh_sample_info"; return false; } else { return self::$dbConn->affected_rows(); } }
function act_allDetermined() { $data = array(); $id = $_POST['id']; $num = $_POST['num']; $sku = $_POST['sku']; $wait_reason = post_check($_POST['wait_reason']); $set = "SET infoId='{$id}',sku='{$sku}',pendingNum='{$num}',note='{$wait_reason}' "; $res = PendingProductsModel::addPendingProducts($set); if ($res) { $data = array('detectorId' => $_SESSION['userId'], 'detectStartTime' => time(), 'detectStatus' => 4); if (WhStandardModel::update($data, "and id='{$id}'")) { self::$errMsg = "提交成功,请检测下一料号"; return true; } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } }
function act_operatePendingProducts() { //QC对待定列表中进行修改图片,正常回测,待退回(全部,不分部分) //$pendingId表示待定表中的记录ID,$status表示修改图片,正常回测或待退回 try { $cTime1 = time() + microtime(); $pendingId = isset($_GET['pendingId']) ? post_check($_GET['pendingId']) : ''; $status = isset($_GET['status']) ? post_check($_GET['status']) : ''; $tracktime = isset($_GET['tracktime']) ? post_check($_GET['tracktime']) : ''; //echo $pendingId.' '.$status; $select = '*'; $where = "WHERE id='{$pendingId}'"; $pendingProductsList = PendingProductsModel::getPendingProductsList($select, $where); if (empty($pendingProductsList)) { throw new Exception("error"); } TransactionBaseModel::begin(); $selectStatus = $pendingProductsList[0]['pendingStatus']; if ($selectStatus != 0 && $selectStatus != 2) { //如果该条待定记录中的状态不是0或2(待处理或者是图片修改完成时,报错) throw new Exception("error"); } $startTime = $pendingProductsList[0]['startTime']; $pendingNum = $pendingProductsList[0]['pendingNum']; $pendingId = $pendingProductsList[0]['id']; $infoId = $pendingProductsList[0]['infoId']; // $spu = $pendingProductsList[0]['spu']; $sku = $pendingProductsList[0]['sku']; $now = time(); if ($status == 1) { //修改图片 $set = "SET pendingStatus='1',processedNum='{$pendingNum}',startTime='{$now}' "; //状态改为需要修改图片 $where = "WHERE id='{$pendingId}'"; PendingProductsModel::updatePendingProducts($set, $where); //先将该待定记录的相关字段修改 //这里还要调用API在产品中心待修改列表中添加一条记录// //先略过,到时处理 } elseif ($status == 2) { //正常回测 $set = "SET pendingStatus='3',processedNum='{$pendingNum}',lastModified='{$now}' "; //状态改为已处理pendingStatus='3' if (empty($startTime)) { //如果不是从修改完图片进行回测的话(即开始处理时间为空),要加上开始处理时间 $set .= ",startTime='{$now}' "; } $where = "WHERE id='{$pendingId}'"; //echo $set; PendingProductsModel::updatePendingProducts($set, $where); //先将该待定记录的相关字段修改 //这里还要在wh_sample_info中将$infoId这条记录的detectStatus状态改为1(待检测),pid=$pendingId $select = 'id'; $where = "WHERE id='{$infoId}'"; $whInfoList = PendingProductsModel::getWhInfo($select, "WHERE id='{$infoId}'"); //取出wh_info表中关联pendingId的记录 if (empty($whInfoList)) { //如果该infoid在whInfo中找不到记录的话 throw new Exception("error infoId"); } $set = "set detectStatus='1',pid='{$pendingId}' "; $affectRow = PendingProductsModel::updateWhInfo($set, $where); //更新原来的wh_info表中的该记录 if ($affectRow != 1) { //如果更新记录数不是唯一的,也报错 throw new Exception("update error"); } } elseif ($status == 3) { //待退回 $set = "SET pendingStatus='3',processedNum='{$pendingNum}',startTime='{$now}',lastModified='{$now}' "; $where = "WHERE id='{$pendingId}'"; PendingProductsModel::updatePendingProducts($set, $where); //先将该待定记录的相关字段修改 $note = '待定移至待退回'; $set = "SET infoId='{$infoId}',sku='{$sku}',note='{$note}',returnNum='{$pendingNum}'"; ReturnProductsModel::addReturnProducts($set); //在退回表中表中添加记录; } else { throw new Exception("error status"); } TransactionBaseModel::commit(); TransactionBaseModel::autoCommit(); $cTime2 = time() + microtime(); self::$errCode = $cTime2 . ' ' . $cTime1; self::$errMsg = 'Success'; return 1; } catch (Exception $e) { TransactionBaseModel::rollback(); $cTime2 = time() + microtime(); self::$errCode = $cTime2 . ' ' . $cTime1; self::$errMsg = $e->getMessage(); return 0; } }
public static function getModifyNum($sku) { self::initDB(); $start = date('Y') . "-" . date('m') . "-01"; $start = strtotime($start); $end = time(); $sql = "SELECT count(*) as num FROM qc_sample_pending_products where sku='{$sku}' and modifyStatus=1 and startTime between {$start} and {$end} "; //echo $sql . '<br>'; $query = self::$dbConn->query($sql); if ($query) { $ret = self::$dbConn->fetch_array_all($query); return $ret[0]['num']; } else { self::$errCode = "1601"; self::$errMsg = "getWhInfo"; return false; } }
function act_allDetermined($category = 1, $skuTypeCheckID = 1) { $data = array(); $data['infoId'] = $_POST['id']; $id = $_POST['id']; $data['spu'] = $_POST['spu']; $data['pendingNum'] = $_POST['num']; $data['sku'] = $_POST['sku']; $data['pendingStatus'] = empty($_POST['rewrite_type']) ? 0 : 1; $data['note'] = post_check($_POST['wait_reason']); $data['modifyStatus'] = $_POST['rewrite_type']; $data['startTime'] = time(); $sample_info = WhStandardModel::getNowWhList('*', ' where id = ' . $id); //之前待定过,然后恢复检测的不能再待定 $pendingStatus = $sample_info[0]['pendingStatus']; if ($pendingStatus == 5) { self::$errCode = '004'; self::$errMsg = '此料号已正常回测,不能再待定!'; return false; } if ($data['modifyStatus'] == 1) { $modifynum = PendingProductsModel::getModifyNum($_POST['sku']); if ($modifynum >= 3) { self::$errCode = "001"; self::$errMsg = "此料号本月修改图片已超过三次!请见其全部检测未不良品!"; return false; } } $log_file = 'skuDetermined/' . date("Y-m-d") . '.txt'; $data['purchaseId'] = $sample_info[0]['purchaseId']; $set = "SET " . array2sql($data); $res = PendingProductsModel::addPendingProducts($set); $log_info = "全部待定:" . date("Y-m-d H:i:s") . "批次:{$sample_info[0]['printBatch']},SKU:{$_POST['sku']},待定数:{$data['pendingNum']}\r\n"; write_log($log_file, $log_info); if ($res) { $data = array('detectorId' => $_SESSION['sysUserId'], 'detectStartTime' => time(), 'detectStatus' => 4); if (WhStandardModel::update($data, "and id='{$_POST['id']}'")) { $c_data = array('sku' => $_POST['sku'], 'goodsName' => $sample_info[0]['goodsName'], 'arrivalNum' => $_POST['num'], 'checkNum' => $check_num, 'rejectsNum' => 0, 'rejectsReason' => '', 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $skuTypeCheckID, 'checkTypeID' => $category); //$useract = new userAct(); IqcCompleteInfoModel::insertRow($c_data); $purchaser = userModel::getUsernameById($sample_info[0]['purchaseId']); //$purchaser = userModel::getUsernameById(9); $from = userModel::getUsernameById($_SESSION['sysUserId']); $mailList['content'] = $from . "在IQC检测中检测料号 " . $_POST['sku'] . " 时将其全部待定!数量:" . $_POST['num'] . ",请及时做处理!====" . date("Y-m-d H:i:s") . "===="; //$mailList['content'] = "发错了!不好意思。"; $mailList['from'] = $from; $mailList['to'] = $purchaser; $mailList['type'] = "email"; $mailList['callback'] = ""; self::$errMsg = "提交成功,请检测下一料号"; return $mailList; } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } //TransactionBaseModel::commit(); }