function act_updateDefectiveProducts($defectiveId, $infoId, $num, $note, $scrappedStatus)
 {
     //QC对不良品列表中进行对报废和内部处理
     //$scrappedStatus表示处理方向,1为报废,2为内部处理,3为待退回
     try {
         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 = 'spu,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}',spu='{$spu}',sku='{$sku}',scrappedNum='{$num}',processTypeId='{$scrappedStatus}',note='{$note}' ";
             ScrappedProductsModel::addScrappedProducts($set);
             //在报废,内部处理表中添加记录;
         } elseif ($scrappedStatus == 3) {
             $set = "SET infoId='{$infoId}',spu='{$spu}',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();
         return 1;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         self::$errCode = '0000';
         self::$errMsg = $e;
         return 0;
     }
 }
Example #2
0
 function act_addReturnProducts($set)
 {
     $list = ReturnProductsModel::updateReturnProducts($set);
     if ($list) {
         return $list;
     } else {
         self::$errCode = ReturnProductsModel::$errCode;
         self::$errMsg = ReturnProductsModel::$errMsg;
         return false;
     }
 }
Example #3
0
 /**
  * 根据条件更新数据
  * @param     $set		插入字段的值
  * @return    返回插入的记录数
  */
 public static function addReturnProducts($set)
 {
     self::initDB();
     $sql = "INSERT INTO " . self::$table . " {$set}";
     if (!self::$dbConn->query($sql)) {
         self::$errCode = "1501";
         self::$errMsg = "addReturnProducts";
         return false;
     } else {
         return self::$dbConn->affected_rows();
     }
 }
Example #4
0
 function act_apiUpdatePendingProducts($pendingId, $infoId, $pendingNum, $userId, $status)
 {
     //QC对待定列表中进行修改图片,正常回测,待退回(全部,不分部分)
     //$pendingProductsList表示待定表中的指定记录
     try {
         TransactionBaseModel::begin();
         $now = time();
         if ($status == 2) {
             //修改图片
             $set = "SET pendingStatus='2',auditId={$userId},processedNum='{$pendingNum}',lastModified='{$now}' ";
             //状态改为需要修改图片
             $where = "WHERE id='{$pendingId}'";
             PendingProductsModel::updatePendingProducts($set, $where);
             //先将该待定记录的相关字段修改
             //这里还要调用API在产品中心待修改列表中添加一条记录//
             //先略过,到时处理
         } else {
             if ($status == 5) {
                 //正常回测
                 $set = "SET pendingStatus='5',auditId={$userId},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");
                 }
             } else {
                 if ($status == 4) {
                     //待退回
                     $set = "SET pendingStatus='4',auditId={$userId},processedNum='{$pendingNum}',startTime='{$now}',lastModified='{$now}' ";
                     $where = "WHERE id='{$pendingId}'";
                     PendingProductsModel::updatePendingProducts($set, $where);
                     //先将该待定记录的相关字段修改
                     $note = '待定移至待退回';
                     $set = "SET infoId='{$infoId}',spu='{$spu}',sku='{$sku}',auditId={$userId},note='{$note}',returnNum='{$pendingNum}'";
                     ReturnProductsModel::addReturnProducts($set);
                     //在退回表中表中添加记录;
                 } else {
                     throw new Exception("error status");
                 }
             }
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         return "申请成功";
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         self::$errCode = '0000';
         self::$errMsg = $e;
         return "申请失败";
     }
 }
Example #5
0
 public function act_auditReturnProducts()
 {
     $flag = 1;
     //标识是否操作成功
     $returnId = isset($_GET['returnId']) ? post_check($_GET['returnId']) : '';
     if (empty($returnId)) {
         //为空时,跳转到列表页面,输出错误信息
         $flag = 0;
     }
     $now = time();
     $set = "SET returnStatus='1',auditTime='{$now}' ";
     $where = "WHERE id='{$returnId}' ";
     $affectRow = ReturnProductsModel::updateReturnProducts($set, $where);
     if (!$affectRow) {
         $flag = 0;
     }
     if ($flag) {
         self::$errCode = 200;
         self::$errMsg = 'Success';
         return 1;
     } else {
         self::$errCode = 301;
         self::$errMsg = 'error';
         return 0;
     }
 }
