/** * 根据条件更新数据 * @param $set 插入字段的值 * @return 返回插入的记录数 */ public static function addDefectiveProducts($set) { self::initDB(); $sql = "INSERT INTO " . self::$table . " {$set}"; //echo $sql; if (!self::$dbConn->query($sql)) { self::$errCode = "1501"; self::$errMsg = "addDefectiveProducts"; return false; } else { return self::$dbConn->affected_rows(); } }
function act_addDefectiveProducts($set) { $list = DefectiveProductsModel::updateDefectiveProducts($set); if ($list) { return $list; } else { self::$errCode = DefectiveProductsModel::$errCode; self::$errMsg = DefectiveProductsModel::$errMsg; return false; } }
function act_afterAuditDefectiveProducts() { //QC对不良品列表中进行对报废和内部处理 //$scrappedStatus表示处理方向,1为报废,2为内部处理,3为待退回 try { $defectiveId = isset($_GET['defectiveId']) ? post_check($_GET['defectiveId']) : ''; $infoId = isset($_GET['infoId']) ? post_check($_GET['infoId']) : ''; $num = isset($_GET['num']) ? post_check($_GET['num']) : ''; $note = isset($_GET['note']) ? post_check($_GET['note']) : ''; $scrappedStatus = isset($_GET['scrappedStatus']) ? post_check($_GET['scrappedStatus']) : ''; if (empty($defectiveId) || empty($infoId) || empty($num) || empty($scrappedStatus)) { throw new Exception("empty fields"); } TransactionBaseModel::begin(); $now = time(); $select = 'startTime'; $where = "WHERE id='{$defectiveId}'"; $defectiveProductsList = DefectiveProductsModel::getDefectiveProductsList($select, $where); //修改记录前看是否是第一次插入 $set = "SET processedNum=processedNum+'{$num}' "; if (empty($defectiveProductsList[0]['startTime'])) { //如果是第一次插入则加入首次处理时间 $set .= ",startTime='{$now}' "; } DefectiveProductsModel::updateDefectiveProducts($set, $where); //先将该不良品记录的相关字段修改 $select = 'sku,defectiveNum,processedNum'; $defectiveProductsList = DefectiveProductsModel::getDefectiveProductsList($select, $where); // $spu = $defectiveProductsList[0]['spu']; $sku = $defectiveProductsList[0]['sku']; $defectiveNum = $defectiveProductsList[0]['defectiveNum']; //不良品记录的总数量 $processedNum = $defectiveProductsList[0]['processedNum']; //已处理数量 if ($scrappedStatus == 1 || $scrappedStatus == 2) { $set = "SET infoId='{$infoId}',sku='{$sku}',scrappedNum='{$num}',processTypeId='{$scrappedStatus}',note='{$note}' "; ScrappedProductsModel::addScrappedProducts($set); //在报废,内部处理表中添加记录; } elseif ($scrappedStatus == 3) { $set = "SET infoId='{$infoId}',sku='{$sku}',returnNum='{$num}',note='{$note}' "; ReturnProductsModel::addReturnProducts($set); //在退回表中表中添加记录; } else { throw new Exception("error status"); } if ($defectiveNum == $processedNum) { //检测该不良品记录是否处理完成 $set = "SET defectiveStatus='2',lastModified='{$now}' "; $where = "WHERE id='{$defectiveId}'"; DefectiveProductsModel::updateDefectiveProducts($set, $where); //先将该不良品记录的相关字段修改 } TransactionBaseModel::commit(); TransactionBaseModel::autoCommit(); self::$errCode = 200; self::$errMsg = 'Success'; return 1; } catch (Exception $e) { TransactionBaseModel::rollback(); self::$errCode = 301; self::$errMsg = $e->getMessage(); return 0; } }
function act_otherCheck() { $data = array(); $typeid = $_POST['typeid']; $id = $_POST['id']; $num = $_POST['num']; $sku = $_POST['sku']; $check_num = $_POST['check_num']; $rejects_num = $_POST['rejects_num']; $bad_reason = post_check($_POST['bad_reason']); if (!empty($rejects_num)) { $set = "SET infoId='{$id}',sku='{$sku}',defectiveNum='{$rejects_num}',note='{$bad_reason}' "; $res = DefectiveProductsModel::addDefectiveProducts($set); if ($res) { $data = array('detectorId' => $_SESSION['userId'], 'detectStartTime' => time(), 'detectStatus' => 3, 'typeId' => $typeid, 'ichibanNum' => $num - $rejects_num); 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; } } else { $data = array('detectorId' => $_SESSION['userId'], 'detectStartTime' => time(), 'detectStatus' => 3, 'typeId' => $typeid, 'ichibanNum' => $num); if (WhStandardModel::update($data, "and id='{$id}'")) { self::$errMsg = "提交成功,请检测下一料号"; return true; } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } } }
function act_whRegularInspection() { $data = array(); $sku = $_POST['sku']; $spu = $_POST['spu']; $check_num = $_POST['check_num']; $checkTypeID = 2; $skuName = $_POST['skuName']; $reNum = $_POST['reNum']; $type = $_POST['type']; $sampleTypeId = $_POST['sampleTypeId']; if ($type == 1) { $rejects_num = $_POST['rejects_num']; $bad_reason = post_check($_POST['bad_reason']); $set = "SET sku='{$sku}',spu='{$spu}',defectiveNum='{$rejects_num}',note='{$bad_reason}',startTime=" . time() . " "; /* * 插入不良品库表qc_sample_defective_products */ $res = DefectiveProductsModel::addDefectiveProducts($set); if ($res) { $data = array('sku' => $sku, 'goodsName' => $skuName, 'arrivalNum' => $reNum, 'checkNum' => $check_num, 'rejectsNum' => $rejects_num, 'rejectsReason' => $bad_reason, 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $sampleTypeId, 'checkTypeID' => 2, 'sellerId' => 1); /* * 插入完成记录表qc_work_table */ $workTabl = IqcCompleteInfoModel::insertRow($data); if ($workTabl) { /* * 更新老ERP系统库存接口 */ $oldErp = UserCacheModel::qccenterUpdateErpGoodscount($sku, $rejects_num); if ($oldErp) { self::$errCode = "200"; self::$errMsg = "提交成功,库存扣除成功,请检测下一料号!"; return $oldErp; } else { self::$errCode = "4444"; self::$errMsg = "qc检测不良品扣除ERP库存失败!请联系IT解决!"; return false; } } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } /*测试用 $oldErp = IqcCompleteInfoModel::insertRow($data); if($oldErp){ self::$errCode = "200"; self::$errMsg = "提交成功,请检测下一料号"; return $oldErp; }else{ self::$errCode = "4444"; self::$errMsg = "qc检测不良品扣除ERP库存失败!请联系IT解决!"; return false; } */ } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } } else { if ($type == 2) { /* * 插入完成记录表qc_work_table */ $data = array('sku' => $sku, 'goodsName' => $skuName, 'arrivalNum' => $reNum, 'checkNum' => $check_num, 'rejectsNum' => 0, 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $sampleTypeId, 'checkTypeID' => 2, 'sellerId' => 1); /* * 插入完成记录表qc_work_table */ if (IqcCompleteInfoModel::insertRow($data)) { self::$errCode = "200"; self::$errMsg = "提交成功,请检测下一料号"; return true; } else { self::$errCode = "003"; self::$errMsg = "提交失败,请重试"; return false; } } } }