Example #6
0
 function act_updatePendingProducts($pendingProductsList, $status)
 {
     //QC对待定列表中进行修改图片,正常回测,待退回(全部,不分部分)
     //$pendingProductsList表示待定表中的指定记录
     try {
         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状态改为3(检测完成)
             //同时在wh_sample_info中插入一条新记录,记录字段和$infoId一样,而且set pid='$pendingId'
             $select = '*';
             $where = "WHERE id='{$infoId}'";
             $whInfoList = PendingProductsModel::getWhInfo('*', "WHERE id='{$infoId}'");
             //取出wh_info表中关联pendingId的记录
             if (empty($whInfoList)) {
                 //如果该infoid在whInfo中找不到记录的话
                 throw new Exception("error infoId");
             }
             $set = "set detectStatus='3' ";
             $affectRow = PendingProductsModel::updateWhInfo($set, $where);
             //更新原来的wh_info表中的该记录
             if ($affectRow != 1) {
                 //如果更新记录数不是唯一的,也报错
                 throw new Exception("update error");
             }
             $sku = $whInfoList[0]['sku'];
             $num = $whInfoList[0]['num'];
             $printerId = $whInfoList[0]['printerId'];
             $printTime = $whInfoList[0]['printTime'];
             $getUserId = $whInfoList[0]['getUserId'];
             $getTime = $whInfoList[0]['getTime'];
             $detectorId = $whInfoList[0]['detectorId'];
             $detectStartTime = time();
             $detectStatus = 2;
             $pid = $pendingId;
             $purchaseId = $whInfoList[0]['purchaseId'];
             $sellerId = $whInfoList[0]['sellerId'];
             $typeId = $whInfoList[0]['typeId'];
             $ichibanNum = $whInfoList[0]['ichibanNum'];
             $set = "SET sku='{$sku}',num='{$num}',printerId='{$printerId}',printTime='{$printTime}',getUserId='{$getUserId}',getTime='{$getTime}',detectorId='{$detectorId}',detectStartTime='{$detectStartTime}',detectStatus='{$detectStatus}',pid='{$pid}',purchaseId='{$purchaseId}',sellerId='{$sellerId}',typeId='{$typeId}',ichibanNum='{$ichibanNum}' ";
             $affectRow = PendingProductsModel::addgetWhInfo($set);
             //待定审核后回测,将新记录插入wh_info表中,pid='$pendingId'
             if (!$affectRow) {
                 //插入数据失败时
                 throw new Exception("add WhInfo 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}',spu='{$spu}',sku='{$sku}',note='{$note}',returnNum='{$pendingNum}'";
             ReturnProductsModel::addReturnProducts($set);
             //在退回表中表中添加记录;
         } else {
             throw new Exception("error status");
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         return 1;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         self::$errCode = '0000';
         self::$errMsg = $e;
         return 0;
     }
 }
Example #7
0
 function act_subcheck()
 {
     $data = array();
     $id = $_POST['id'];
     $num = $_POST['num'];
     $rtnum = $_POST['rtnum'];
     //检测退回抽检百分比
     $sku = $_POST['sku'];
     $spu = $_POST['spu'];
     $category = $_POST['categoryId'];
     $check_num = $_POST['check_num'];
     $rejects_num = $_POST['rejects_num'];
     $bad_reason = post_check($_POST['bad_reason']);
     $sellerId = 1;
     $checkTypeID = $_POST['checkTypeID'];
     //QC检测类型ID (入库产品检测,在仓产品检测,退回产品检测)
     $skuTypeCheckID = $_POST['categoryId'];
     $completeStatus = 1;
     if ($check_num == 0) {
         self::$errCode = "004";
         self::$errMsg = "抽检数目为零,请重试";
         return false;
     }
     if ($rejects_num) {
         $completeStatus = 3;
     }
     $ichibanNum = $num - $rejects_num;
     $log_file = 'detectSku/' . date('Y-m-d') . '.txt';
     $sample_info = WhStandardModel::getNowWhList('*', ' where id = ' . $id);
     $msg = userCacheModel::updateWhichibanNum($sample_info[0]['printBatch'], $sku, $ichibanNum);
     $log_info = "更新仓库良品数:" . date("Y-m-d H:i:s") . "批次:{$sample_info[0]['printBatch']},SKU:{$sku},良品数:{$ichibanNum}\r\n";
     $log_info .= "接口返回信息:";
     if (is_array($msg)) {
         foreach ($msg as $key => $info) {
             $log_info .= sprintf("%s:%s ", $key, $info);
         }
     } else {
         $log_info .= sprintf("%s", $msg);
     }
     $log_info .= "\r\n";
     write_log($log_file, $log_info);
     if (!isset($msg['errCode']) || $msg['errCode'] != 0) {
         self::$errCode = "004";
         self::$errMsg = "推送良品数失败,请重试";
         return false;
     }
     if (!empty($rejects_num)) {
         $return_rate = $rejects_num / $check_num * 100;
         if ($return_rate > $rtnum && $rtnum != 0) {
             //退回比例
             $set = "SET infoId='{$id}',sku='{$sku}',returnNum='{$num}',note='{$bad_reason}',sellerId='{$sellerId}',startTime=" . time();
             $res = ReturnProductsModel::addReturnProducts($set);
             if ($res) {
                 $data = array('detectorId' => $_SESSION['sysUserId'], 'detectStartTime' => time(), 'detectStatus' => 3, 'completeStatus' => $completeStatus, 'typeId' => $checkTypeID, 'sampleTypeId' => $category, 'ichibanNum' => $ichibanNum);
                 if (WhStandardModel::update($data, "and id='{$id}'")) {
                     $c_data = array('infoId' => $id, 'sku' => $sku, 'goodsName' => $sample_info[0]['goodsName'], 'arrivalNum' => $num, 'checkNum' => $check_num, 'rejectsNum' => $rejects_num, 'rejectsReason' => $bad_reason, 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $skuTypeCheckID, 'checkTypeID' => $checkTypeID, 'sellerId' => $sellerId);
                     IqcCompleteInfoModel::insertRow($c_data);
                     /*	$data = UserCacheModel::qccenterUpdateErpGoodscount($sku,$rejects_num);
                     			
                     			$mailList['msg'] = $data;*/
                     $purchaser = userModel::getUsernameById($sample_info[0]['purchaseId']);
                     //$purchaser = userModel::getUsernameById();
                     $from = userModel::getUsernameById($_SESSION['sysUserId']);
                     $mailList['content'] = $from . "在IQC检测中检测料号 " . $_POST['sku'] . " 时检测到了:" . $_POST['num'] . "个不良品,请及时做处理!====" . date("Y-m-d H:i:s") . "====";
                     $mailList['from'] = $from;
                     $mailList['to'] = $purchaser;
                     $mailList['type'] = "email";
                     $mailList['callback'] = "";
                     self::$errMsg = "提交成功,请检测下一料号";
                     return $mailList;
                     //return true;
                 } else {
                     self::$errCode = "003";
                     self::$errMsg = "提交失败,请重试";
                     return false;
                 }
             } else {
                 self::$errCode = "003";
                 self::$errMsg = "提交失败,请重试";
                 return false;
             }
         } else {
             $set = "SET infoId='{$id}',sku='{$sku}',spu='{$spu}',defectiveNum='{$rejects_num}',note='{$bad_reason}',startTime=" . time() . " ";
             $res = DefectiveProductsModel::addDefectiveProducts($set);
             if ($res) {
                 $data = array('detectorId' => $_SESSION['sysUserId'], 'detectStartTime' => time(), 'detectStatus' => 3, 'completeStatus' => $completeStatus, 'typeId' => $checkTypeID, 'sampleTypeId' => $category, 'ichibanNum' => $ichibanNum);
                 if (WhStandardModel::update($data, "and id='{$id}'")) {
                     $c_data = array('infoId' => $id, 'sku' => $sku, 'goodsName' => $sample_info[0]['goodsName'], 'arrivalNum' => $num, 'checkNum' => $check_num, 'rejectsNum' => $rejects_num, 'rejectsReason' => $bad_reason, 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $skuTypeCheckID, 'checkTypeID' => $checkTypeID, 'sellerId' => $sellerId);
                     IqcCompleteInfoModel::insertRow($c_data);
                     $purchaser = userModel::getUsernameById($sample_info[0]['purchaseId']);
                     /*$data = UserCacheModel::qccenterUpdateErpGoodscount($sku,$rejects_num);
                     		
                     		
                     		$mailList['msg'] = $data;*/
                     //$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['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;
             }
         }
     } else {
         $data = array('detectorId' => $_SESSION['sysUserId'], 'detectStartTime' => time(), 'detectStatus' => 3, 'completeStatus' => $completeStatus, 'typeId' => $checkTypeID, 'sampleTypeId' => $category, 'ichibanNum' => $num);
         if (WhStandardModel::update($data, "and id='{$id}'")) {
             $c_data = array('infoId' => $id, 'sku' => $sku, 'goodsName' => $sample_info[0]['goodsName'], 'arrivalNum' => $num, 'checkNum' => $check_num, 'rejectsNum' => $rejects_num, 'rejectsReason' => $bad_reason, 'checkUser' => $_SESSION['sysUserId'], 'checkTime' => time(), 'skuTypeCheckID' => $skuTypeCheckID, 'checkTypeID' => $checkTypeID, 'sellerId' => $sellerId);
             IqcCompleteInfoModel::insertRow($c_data);
             self::$errMsg = "提交成功,请检测下一料号";
             return true;
         } else {
             self::$errCode = "003";
             self::$errMsg = "提交失败,请重试";
             return false;
         }
     }
 }