Esempio n. 1
0
 function act_onSampleCoefficient($cName, $sampleTypeId)
 {
     //启动一个系数,在一个事务中
     try {
         TransactionBaseModel::begin();
         $set = "SET is_open=0 ";
         $where = "WHERE cName<>'{$cName}' and sampleTypeId='{$sampleTypeId}' ";
         //先将该sampleTypeID下cName<>$cName的is_open设为0
         $affectRow1 = SampleCoefficientModel::updateSampleCoefficient($set, $where);
         $set = "SET is_open=1 ";
         $where = "WHERE cName='{$cName}' and sampleTypeId='{$sampleTypeId}' ";
         //将该sampleTypeID下$cName设为1
         $affectRow2 = SampleCoefficientModel::updateSampleCoefficient($set, $where);
         if (!$affectRow2) {
             //如果is_open=1没有更新的话,则表示已经启动或找不到该记录
             throw new Exception('update error');
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         return 1;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         self::$errCode = "1101";
         self::$errMsg = $e;
         return 0;
     }
 }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
 function act_getGroupInfo()
 {
     $userId = $_SESSION['userId'];
     $shipOrderGroup = $_POST['order_group'];
     $group_sql = WhGoodsAssignModel::getOrderGroup("*", array('assignNumber' => $shipOrderGroup));
     //var_dump($group_sql);exit;
     if (empty($group_sql)) {
         self::$errCode = "001";
         self::$errMsg = "该调拨单号不存在,请重新输入!";
         return false;
     }
     if ($group_sql[0]['status'] != 106) {
         self::$errCode = "002";
         self::$errMsg = "调拨单只有在接收复核后才可完结!";
         return false;
     }
     $orderIds = WhGoodsAssignModel::getAssignOrderIds($group_sql[0]['id']);
     if (!$orderIds) {
         self::$errCode = "003";
         self::$errMsg = "该调拨单下没有关联的B仓订单!";
         return false;
     }
     $ids = array();
     foreach ($orderIds as $id) {
         $ids[] = $id['orderId'];
     }
     TransactionBaseModel::begin();
     //更新调拨单状态
     $info = WhGoodsAssignModel::updateAssignListStatus(array('id' => $group_sql[0]['id']), array('status' => 107));
     if (!$info) {
         self::$errCode = "004";
         self::$errMsg = "更新调拨单状态失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     $ids = implode(',', $ids);
     $info = CommonModel::updateOrderStatus($ids, 745);
     if ($info['errCode'] != 200) {
         self::$errCode = "004";
         self::$errMsg = "同步旧ERP订单状态失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     self::$errCode = "0";
     self::$errMsg = "调拨单完结成功!";
     TransactionBaseModel::commit();
     return TRUE;
 }
Esempio n. 4
0
 public function act_addGroup()
 {
     TransactionBaseModel::begin();
     $group_name = isset($_POST['group_name']) ? $_POST['group_name'] : "";
     $group_num = isset($_POST['group_num']) ? $_POST['group_num'] : "";
     $userId = $_SESSION['userId'];
     $ret = addGroupModel::insertRecord($group_name, $group_num, $userId);
     if (!$ret) {
         self::$errCode = 101;
         self::$errMsg = "����ʧ��";
         TransactionBaseModel::rollback();
         return false;
     }
     TransactionBaseModel::commit();
     return true;
 }
 function act_checkSkuNum()
 {
     $bool = false;
     //标志是否有摒弃订单
     $assignNUmber = $_POST['order_group'];
     $sku = trim($_POST['sku']);
     //$sku         = getGoodsSn2($sku);
     $sku_num = $_POST['sku_num'];
     $assignId = $_POST['now_group_id'];
     //$now_pname 	    = $_POST['now_pname'];
     $assignStock = WhGoodsAssignModel::getAssignStock($sku);
     //获取该料号调拨库存
     if ($assignStock == 0) {
         self::$errCode = "004";
         self::$errMsg = "该调拨单无调拨库存,不能退库!";
         return FALSE;
     }
     if ($assignStock < $sku_num) {
         self::$errCode = "004";
         self::$errMsg = "退库数量大于调拨库存,不能退库!";
         return FALSE;
     }
     $sku_info = WhGoodsAssignModel::getDetail($assignId, " and a.sku='{$sku}'");
     if (empty($sku_info)) {
         self::$errCode = "004";
         self::$errMsg = "该调拨单无此料号!";
         return FALSE;
     }
     TransactionBaseModel::begin();
     $where = array('sku' => $sku, 'storeId' => $sku_info['storeId']);
     $update = array('actualStock' => "actualStock + {$sku_num}", 'assignStock' => "assignStock - {$sku_num}");
     $info = WhGoodsAssignModel::updateSkuLocation($where, $update);
     //更新wh_sku_location的调拨库存和总库存
     if (!$info) {
         TransactionBaseModel::rollback();
         self::$errCode = "003";
         self::$errMsg = "更新总库存失败!";
         return false;
     }
     $where = array('pId' => $skuinfo['id'], 'positionId' => $sku_info['positionId']);
     $update = array('nums' => "nums + {$sku_num}");
     $info = WhGoodsAssignModel::updateProdcutPosition($where, $update);
     //更新wh_product_position_relation的仓位库存
     if (!$info) {
         TransactionBaseModel::rollback();
         self::$errCode = "003";
         self::$errMsg = "更新仓位库存失败!";
         return false;
     }
     TransactionBaseModel::commit();
     self::$errCode = "0";
     self::$errMsg = "退库成功!";
     return true;
 }
Esempio n. 6
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 "申请失败";
     }
 }
 public function act_whShelf()
 {
     //print_r($_POST);
     $log_file = 'whselfB_log/' . date('Ymd') . '.txt';
     //日志文件路径
     $date = date('Y-m-d H:i:s');
     $userCnName = $_SESSION['userCnName'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $nums = $_POST['nums'];
     $now_position_id = intval(trim($_POST['now_position_id']));
     //现在存放该料号的仓位id
     $goodsAssignId = intval(trim($_POST['now_group_id']));
     $positionId = intval(trim($_POST['position_id']));
     //分配的仓位id
     $assignList = WhGoodsAssignModel::getAssignList("and a.id = {$goodsAssignId}", '', '', '');
     if ($assignList[0]['status'] != 106) {
         self::$errCode = 400;
         self::$errMsg = "该调拨单不在等待上架状态!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($sku)) {
         self::$errCode = 401;
         self::$errMsg = "sku不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if (empty($now_position_id) && !$positionId) {
         self::$errCode = 401;
         self::$errMsg = "上架仓位不能为空";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     if ($nums < 1) {
         self::$errCode = 403;
         self::$errMsg = "上架数量不能小于1";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     $sku_info = WhGoodsAssignModel::getDetail($goodsAssignId, " and a.sku='{$sku}' and a.inCheckNum != 0");
     if (empty($sku_info)) {
         self::$errCode = "404";
         self::$errMsg = "该调拨单无此料号!";
         return FALSE;
     }
     $whselfNums = $nums + $sku_info['whselfNum'];
     if ($whselfNums > $sku_info['assignNum']) {
         self::$errCode = "405";
         self::$errMsg = "总上架数不能大于配货数!";
         return FALSE;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 404;
         self::$errMsg = "无该料号信息";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     } else {
         $skuId = $skuinfo['id'];
         $purchaseId = $skuinfo['purchaseId'];
     }
     $ioTypeId = 35;
     //35 调拨入库上架 出入库类型表id
     $return_num = $nums;
     $in_positionId = 0;
     $userId = $_SESSION['userId'];
     //$where           =  "where pId ={$skuId} and positionId = {$now_position_id} and is_delete=0 and storeId = 2";
     TransactionBaseModel::begin();
     if ($now_position_id) {
         //存在料号仓位关系
         $positioninfo = whShelfModel::selectRelationShip('', '', 2, $now_position_id);
         //检测该料号是否有对应仓位关系
         /***无料号对应仓位的关系时更新关系表***/
         $relationId = $positioninfo[0]['id'];
         $positionId = $positioninfo[0]['positionId'];
         //仓位id
         $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$relationId}'");
         if (!$update_position) {
             self::$errCode = 410;
             self::$errMsg = "更新仓位库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $update_position, $num, $select_now_store);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新仓位库存成功!' . "{$sku}\r\n");
     } else {
         if ($positionId) {
             //没有料号仓位关系则插入一条数据
             $relationId = whShelfModel::insertRelation($skuinfo['id'], $positionId, $nums, 2);
             //插入关系表
             //$update_position = whShelfModel::updateProductPositionRelation($nums,"where id='$relationId'");
             if (!$relationId) {
                 self::$errCode = 410;
                 self::$errMsg = "插入仓位关系失败!";
                 $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $update_position, $num, $select_now_store);
                 write_log($log_file, $log_info);
                 TransactionBaseModel::rollback();
                 return false;
             }
             write_log($log_file, date('Y-m-d H:i:s') . '插入仓位关系成功!' . "{$sku}\r\n");
         }
     }
     /**** 更新总库存 *****/
     $actualStock = whShelfModel::selectSkuNums($sku, 2);
     if (!empty($actualStock)) {
         $where = "where sku='{$sku}' and storeId=2";
         $info = whShelfModel::updateStoreNum($nums, $where);
         if (!$info) {
             self::$errCode = 412;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $nums, $where);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     } else {
         $info = whShelfModel::insertStore($sku, $nums, 2);
         if (!$info) {
             self::$errCode = 413;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $sku, $nums);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     }
     /**** 插入出入库记录 *****/
     $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => $ioTypeId, 'userId' => $userId, 'reason' => '调拨入库上架');
     $record = CommonModel::addIoRecores($paraArr);
     //出库记录
     if (!$record) {
         self::$errCode = 414;
         self::$errMsg = "插入出入库记录失败!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s \r\n", $sku, $date, self::$errMsg, $record, json_encode($paraArr));
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     write_log($log_file, date('Y-m-d H:i:s') . '插入入库记录成功!' . "{$sku}\r\n");
     //更新调拨单料号上架数量
     $where = array('goodsassignId' => $goodsAssignId, 'sku' => $sku);
     $update = array('whselfNum' => $whselfNums);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if ($info === FALSE) {
         self::$errCode = 415;
         self::$errMsg = "更新上架数量失败";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s ,参数:s%\r\n", $sku, $date, self::$errMsg, $nums);
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     //更新料号调拨库存
     $where = array('sku' => $sku, 'storeId' => $assignList[0]['outStoreId']);
     $update = array('assignStock' => "assignStock - {$nums}");
     $info = WhGoodsAssignModel::updateSkuLocation($where, $update);
     if ($info == FALSE) {
         self::$errCode = 416;
         self::$errMsg = "更新调拨库存失败";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s ,参数:s%\r\n", $sku, $date, self::$errMsg, $nums);
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     /** 同步老ERP库存**/
     $pName = whShelfModel::selectPositionInfo('pName', array('id' => $positionId));
     //获取仓位名称
     $pName = $pName['pName'];
     $info = CommonModel::updateIoRecord($sku, $nums, 1, '仓库调拨入库上架', $_SESSION['userCnName'], $pName);
     //var_dump($info);exit;
     if ($info['errCode'] != 200) {
         TransactionBaseModel::rollback();
         self::$errCode = "004";
         self::$errMsg = "同步旧ERP库存失败!";
         $log_info = sprintf("料号:%s, 时间:%s,信息:%s ,参数:%s\r\n", $sku, $date, self::$errMsg, is_array($info) ? json_encode($info) : $info);
         write_log($log_file, $log_info);
         return false;
     }
     TransactionBaseModel::commit();
     self::$errMsg = "料号[{$sku}]上架成功!";
     return true;
 }
Esempio n. 8
0
 function act_addWhShipingOrderCAT()
 {
     global $memc_obj;
     //调用memcache获取sku信息
     $jsonArr = isset($_GET['jsonArr']) ? $_GET['jsonArr'] : '';
     //传过来的base64编码的json字符串(客户端要先json然后再base64))
     if (empty($jsonArr)) {
         self::$errCode = '0101';
         self::$errMsg = 'empty jsonArr';
         return 0;
     }
     $jsonArr = json_decode(base64_decode($jsonArr), true);
     //对base64及json解码
     if (!is_array($jsonArr)) {
         self::$errCode = '0201';
         self::$errMsg = 'error array';
         return 0;
     }
     if (!is_array($jsonArr['shipOrderDetail'])) {
         self::$errCode = '0301';
         self::$errMsg = 'shipOrderDetail error array';
         return 0;
     }
     try {
         TransactionBaseModel::begin();
         $originOrderId = $jsonArr['originOrderId'];
         //订单ID
         if (intval($originOrderId) == 0) {
             self::$errCode = '0401';
             self::$errMsg = 'error originOrderId';
             return 0;
         }
         $recordNumber = $jsonArr['recordNumber'];
         //订单记录各平台id号
         $shipOrderDetail = $jsonArr['shipOrderDetail'];
         //订单详细,为数组记录
         $username = $jsonArr['username'];
         //收件人
         $platformUsername = $jsonArr['platformUsername'];
         //对应平台的用户登陆名称,买家id
         $email = $jsonArr['email'];
         //客户邮箱
         $countryName = $jsonArr['countryName'];
         //收件人国家名称
         $countrySn = $jsonArr['countrySn'];
         //收件人国家简称
         $state = $jsonArr['state'];
         //收件人省份,州名
         $city = $jsonArr['city'];
         //收件人城市名称
         $street = $jsonArr['street'];
         //收件人街道
         $address2 = $jsonArr['address2'];
         //收件人地址2
         $address3 = $jsonArr['address3'];
         //收件人地址3
         $currency = $jsonArr['currency'];
         //币种
         $landline = $jsonArr['landline'];
         //座机
         $phone = $jsonArr['phone'];
         //手机
         $zipCode = $jsonArr['zipCode'];
         //邮政编码
         $transportId = $jsonArr['transportId'];
         //运输方式ID
         $accountId = $jsonArr['accountId'];
         //发货单对应销售账号
         $orderAttributes = $jsonArr['orderAttributes'];
         //发货单属性状态id,为数组
         if (empty($orderAttributes) || !is_array($orderAttributes)) {
             self::$errCode = '0501';
             self::$errMsg = 'error orderAttributes';
             return 0;
         }
         $pmId = $jsonArr['pmId'];
         //包装材料ID
         $isFixed = $jsonArr['isFixed'];
         //是否固定运输方式,默认2最优运输方式;1固定运输方式
         $total = $jsonArr['total'];
         //发货单总价值
         $channelId = $jsonArr['channelId'];
         //渠道ID
         $calcWeight = $jsonArr['calcWeight'];
         //估算重量,单位是kg
         $calcShipping = $jsonArr['calcShipping'];
         //估算运费
         $createdTime = $jsonArr['createdTime'] ? $jsonArr['createdTime'] : time();
         //添加时间
         $orderTypeId = $jsonArr['orderTypeId'] ? $jsonArr['orderTypeId'] : 1;
         //发货单类别,默认为1,发货单;2为配货单
         $companyId = $jsonArr['companyId'] ? $jsonArr['companyId'] : 1;
         //公司名称ID,默认赛维网络科技
         $storeId = $jsonArr['storeId'] ? $jsonArr['storeId'] : 1;
         //仓库ID,默认为1赛维网络深圳仓库
         $tName = 'wh_shipping_order';
         $set = "SET username='******',platformUsername='******',email='{$email}',countryName='{$countryName}',\n\t\t\t        countrySn='{$countrySn}',state='{$state}',city='{$city}',street='{$street}',address2='{$address2}',\n\t\t\t        address3='{$address3}',currency='{$currency}',landline='{$landline}',\n\t\t\t        phone='{$phone}',zipCode='{$zipCode}',transportId='{$transportId}',\n\t\t\t        accountId='{$accountId}',pmId='{$pmId}',\n\t\t\t        isFixed='{$isFixed}',total='{$total}',channelId='{$channelId}',\n\t\t\t        calcWeight='{$calcWeight}',calcShipping='{$calcShipping}',createdTime='{$createdTime}',\n\t\t\t        orderTypeId='{$orderTypeId}',companyId='{$companyId}',storeId='{$storeId}' ";
         $insertId = WhIoStoreModel::addTNameRow($tName, $set);
         if (!$insertId) {
             self::$errCode = '0801';
             self::$errMsg = 'addRow error';
             throw new Exception('add shipOrder error');
         }
         $shipOrderId = $insertId;
         //发货单ID
         foreach ($shipOrderDetail as $detail) {
             $sku = $detail['sku'];
             //sku
             $amount = $detail['amount'];
             //配货数量
             if (!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*\$/", $sku) || intval($amount) == 0) {
                 self::$errCode = '0811';
                 self::$errMsg = 'sku or amount error';
                 throw new Exception('sku or amount error');
             }
             //echo 'sku == '.$sku.'<br/>';
             $storeId = $detail['storeId'] ? $detail['storeId'] : 1;
             //仓库ID,默认为1赛维网络深圳仓库
             //echo '$memc_obj====';
             //print_r($memc_obj);
             //echo'<br/>';
             $skuInfo = $memc_obj->get_extral("sku_info_" . $sku);
             //调用memcache取得对应单料号或组合料号的重量
             //echo '$skuInfo=======';
             //print_r($skuInfo);
             //echo'<br/>';
             if (empty($skuInfo)) {
                 self::$errCode = '0814';
                 self::$errMsg = 'empty skuInfo';
                 throw new Exception('skuInfo');
             }
             //				$ppp = $memc_obj->get_extral("pc_packing_material"); //调用memcache取得对应单料号或组合料号的重量
             //				//echo '$ppp=======';
             //				//print_r($ppp);
             //				//echo'<br/>';
             if (!empty($skuInfo['sku']) && is_array($skuInfo['sku'])) {
                 //为组合料号
                 foreach ($skuInfo['sku'] as $key => $value) {
                     //循环$skuInfo下的sku的键,找出所有真实料号及对应数量,$key为组合料号下对应的真实单料号,value为对应数量
                     if (!preg_match("/^[A-Z0-9]+(_[A-Z0-9]+)*\$/", $key) || intval($value) == 0) {
                         self::$errCode = '0812';
                         self::$errMsg = 'sku or amount error';
                         throw new Exception('sku or amount error');
                     }
                     $singSkuAmount = $value * $amount;
                     //echo '$key == '.$key.'<br/>';
                     //echo '$singSkuAmount == '.$singSkuAmount.'<br/>';
                     $tName = 'wh_shipping_orderdetail';
                     $set = "SET shipOrderId='{$shipOrderId}',combineSku='{$sku}',combineNum='{$amount}',sku='{$key}',\n\t\t\t\t\t\t        amount='{$singSkuAmount}',storeId='{$storeId}' ";
                     $insertDetailId = WhIoStoreModel::addTNameRow($tName, $set);
                     if (!$insertDetailId) {
                         self::$errCode = '0802';
                         self::$errMsg = 'add shipOrderDetail1 error';
                         throw new Exception('add shipOrderDetail1 error');
                     }
                 }
             } else {
                 $tName = 'wh_shipping_orderdetail';
                 $set = "SET shipOrderId='{$shipOrderId}',sku='{$sku}',\n\t\t\t\t\t        amount='{$amount}',storeId='{$storeId}' ";
                 $insertDetailId = WhIoStoreModel::addTNameRow($tName, $set);
                 //echo'++++++++++++++++++++++++++';
                 //echo '$insertDetailId========='.$insertDetailId.'<br/>';
                 if (!$insertDetailId) {
                     self::$errCode = '0822';
                     self::$errMsg = 'add shipOrderDetail2 error';
                     throw new Exception('add shipOrderDetail2 error');
                 }
             }
         }
         //插入发货单和属性关系表
         //echo '$orderAttributes=======';
         //print_r($orderAttributes);
         //echo'<br/>';
         $tName = 'wh_order_attributes_relation';
         foreach ($orderAttributes as $orderAttribute) {
             if ($orderAttribute != 1 && $orderAttribute != 2) {
                 self::$errCode = '0805';
                 self::$errMsg = 'orderAttribute error';
                 throw new Exception('orderAttribute error');
             }
             $set = "SET shippingOrderId='{$shipOrderId}',attributeId='{$orderAttribute}'";
             $insertARId = WhIoStoreModel::addTNameRow($tName, $set);
             //echo'++++++++++++++++++++++++++';
             //echo '$insertARId========='.$insertARId.'<br/>';
             if ($insertARId !== 0) {
                 self::$errCode = '0806';
                 self::$errMsg = 'add insertARId error';
                 throw new Exception('add insertARId error');
             }
         }
         //插入订单发货单关系表
         $tName = 'wh_shipping_order_relation';
         $set = "SET originOrderId='{$originOrderId}',shipOrderId='{$shipOrderId}',recordNumber='{$recordNumber}',storeId='{$storeId}' ";
         $insertRelationId = WhIoStoreModel::addTNameRow($tName, $set);
         if (!$insertRelationId) {
             self::$errCode = '0803';
             self::$errMsg = 'add relation error';
             throw new Exception('add relation error');
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         self::$errCode = '222';
         self::$errMsg = "success";
         return 1;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         TransactionBaseModel::autoCommit();
         self::$errCode = '404';
         self::$errMsg = $e->getMessage();
         return 0;
     }
 }
Esempio n. 9
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;
     }
 }
Esempio n. 10
0
 function act_addWhRecManageDetail($jsonArr)
 {
     if (empty($jsonArr)) {
         self::$errCode = 0101;
         self::$errMsg = 'empty jsonArr';
         return 0;
     }
     if (!is_array($jsonArr)) {
         self::$errCode = 0201;
         self::$errMsg = 'error array';
         return 0;
     }
     $sku = $jsonArr['sku'];
     //sku
     $nums = $jsonArr['nums'];
     //到货数量
     $userId = $jsonArr['userId'];
     //添加人id
     $batchNum = $jsonArr['batchNum'];
     //到货批次
     $now = time();
     $flag = 0;
     //标识变量,用来判断是否要进行采购未订单;
     try {
         TransactionBaseModel::begin();
         if (empty($sku)) {
             //sku不能为空
             self::$errCode = 0101;
             self::$errMsg = 'empty sku';
             throw new Exception('empty sku');
         }
         if (empty($nums)) {
             //到货数量不能为空
             self::$errCode = 0201;
             self::$errMsg = 'empty nums';
             throw new Exception('empty nums');
         }
         if (intval($nums) == 0) {
             //数量不能为0
             self::$errCode = 0311;
             self::$errMsg = 'error nums';
             throw new Exception('error nums');
         }
         if (empty($userId)) {
             //操作人id不能为空
             self::$errCode = 0301;
             self::$errMsg = 'empty userId';
             throw new Exception('empty userId');
         }
         //            if (empty ($batchNum)) { //批次不能为空
         //				self :: $errCode = 0302;
         //				self :: $errMsg = 'empty $atchNum';
         //				throw new Exception('empty batchNum');
         //			}
         $tName = 'wh_receipt_management';
         $select = '*';
         $where = "WHERE reStatus=0 AND sku='{$sku}' ORDER BY createdTime";
         //reStatus为0,且sku符合的收货表记录
         $whRecManageList = WhRecManageModel::getTNameList($tName, $select, $where);
         if (empty($whRecManageList)) {
             //没有找到该sku对应的记录时,直接全部未订单
             self::$errCode = 222;
             self::$errMsg = 'success';
             $resupplyOrder = array();
             //采购未订单数组
             $resupplyOrder['sku'] = $sku;
             $resupplyOrder['nums'] = $nums;
             return $resupplyOrder;
         }
         $diffNums = $whRecManageList[0]['amount'] - $whRecManageList[0]['arrivedNums'];
         //该记录中能插入的最大到货数量
         if ($nums <= $diffNums) {
             //nums小于本条记录能支持的最大到货数量
             $tName = 'wh_receipt_management_details';
             $set = "SET rmId='{$whRecManageList[0]['id']}',nums='{$nums}',userId='{$userId}',batchNum='{$batchNum}',insertTime='{$now}'";
             $affectRowAdd = WhRecManageModel::addTNameRow($tName, $set);
             if (!$affectRowAdd) {
                 //未插入成功报错
                 self::$errCode = 0501;
                 self::$errMsg = 'affectRowAdd error';
                 throw new Exception('affectRowAdd error');
             }
             //同时更新匹配记录的字段,arrivedNums和reStatus
             $tName = 'wh_receipt_management';
             $set = "SET arrivedNums=arrivedNums+'{$nums}' ";
             if ($nums == $diffNums) {
                 $set .= ",reStatus=1 ";
             }
             $where = "WHERE id='{$whRecManageList[0]['id']}'";
             $affectRowUp = WhRecManageModel::updateTNameRow($tName, $set, $where);
             if (!$affectRowUp) {
                 //未插入成功报错
                 self::$errCode = 0501;
                 self::$errMsg = 'affectRowUp error';
                 throw new Exception('affectRowUp error');
             }
             $flag = 1;
         } else {
             //如果nums大于本条记录能支持的最大到货数量
             foreach ($whRecManageList as $value) {
                 $diffNums = $value['amount'] - $value['arrivedNums'];
                 //该记录中能插入的最大到货数量,此时第一次循环是,$num一定是>diffnums的
                 if ($nums <= $diffNums) {
                     //本次到货数量小于本条记录能支持的最大到货数量
                     $tName = 'wh_receipt_management_details';
                     $set = "SET rmId='{$value['id']}',nums='{$nums}',userId='{$userId}',batchNum='{$batchNum}',insertTime='{$now}'";
                     $affectRowAdd = WhRecManageModel::addTNameRow($tName, $set);
                     if (!$affectRowAdd) {
                         //未插入成功报错
                         self::$errCode = 0501;
                         self::$errMsg = 'affectRowAdd error';
                         throw new Exception('affectRowAdd error');
                     }
                     //同时更新匹配记录的字段,arrivedNums和reStatus
                     $tName = 'wh_receipt_management';
                     $set = "SET arrivedNums=arrivedNums+'{$nums}' ";
                     if ($nums == $diffNums) {
                         $set .= ",reStatus=1 ";
                     }
                     $where = "WHERE id='{$value['id']}'";
                     $affectRowUp = WhRecManageModel::updateTNameRow($tName, $set, $where);
                     if (!$affectRowUp) {
                         //未插入成功报错
                         self::$errCode = 0501;
                         self::$errMsg = 'affectRowUp error';
                         throw new Exception('affectRowUp error');
                     }
                     $flag = 1;
                     break;
                     //$nums <= $diffNums时,退出循环
                 } else {
                     //直接先将第一条匹配记录的最大差值填入
                     $tName = 'wh_receipt_management_details';
                     $set = "SET rmId='{$value['id']}',nums='{$diffNums}',userId='{$userId}',batchNum='{$batchNum}',insertTime='{$now}'";
                     $affectRowAdd = WhRecManageModel::addTNameRow($tName, $set);
                     if (!$affectRowAdd) {
                         //未插入成功报错
                         self::$errCode = 0501;
                         self::$errMsg = 'affectRowAdd error';
                         throw new Exception('affectRowAdd error');
                     }
                     //同时更新匹配记录的字段,arrivedNums和reStatus
                     $tName = 'wh_receipt_management';
                     $set = "SET arrivedNums=arrivedNums+'{$diffNums}',reStatus=1 ";
                     $where = "WHERE id='{$value['id']}'";
                     $affectRowUp = WhRecManageModel::updateTNameRow($tName, $set, $where);
                     if (!$affectRowUp) {
                         //未插入成功报错
                         self::$errCode = 0501;
                         self::$errMsg = 'affectRowUp error';
                         throw new Exception('affectRowUp error');
                     }
                     $nums = $nums - $diffNums;
                     //减去本次插入的数量,下次循环继续比对
                 }
             }
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         if ($flag == 1) {
             //不需要采购未订单
             self::$errCode = 200;
             self::$errMsg = 'success';
             return 1;
         } else {
             //需要采购未订单
             self::$errCode = 222;
             self::$errMsg = 'success';
             $resupplyOrder = array();
             //采购未订单数组
             $resupplyOrder['sku'] = $sku;
             $resupplyOrder['nums'] = $nums;
             return $resupplyOrder;
         }
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         TransactionBaseModel::autoCommit();
         return 0;
     }
 }
Esempio n. 11
0
 public function act_shiftLibrary()
 {
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $oldposition = trim($_POST['oldposition']);
     $newposition = trim($_POST['newposition']);
     $nums = intval(trim($_POST['nums']));
     if (empty($sku)) {
         self::$errCode = 401;
         self::$errMsg = "sku不能为空";
         return false;
     }
     if (empty($oldposition)) {
         self::$errCode = 402;
         self::$errMsg = "旧仓位号不能为空";
         return false;
     }
     if (empty($newposition)) {
         self::$errCode = 403;
         self::$errMsg = "新仓位号不能为空";
         return false;
     }
     if ($oldposition == $newposition) {
         self::$errCode = 404;
         self::$errMsg = "新旧仓位号不能相同";
         return false;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 404;
         self::$errMsg = "无该料号信息";
         return false;
     } else {
         $skuId = $skuinfo['id'];
     }
     $old_positon_info = OmAvailableModel::getTNameList("wh_position_distribution", "id", "where pName='{$oldposition}' and storeId in(1,2)");
     if (empty($old_positon_info)) {
         self::$errCode = 405;
         self::$errMsg = "无旧仓位号信息";
         return false;
     } else {
         $old_location = $old_positon_info[0]['id'];
     }
     $new_positon_info = OmAvailableModel::getTNameList("wh_position_distribution", "id,type", "where pName='{$newposition}' and storeId in(1,2)");
     if (empty($new_positon_info)) {
         self::$errCode = 406;
         self::$errMsg = "无新仓位号信息";
         return false;
     } else {
         $new_location = $new_positon_info[0]['id'];
     }
     $old_sku_pos_info = OmAvailableModel::getTNameList("wh_product_position_relation", "*", "where pId='{$skuId}' and positionId='{$old_location}' and storeId in(1,2) and is_delete=0");
     if (empty($old_sku_pos_info)) {
         self::$errCode = 407;
         self::$errMsg = "无sku对应的旧仓位号信息";
         return false;
     }
     $new_sku_pos_info = OmAvailableModel::getTNameList("wh_product_position_relation", "*", "where pId='{$skuId}' and positionId='{$new_location}' and storeId in(1,2) and is_delete=0");
     if ($nums > $old_sku_pos_info[0]['nums'] || empty($nums)) {
         $change_nums = $old_sku_pos_info[0]['nums'];
     } else {
         $change_nums = $nums;
     }
     OmAvailableModel::begin();
     if (!empty($new_sku_pos_info)) {
         if (empty($nums)) {
             $tname_old = "wh_product_position_relation";
             $set_old = "set nums=0,is_delete=1";
             $where_old = "where id={$old_sku_pos_info[0]['id']}";
             $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old);
             if (!$update_old) {
                 self::$errCode = 408;
                 self::$errMsg = "更新旧仓位库存失败!";
                 TransactionBaseModel::rollback();
                 return false;
             }
         } else {
             $tname_old = "wh_product_position_relation";
             $set_old = "set nums=nums-{$change_nums}";
             $where_old = "where id={$old_sku_pos_info[0]['id']}";
             $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old);
             if (!$update_old) {
                 self::$errCode = 409;
                 self::$errMsg = "更新旧仓位库存失败!";
                 TransactionBaseModel::rollback();
                 return false;
             }
         }
         $tname_new = "wh_product_position_relation";
         $set_new = "set nums=nums+{$change_nums}";
         $where_new = "where id={$new_sku_pos_info[0]['id']}";
         $update_new = OmAvailableModel::updateTNameRow($tname_new, $set_new, $where_new);
         if (!$update_new) {
             self::$errCode = 410;
             self::$errMsg = "更新新仓位库存失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     } else {
         if (empty($nums)) {
             $tname_old = "wh_product_position_relation";
             $set_old = "set nums=0,is_delete=1";
             $where_old = "where id={$old_sku_pos_info[0]['id']}";
             $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old);
             if (!$update_old) {
                 self::$errCode = 411;
                 self::$errMsg = "更新旧仓位库存失败!";
                 TransactionBaseModel::rollback();
                 return false;
             }
         } else {
             $tname_old = "wh_product_position_relation";
             $set_old = "set nums=nums-{$change_nums}";
             $where_old = "where id={$old_sku_pos_info[0]['id']}";
             $update_old = OmAvailableModel::updateTNameRow($tname_old, $set_old, $where_old);
             if (!$update_old) {
                 self::$errCode = 412;
                 self::$errMsg = "更新旧仓位库存失败!";
                 TransactionBaseModel::rollback();
                 return false;
             }
         }
         $tname_insert = "wh_product_position_relation";
         $set_insert = "set pId='{$skuId}',positionId='{$new_location}',nums='{$change_nums}',type={$new_positon_info[0]['type']}";
         $relation_insert = OmAvailableModel::insertRow($tname_insert, $set_insert);
         if (!$relation_insert) {
             self::$errCode = 413;
             self::$errMsg = "插入关系表失败!";
             TransactionBaseModel::rollback();
             return false;
         }
         /*
         //更新仓位使用状态
         $update_position = OmAvailableModel::updateTNameRow("wh_position_distribution","set is_enable=1","where id=$new_location");
         if(!$update_position){
         	self::$errCode = 414;
         	self::$errMsg = "更新仓位使用状态失败!";
         	TransactionBaseModel :: rollback();
         	return false;
         }
         */
     }
     //全部转移到新仓位,则将仓位同步到老ERP
     if (!$nums) {
         $info = CommonModel::updateSkuLocation($sku, $newposition);
         //print_r($info);exit;
         if ($info['res_code'] != 200) {
             self::$errCode = 414;
             self::$errMsg = '同步旧ERP仓位失败!';
             return FALSE;
         }
     }
     OmAvailableModel::commit();
     self::$errMsg = "料号[{$sku}]移库成功!";
     return true;
 }
Esempio n. 12
0
 function act_auditIoStore()
 {
     $ordersn = isset($_GET['ordersn']) ? $_GET['ordersn'] : '';
     //单据编码
     $auditStatus = isset($_GET['auditStatus']) ? $_GET['auditStatus'] : '';
     //审核状态,1为通过,2为不通过
     $auditorId = isset($_GET['auditorId']) ? $_GET['auditorId'] : '';
     //审核人id
     $now = time();
     //当前时间
     if (empty($ordersn)) {
         self::$errCode = 0201;
         self::$errMsg = 'empty ordersn';
         return 3;
     }
     if (intval($auditStatus) != 1 && intval($auditStatus) != 2) {
         self::$errCode = 0201;
         self::$errMsg = 'error auditStatus';
         return 5;
     }
     if (intval($auditorId) == 0) {
         self::$errCode = 0201;
         self::$errMsg = 'error auditorId';
         return 6;
     }
     //根据ordersn取出对应的invoiceTypeId,storeId
     $tName = 'wh_iostore';
     $select = 'invoiceTypeId,storeId';
     $where = "WHERE is_delete=0 AND ordersn='{$ordersn}'";
     $whIostoreList = WhAuditModel::getTNameList($tName, $select, $where);
     if (empty($whIostoreList)) {
         //ioStore表中不存在ordersn这条记录
         self::$errCode = 0201;
         self::$errMsg = 'empty whIostoreList';
         return 7;
     }
     $invoiceTypeId = $whIostoreList[0]['invoiceTypeId'];
     //出入库单据类型
     $storeId = $whIostoreList[0]['storeId'];
     //仓库id
     try {
         TransactionBaseModel::begin();
         $nowInsertALevel = 0;
         //定义一个变量用来存放本次插入的审核等级
         $whARByOrdersn = WhAuditModel::getAuditRecordsByOrdersn($ordersn);
         //根据ordersn在records表中查找出最大id,其最大id所在的auditrelationId所关联的auditlevel就是该ordersn已经存在的最大审核级别记录
         if (empty($whARByOrdersn)) {
             //如果$whARByOrdersn为空,则表示records表中没有该ordersn的记录,
             $minALevel = WhAuditModel::getMinALevelByIS($invoiceTypeId, $storeId);
             //取出list表中invoiceTypeId,storeId下已经开启的最小的auditLevel
             if (empty($minALevel)) {
                 //如果$minALevel为空,表示list表中不存在开启的$invoiceTypeId,$storeId的记录
                 self::$errCode = 0201;
                 self::$errMsg = 'empty minALevel';
                 return 8;
             }
             $whWillInsertAid = WhAuditModel::getALIdByAA($invoiceTypeId, $storeId, $minALevel, $auditorId);
             //取得invoiceTypeId,storeId下和本次auditorId匹配的最小level的list中的id
             if (empty($whWillInsertAid)) {
                 //如果$whWillInsertAid为空,表示该最小的level没有和auditor有对应的关系,可能是不存在这条审核类型记录或者是审核人无权限,或者是审核类型记录被禁用了
                 self::$errCode = 0201;
                 self::$errMsg = 'empty whWillInsertAid';
                 return 9;
             }
             $tName = 'wh_audit_records';
             $set = "SET ordersn='{$ordersn}',auditRelationId='{$whWillInsertAid}',auditStatus='{$auditStatus}',auditTime='{$now}'";
             $affectRow = WhAuditModel::addTNameRow($tName, $set);
             if (!$affectRow) {
                 //插入错误或者是影响记录数为0时抛出异常
                 throw new Exception('add error');
             }
             $nowInsertALevel = $minALevel;
             //本次插入的审核等级
         } else {
             //如果$whARByOrdersn不为空,则表示records表中有该ordersn的记录,此时需要找出记录中最大的auditlevel
             $whARAidsArray = array();
             //定义一个数组存放$whARByOrdersn中的auditRelationId
             foreach ($whARByOrdersn as $value) {
                 $whARAidsArray[] = $value['auditRelationId'];
             }
             $whARAidsString = implode(',', $whARAidsArray);
             //将$whARAidsArray转化成id1,id2,id3形式的字符串
             $maxALevel = WhAuditModel::getMaxLevelByAIds($whARAidsString);
             //查找出$whARAidsString中auditLevel最大的
             if (empty($maxALevel)) {
                 //如果为空,表示$whARAidsString中在list中都没有已经开启的记录,可能是全被人禁用了
                 self::$errCode = 0201;
                 self::$errMsg = 'empty maxALevel';
                 return 10;
             }
             $whNextALevel = WhAuditModel::getNextLevelByISL($invoiceTypeId, $storeId, $maxALevel);
             //根据当前最大的auditLevel取得下一个auditLevel的值
             if (empty($whNextALevel)) {
                 //如果$whNextALevel为空,表示当前record表中最大的审核等级已经是list中最大的审核等级,不存在下一级审核了
                 self::$errCode = 0201;
                 self::$errMsg = 'empty whNextALevel';
                 return 11;
             }
             $whWillInsertAid = WhAuditModel::getALIdByAA($invoiceTypeId, $storeId, $whNextALevel, $auditorId);
             //查找本次要插入records表记录的auditRelationId
             if (empty($whWillInsertAid)) {
                 //$whWillInsertAid为空,表示$auditorId不存在该开启的这条记录中
                 self::$errCode = 0201;
                 self::$errMsg = 'empty whWillInsertAid';
                 return 12;
             }
             $tName = 'wh_audit_records';
             $set = "SET ordersn='{$ordersn}',auditRelationId='{$whWillInsertAid}',auditStatus='{$auditStatus}',auditTime='{$now}'";
             $affectRow = WhAuditModel::addTNameRow($tName, $set);
             if (!$affectRow) {
                 throw new Exception('add error2');
             }
             $nowInsertALevel = $whNextALevel;
             //本次要插入的审核等级
         }
         if ($auditStatus == 2) {
             //如果本次审核结果为不通过时,反些iostore表中该ordersn的ioStatus为不通过,和endTime
             $tName = 'wh_iostore';
             $set = "SET ioStatus='3',endTime='{$now}',operatorId='{$auditorId}' ";
             $where = "WHERE ordersn='{$ordersn}' AND is_delete=0";
             $affectRow = WhAuditModel::updateTNameRow($tName, $set, $where);
             if (!$affectRow) {
                 throw new Exception('update error1');
             }
         } else {
             //如果审核为通过时,要判断本次审核是不是最后一次审核,如果是最后一次审核,则要反写ioStatus中的值
             if ($nowInsertALevel == 0) {
                 //如果$nowInsertALevel为0,表示程序异常
                 self::$errCode = 0201;
                 self::$errMsg = 'empty $nowInsertALevel';
                 return 13;
             }
             $whNextALevel = WhAuditModel::getNextLevelByISL($invoiceTypeId, $storeId, $nowInsertALevel);
             //本次审核等级的下次审核等级
             if (empty($whNextALevel)) {
                 //如果$whNextALevel为空,表示没有下一级审核,该次审核为最后一次审核,此时要反写ioStatus等信息
                 $tName = 'wh_iostore';
                 if ($auditStatus == 1) {
                     $ioStatus = 2;
                 } else {
                     $ioStatus = 3;
                 }
                 $set = "SET ioStatus='{$ioStatus}',endTime='{$now}',operatorId='{$auditorId}' ";
                 $where = "WHERE ordersn='{$ordersn}' AND is_delete=0";
                 $affectRow = WhAuditModel::updateTNameRow($tName, $set, $where);
                 if (!$affectRow) {
                     throw new Exception('update error2');
                 }
                 if ($auditStatus == 1) {
                     //如果是最后一级审核,并且审核通过的话,添加出入库记录及加减库存
                     $ioTypeList = WhAuditModel::getIoTypeById($invoiceTypeId);
                     //根据id查出invoiceType表中的ioType和ioTypeId
                     if (empty($ioTypeList)) {
                         //如果没找到对应的ioTypeId,和ioType,则抛出异常
                         throw new Exception('empty ioTypeList');
                     }
                     $ioType = $ioTypeList['ioType'];
                     $ioTypeId = $ioTypeList['ioTypeId'];
                     $whIoRecordsAct = new WhIoRecordsAct();
                     //库方法中
                     $ioType = $ioType == 0 ? 1 : 2;
                     //在act_addIoRecoresForWh中inType为1表示出库,2表示入库
                     $iostoreId = WhAuditModel::getIdByOrdersn($ordersn);
                     //取得ordersn所在的iostoreId
                     $tName = 'wh_iostoredetail';
                     $select = '*';
                     $where = "WHERE is_delete=0 AND iostoreId='{$iostoreId}'";
                     $iostoreDetailList = WhAuditModel::getTNameList($tName, $select, $where);
                     if (empty($iostoreDetailList)) {
                         throw new Exception('empty iostoreDetailList');
                     }
                     foreach ($iostoreDetailList as $value) {
                         //进行出入库记录和添加库存操作
                         $sku = $value['sku'];
                         $amount = $value['amount'];
                         $purchaseId = $value['purchaseId'];
                         $userId = $auditorId;
                         if (empty($ordersn)) {
                             self::$errCode = '0301';
                             self::$errMsg = 'empty ordersn';
                             return 0;
                         }
                         if (empty($sku)) {
                             self::$errCode = '0401';
                             self::$errMsg = 'sku';
                             return 0;
                         }
                         if (empty($amount)) {
                             self::$errCode = '0501';
                             self::$errMsg = 'empty amount';
                             return 0;
                         }
                         if (empty($purchaseId)) {
                             self::$errCode = '0601';
                             self::$errMsg = 'empty purchaseId';
                             return 0;
                         }
                         if (empty($ioType)) {
                             self::$errCode = '0701';
                             self::$errMsg = '';
                             return 0;
                         }
                         if (empty($ioTypeId)) {
                             self::$errCode = '0801';
                             self::$errMsg = 'empty ioTypeId';
                             return 0;
                         }
                         if (empty($userId)) {
                             self::$errCode = '0901';
                             self::$errMsg = 'empty userId';
                             return 0;
                         }
                         if (empty($storeId)) {
                             self::$errCode = '1001';
                             self::$errMsg = 'emptyOrError storeId';
                             return 0;
                         }
                         if ($ioType != 1 && $ioType != 2) {
                             self::$errCode = '1101';
                             self::$errMsg = 'error ioType';
                             return 0;
                         }
                         $tName = 'wh_iorecords';
                         $set = "SET ordersn='{$ordersn}',sku='{$sku}',amount='{$amount}',purchaseId='{$purchaseId}',ioType='{$ioType}',ioTypeId='{$ioTypeId}',userId='{$userId}',reason='{$reason}',createdTime='{$now}',storeId='{$storeId}'";
                         $ret = WhIoRecordsModel::addTNameRow($tName, $set);
                         //添加入库记录
                         if ($ret) {
                             $tName = 'wh_sku_location';
                             if ($ioType == 1) {
                                 $amount = -1 * $amount;
                             }
                             $set = "SET actualStock=actualStock+{$amount}";
                             $where = "WHERE sku='{$sku}' AND storeId='{$storeId}'";
                             $affectRow = WhIoRecordsModel::updateTNameRow($tName, $set, $where);
                             //库存变化
                             if (!$affectRow) {
                                 throw new Exception('');
                             }
                         } else {
                             throw new Exception('');
                         }
                     }
                 }
             }
         }
         TransactionBaseModel::commit();
         TransactionBaseModel::autoCommit();
         self::$errCode = 200;
         self::$errMsg = 'success';
         return 200;
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         TransactionBaseModel::autoCommit();
         return 404;
     }
 }
Esempio n. 13
0
 /**
  * Pda_makeAssignListAct::act_makeAssignList()
  * 生成调拨单编号并更新调拨明细表 
  * @return void
  */
 public function act_makeAssignList()
 {
     $res = WhGoodsAssignModel::getDetail('0', '');
     //检测是否有未生成调拨单的料号信息
     if (empty($res)) {
         self::$errCode = '001';
         self::$errMsg = '没有可以生成调拨单的料号信息!';
         return FALSE;
     }
     $outStoreId = 1;
     $inStoreId = 2;
     $createdUid = $_SESSION['userId'];
     $whGoodsAssignAct = new WhGoodsAssignAct();
     $assignNumber = $whGoodsAssignAct->buildAssignNumber();
     //获取调拨单编号
     TransactionBaseModel::begin();
     //调拨单表中插入数据并获取插入id
     $goodsAssignId = WhGoodsAssignModel::addAssignList($assignNumber, $outStoreId, $inStoreId, time(), time(), $createdUid);
     if ($goodsAssignId == FALSE) {
         self::$errCode = 02;
         self::$errMsg = '生成调拨单失败!';
         return FALSE;
     }
     $where = array('goodsAssignId' => 0, 'is_delete' => 0);
     $update = array('goodsAssignId' => $goodsAssignId);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if ($info) {
         TransactionBaseModel::commit();
         self::$errCode = '200';
         self::$errMsg = '生成调拨单【' . $assignNumber . '】!';
         return TRUE;
     } else {
         TransactionBaseModel::commit();
         self::$errCode = '003';
         self::$errMsg = '生成调拨单失败!';
         return FALSE;
     }
 }
Esempio n. 14
0
 function act_addIoRecores()
 {
     $paraArr = isset($_GET['paraArr']) ? $_GET['paraArr'] : '';
     //参数base64,json数组,具体键如下,
     try {
         TransactionBaseModel::begin();
         if (empty($paraArr)) {
             self::$errCode = '0101';
             self::$errMsg = 'empty paraArr';
             throw new Exception('');
         }
         $paraArr = json_decode(base64_decode($paraArr), true);
         //对base64及json解码
         if (!is_array($paraArr)) {
             self::$errCode = '0201';
             self::$errMsg = 'is not array';
             throw new Exception('');
         }
         $ordersn = $paraArr['ordersn'];
         //发货单号或者是单据的ordersn
         $sku = $paraArr['sku'];
         //sku
         $amount = $paraArr['amount'];
         //数量
         $purchaseId = $paraArr['purchaseId'];
         //采购员id
         $ioType = $paraArr['ioType'];
         //出/入库,1为出库,2为入库
         $ioTypeId = $paraArr['ioTypeId'];
         //出入库类型id,即出入库类型表中对应的id
         $userId = $paraArr['userId'];
         //添加人id
         $reason = isset($paraArr['reason']) ? $paraArr['reason'] : '';
         //原因
         $storeId = isset($paraArr['storeId']) ? intval($paraArr['storeId']) : 1;
         $createdTime = time();
         $tName = 'wh_iorecords';
         if (empty($ordersn)) {
             self::$errCode = '0301';
             self::$errMsg = 'empty ordersn';
             throw new Exception('');
         }
         if (empty($sku)) {
             self::$errCode = '0401';
             self::$errMsg = 'sku';
             throw new Exception('');
         }
         if (empty($amount)) {
             self::$errCode = '0501';
             self::$errMsg = 'empty amount';
             throw new Exception('');
         }
         if (empty($purchaseId)) {
             self::$errCode = '0601';
             self::$errMsg = 'empty purchaseId';
             throw new Exception('');
         }
         if (empty($ioType)) {
             self::$errCode = '0701';
             self::$errMsg = '';
             throw new Exception('');
         }
         if (empty($ioTypeId)) {
             self::$errCode = '0801';
             self::$errMsg = 'empty ioTypeId';
             throw new Exception('');
         }
         if (empty($userId)) {
             self::$errCode = '0901';
             self::$errMsg = 'empty userId';
             throw new Exception('');
         }
         if (empty($storeId)) {
             self::$errCode = '1001';
             self::$errMsg = 'emptyOrError storeId';
             throw new Exception('');
         }
         if ($ioType != 1 && $ioType != 2) {
             self::$errCode = '1101';
             self::$errMsg = 'error ioType';
             throw new Exception('');
         }
         $set = "SET ordersn='{$ordersn}',sku='{$sku}',amount='{$amount}',purchaseId='{$purchaseId}',ioType='{$ioType}',ioTypeId='{$ioTypeId}',userId='{$userId}',reason='{$reason}',createdTime='{$createTime}',storeId='{$storeId}'";
         $ret = WhIoRecordsModel::addTNameRow($tName, $set);
         //添加入库记录
         if ($ret) {
             $tName = 'wh_sku_location';
             if ($ioType == 1) {
                 $amount = -1 * $amount;
             }
             $set = "SET actualStock=actualStock+{$amount}";
             $where = "WHERE sku='{$sku}' AND storeId='{$storeId}'";
             $affectRow = WhIoRecordsModel::updateTNameRow($tName, $set, $where);
             if ($affectRow) {
                 self::$errCode = '200';
                 self::$errMsg = 'success';
                 TransactionBaseModel::commit();
                 TransactionBaseModel::autoCommit();
                 return 1;
             } else {
                 self::$errCode = '1201';
                 //库存加减错误
                 self::$errMsg = 'addAmount error';
                 throw new Exception('');
             }
         } else {
             self::$errCode = '1301';
             //添加记录错误
             self::$errMsg = 'addRecords error';
             throw new Exception('');
         }
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         TransactionBaseModel::autoCommit();
         return 0;
     }
 }
Esempio n. 15
0
 function act_deleteWhIoStore()
 {
     $iostoreId = isset($_GET['iostoreId']) ? $_GET['iostoreId'] : '';
     //传过来的base64编码的json字符串
     try {
         TransactionBaseModel::begin();
         //开始事务
         if (empty($iostoreId)) {
             //如果iostoreId为空,则抛出异常
             self::$errCode = 0101;
             self::$errMsg = 'empty iostoreId';
             throw new Exception('empty iostoreId');
         }
         $tName = 'wh_iostore';
         $set = "SET is_delete=1 ";
         $where = "WHERE id='{$iostoreId}' ";
         $affectRows = WhIoStoreModel::updateTNameRow($tName, $set, $where);
         //将ioStore表记录标记为删除,is_delete=1
         if (!$affectRows) {
             //执行错误或者affectedRows为0则抛出异常
             self::$errCode = 0201;
             self::$errMsg = 'deleteRow error';
             throw new Exception('deleteRow error');
         }
         $tName = 'wh_iostoredetail';
         $where = "WHERE iostoreId='{$iostoreId}' ";
         $affectRowsDetail = WhIoStoreModel::updateTNameRow($tName, $set, $where);
         //对应iostoreId的iostoredetail表中也标记删除对应记录
         if ($affectRowsDetail === false) {
             //执行错误则抛出异常(不包括影响记录为0的情况)
             self::$errCode = 0301;
             self::$errMsg = 'deleteDetailRow error';
             throw new Exception('deleteDetailRow error');
         }
         TransactionBaseModel::commit();
         //执行
         TransactionBaseModel::autoCommit();
         //重新设置事务为自动提交
         self::$errCode = 200;
         self::$errMsg = 'success';
         return 1;
         //返回正确
     } catch (Exception $e) {
         TransactionBaseModel::rollback();
         //回滚
         TransactionBaseModel::autoCommit();
         return 0;
     }
 }
Esempio n. 16
0
 public function act_waveAllocation()
 {
     //单个发货单
     $singleInvoiceWeight = isset($_POST['singleInvoiceWeight']) ? $_POST['singleInvoiceWeight'] : 0;
     $singleInvoiceVolume = isset($_POST['singleInvoiceVolume']) ? $_POST['singleInvoiceVolume'] : 0;
     $singleInvoiceSkuNum = isset($_POST['singleInvoiceSkuNum']) ? $_POST['singleInvoiceSkuNum'] : 0;
     $singleInvoiceId = isset($_POST['singleInvoiceId']) ? $_POST['singleInvoiceId'] : '';
     //单SKU
     $singleSkuWeigh = isset($_POST['singleSkuWeigh']) ? $_POST['singleSkuWeigh'] : 0;
     $singleSkuVolume = isset($_POST['singleSkuVolume']) ? $_POST['singleSkuVolume'] : 0;
     $singleSkuNum = isset($_POST['singleSkuNum']) ? $_POST['singleSkuOrderNum'] : 0;
     $singleSkuOrderNum = isset($_POST['singleSkuOrderNum']) ? $_POST['singleSkuOrderNum'] : 0;
     $singleSkuId = isset($_POST['singleSkuId']) ? $_POST['singleSkuId'] : '';
     //多SKU
     $skusWeight = isset($_POST['skusWeight']) ? $_POST['skusWeight'] : 0;
     $skusVolume = isset($_POST['skusVolume']) ? $_POST['skusVolume'] : 0;
     $skusNum = isset($_POST['skusNum']) ? $_POST['skusNum'] : 0;
     $skusOrderNum = isset($_POST['skusOrderNum']) ? $_POST['skusOrderNum'] : 0;
     $skusId = isset($_POST['skusId']) ? $_POST['skusId'] : '';
     //单个发货单拆分起点
     $singleInvoiceSplitWeight = isset($_POST['singleInvoiceSplitWeight']) ? $_POST['singleInvoiceSplitWeight'] : 0;
     $singleInvoiceSplitVolume = isset($_POST['singleInvoiceSplitVolume']) ? $_POST['singleInvoiceSplitVolume'] : 0;
     $singleInvoiceSplitSkuNum = isset($_POST['singleInvoiceSplitSkuNum']) ? $_POST['singleInvoiceSplitSkuNum'] : 0;
     $singleInvoiceSplitId = isset($_POST['singleInvoiceSplitId']) ? $_POST['singleInvoiceSplitId'] : '';
     //单个发货单每个波次拆分
     $singleInvoiceSplitEachWeigh = isset($_POST['singleInvoiceSplitEachWeigh']) ? $_POST['singleInvoiceSplitEachWeigh'] : 0;
     $singleInvoiceSplitEachVolume = isset($_POST['singleInvoiceSplitEachVolume']) ? $_POST['singleInvoiceSplitEachVolume'] : 0;
     $singleInvoiceSplitEachNum = isset($_POST['singleInvoiceSplitEachNum']) ? $_POST['singleInvoiceSplitEachNum'] : 0;
     $singleInvoiceSplitEachId = isset($_POST['singleInvoiceSplitEachId']) ? $_POST['singleInvoiceSplitEachId'] : '';
     $insertData = array(array('limitWeight' => $singleInvoiceWeight, 'limitVolume' => $singleInvoiceVolume, 'limitSkuNums' => $singleInvoiceSkuNum, 'limitOrderNums' => 0, 'waveType' => 1, 'limitType' => 1, 'id' => $singleInvoiceId), array('limitWeight' => $singleSkuWeigh, 'limitVolume' => $singleSkuVolume, 'limitSkuNums' => $singleSkuNum, 'limitOrderNums' => $singleSkuOrderNum, 'waveType' => 2, 'limitType' => 1, 'id' => $singleSkuId), array('limitWeight' => $skusWeight, 'limitVolume' => $skusVolume, 'limitSkuNums' => $skusNum, 'limitOrderNums' => $skusOrderNum, 'waveType' => 3, 'limitType' => 1, 'id' => $skusId), array('limitWeight' => $singleInvoiceSplitWeight, 'limitVolume' => $singleInvoiceSplitVolume, 'limitSkuNums' => $singleInvoiceSplitSkuNum, 'limitOrderNums' => 0, 'waveType' => 1, 'limitType' => 2, 'id' => $singleInvoiceSplitId), array('limitWeight' => $singleInvoiceSplitEachWeigh, 'limitVolume' => $singleInvoiceSplitEachVolume, 'limitSkuNums' => $singleInvoiceSplitEachNum, 'limitOrderNums' => 0, 'waveType' => 1, 'limitType' => 3, 'id' => $singleInvoiceSplitEachId));
     TransactionBaseModel::begin();
     //开始事物
     //插入数据
     foreach ($insertData as $data) {
         $id = $data['id'];
         unset($data['id']);
         if (empty($id)) {
             $insertId = WhWaveConfigModel::insertWaveConfigRow($data);
             if (!$insertId) {
                 self::$errCode = 101;
                 self::$errMsg = "数据插入失败";
                 TransactionBaseModel::rollback();
                 return false;
             }
         } else {
             if (!WhWaveConfigModel::updateWaveConfig($data, ' AND id = ' . $id)) {
                 self::$errCode = 102;
                 self::$errMsg = "更新数据失败";
                 TransactionBaseModel::rollback();
                 return false;
             }
         }
     }
     TransactionBaseModel::commit();
     return true;
 }
Esempio n. 17
0
 public function act_whShelf()
 {
     //print_r($_POST);
     $userCnName = $_SESSION['userCnName'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $nums = $_POST['nums'];
     $select_now_position = $_POST['select_now_position'];
     $select_now_store = $_POST['select_now_store'];
     $select_hope_position = $_POST['select_hope_position'];
     $select_hope_store = $_POST['select_hope_store'];
     if (empty($sku)) {
         self::$errCode = 401;
         self::$errMsg = "sku不能为空";
         return false;
     }
     if (empty($select_now_position) && empty($select_now_store) && empty($select_hope_position) && empty($select_hope_store)) {
         self::$errCode = 401;
         self::$errMsg = "上架位置不能为空";
         return false;
     }
     /*
     $where = "where sku='{$sku}' and tallyStatus=0";
     $tallying_list  = packageCheckModel::selectList($where);
     if(empty($tallying_list)){
     	self::$errCode = 402;
     	self::$errMsg  = "无该料号点货信息";
     	return false;
     }else{
     	$tallying_num = 0;
     	foreach($tallying_list as $tallying){
     		$tallying_num += $tallying['ichibanNums']-$tallying['shelvesNums'];
     	}
     	if($nums>$tallying_num){
     		self::$errCode = 402;
     		self::$errMsg  = "上架数不能大于点货良品数[{$tallying_num}]";
     		return false;
     	}
     }
     */
     if ($nums < 1) {
         self::$errCode = 403;
         self::$errMsg = "上架数量不能小于1";
         return false;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 404;
         self::$errMsg = "无该料号信息";
         return false;
     } else {
         $skuId = $skuinfo['id'];
         $purchaseId = $skuinfo['purchaseId'];
     }
     /*
     		$purInfo = CommonModel::endPurchaseOrder($sku,$nums);             //api获取采购订单处理情况
     		if($purInfo!=0){
     			self::$errCode = 405;
     			self::$errMsg  = "完结采购订单出错,上架失败";
     			return false;
     		}
     		
     		//更新旧erp库存
     		$update_onhand = CommonModel::updateOnhand($sku,$nums);
     		if($update_onhand==0){
     			self::$errCode = 415;
     			self::$errMsg = "更新erp库存失败";
     			return false;
     		}*/
     $return_num = $nums;
     $in_positionId = 0;
     $userId = $_SESSION['userId'];
     TransactionBaseModel::begin();
     /****插入采购未订单记录****/
     /*
     if($return_num>0){
     	$where = " where sku = '{$sku}' and tallyStatus=0";
     	$list  = whShelfModel::selectList($where);
     	$purchaseId = $list[0]['purchaseId'];
     	$totalNums = 0;
     	foreach($list as $key=>$value){
     		$totalNums += $value['num'];
     	}
     	if ($return_num==$nums){
     		$reach_note = "sku[{$sku}]到货{$nums}个,未找到该料号的订单,请物料点货确认和采购补单!";
     	}else{
     		$reach_note = "sku[{$sku}]到货{$nums}个,入库完毕后还多余{$return_num}个,请物料点货确认和采购补单!";
     	}
     	$msg = whShelfModel::insertNoOrder($sku,$return_num,$totalNums,$purchaseId,$userId,$reach_note);
     	if(!$msg){
     		self::$errCode = whShelfModel::$errCode;
     		self::$errMsg  = whShelfModel::$errMsg;
     		return false;
     	}
     }
     */
     /***无料号对应仓位的关系时更新关系表***/
     if ($select_hope_store != 0 || $select_hope_position != 0) {
         $type = 1;
         $positionId = $select_hope_position;
         if ($select_hope_store != 0) {
             $type = 2;
             $positionId = $select_hope_store;
         }
         $in_positionId = $positionId;
         $tname = "wh_product_position_relation";
         $set = "set pId='{$skuId}',positionId='{$positionId}',nums='{$nums}',type='{$type}',storeId=2";
         $insert_relation = OmAvailableModel::insertRow($tname, $set);
         if (!$insert_relation) {
             self::$errCode = 408;
             self::$errMsg = "插入关系表失败!";
             TransactionBaseModel::rollback();
             return false;
         }
         //更新仓位使用状态
         $update_position = OmAvailableModel::updateTNameRow("wh_position_distribution", "set is_enable=1", "where id={$positionId}");
         if ($update_position === false) {
             self::$errCode = 409;
             self::$errMsg = "更新仓位使用状态失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     }
     //更新指定仓位存货数量
     if ($select_now_store != 0) {
         $positioninfo = whShelfModel::selectRelation("where id={$select_now_store}");
         $in_positionId = $positioninfo[0]['positionId'];
         $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_store}'");
         if (!$update_position) {
             self::$errCode = 410;
             self::$errMsg = "更新仓位库存失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     }
     if ($select_now_store == 0 && $select_hope_position == 0 && $select_hope_store == 0) {
         $positioninfo = whShelfModel::selectRelation("where id={$select_now_position}");
         $in_positionId = $positioninfo[0]['positionId'];
         $update_position = whShelfModel::updateProductPositionRelation($nums, "where id='{$select_now_position}'");
         if (!$update_position) {
             self::$errCode = 411;
             self::$errMsg = "更新仓位库存失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     }
     /**** 更新总库存 *****/
     $actualStock = whShelfModel::selectSkuNums($sku, 2);
     if (!empty($actualStock)) {
         $where = "where sku='{$sku}' and storeId=2";
         $info = whShelfModel::updateStoreNum($nums, $where);
         if (!$info) {
             self::$errCode = 412;
             self::$errMsg = "更新总库存失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     } else {
         $info = packageCheckModel::insertStore($sku, $nums, 2);
         if (!$info) {
             self::$errCode = 412;
             self::$errMsg = "更新总库存失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     }
     /**** 插入出入库记录 *****/
     $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $in_positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => 13, 'userId' => $userId, 'reason' => '上架入库', 'storeId' => 2);
     $record = CommonModel::addIoRecores($paraArr);
     //出库记录
     if (!$record) {
         self::$errCode = 413;
         self::$errMsg = "插入出入库记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     /*
     //更新点货记录状态
     $where = "where sku='{$sku}' and tallyStatus=0 and ichibanNums>0";
         	$list  = packageCheckModel::selectList($where);
     $i = 0;
     while($list[$i]&&$nums){
     	$need_nums = $list[$i]['ichibanNums']-$list[$i]['shelvesNums'];
     	if($nums >= $need_nums){
     		//更改状态
     		$msg = whShelfModel::updateTallyStatus($list[$i]['id'],$need_nums);
     		if(!$msg){
     			self::$errCode = 413;
     			self::$errMsg  = "更新点货记录状态失败!";
     			TransactionBaseModel :: rollback();
     			return false;
     		}
     		$nums = $nums-$need_nums;
     	}else{
     		$msg = whShelfModel::updateShelfNum($list[$i]['id'],$nums);
     		if(!$msg){
     			self::$errCode = 414;
     			self::$errMsg  = "更新点货记录已上架数量失败!";
     			TransactionBaseModel :: rollback();
     			return false;
     		}
     		$nums = 0;
     	}
     	$i++;
     }
     */
     /*
     $purInfo = CommonModel::endPurchaseOrder($sku,$return_num);             //api获取采购订单处理情况
     if($purInfo!=0){
     	self::$errCode = 405;
     	self::$errMsg  = "完结采购订单出错,上架失败";
     	TransactionBaseModel :: rollback();
     	return false;
     }
     
     //更新旧erp库存
     $position_info = PositionModel::getPositionList("pName","where id={$in_positionId}");
     $update_onhand = CommonModel::updateOnhand($sku,$return_num,$userCnName,$position_info[0]['pName']);
     if($update_onhand==0){
     	self::$errCode = 415;
     	self::$errMsg = "更新旧erp库存失败";
     	TransactionBaseModel :: rollback();
     	return false;
     }
     */
     TransactionBaseModel::commit();
     self::$errMsg = "料号[{$sku}]上架成功!";
     return true;
 }
Esempio n. 18
0
 function act_checkSkuNum()
 {
     $bool = false;
     //标志是否有摒弃订单
     $assignNUmber = $_POST['order_group'];
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $skuinfo = whShelfModel::selectSku(" where sku = '{$sku}'");
     //获取sku信息
     //print_r($skuinfo);exit;
     //var_dump($skuinfo);exit;
     //$sku         = getGoodsSn2($sku);
     $sku_num = $_POST['sku_num'];
     $assignId = $_POST['now_group_id'];
     $now_pname = $_POST['now_pname'];
     $sku_info = WhGoodsAssignModel::getDetail($assignId, " and a.sku='{$sku}' and a.checkUid=0");
     //调拨单明细中的sku信息
     //$sku_onhand 	= GroupDistributionModel::getSkuPositionStock("and c.sku='$sku' and b.pName='$now_pname'");
     //$order_sku_info = $this->get_valid_order($sku_info[0]['shipOrderGroup'],$sku_info[0]['sku'],$sku_info[0]['pName']);
     $now_num = $sku_num + $sku_info['assignNum'];
     //已配货数加上本次配货数
     if (!is_numeric($sku_num) || $now_num < 0) {
         self::$errCode = "007";
         self::$errMsg = "出库数量必须为正整数,请确认!";
         return false;
     }
     if ($sku_info['num'] < $now_num) {
         self::$errCode = "008";
         self::$errMsg = "配货数量不能大于原始需求数量!";
         return false;
     }
     //print_r($sku_info);exit;
     $erp_onhand = CommonModel::getErpSkuInfo($sku);
     //获取老ERP料号库存信息
     if ($erp_onhand['errocode'] != 200) {
         self::$errCode = "014";
         self::$errMsg = "拉取老ERP库存信息失败,请稍后再试!";
         return false;
     }
     //根据转出仓库获取库存
     $goods_count = $sku_info['storeId'] == 1 ? $erp_onhand['data']['goods_count'] : $erp_onhand['data']['second_count'];
     if ($sku_num > $goods_count) {
         self::$errCode = "009";
         self::$errMsg = "配货数量不能大于旧ERP系统库存[{$goods_count}],请确认!";
         return false;
     }
     $uid = $_SESSION['userId'];
     $scanTime = time();
     $where = array('goodsAssignId' => $assignId, 'sku' => $sku);
     //拼接where条件
     $update = array('scanUid' => $uid, 'scanTime' => $scanTime, 'assignNum' => "assignNum+{$sku_num}");
     //拼接更新字段
     TransactionBaseModel::begin();
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if ($info) {
         $where = array('sku' => $sku, 'storeId' => $sku_info['storeId']);
         $update = array('actualStock' => "actualStock - {$sku_num}", 'assignStock' => "assignStock + {$sku_num}");
         $info = WhGoodsAssignModel::updateSkuLocation($where, $update);
         //更新wh_sku_location的调拨库存和总库存
         if (!$info) {
             TransactionBaseModel::rollback();
             self::$errCode = "010";
             self::$errMsg = "更新总库存失败!";
             return false;
         }
         $where = array('pId' => $skuinfo['id'], 'positionId' => $sku_info['positionId']);
         $update = array('nums' => "nums - {$sku_num}");
         $info = WhGoodsAssignModel::updateProdcutPosition($where, $update);
         //更新wh_product_position_relation的仓位库存
         if (!$info) {
             TransactionBaseModel::rollback();
             self::$errCode = "011";
             self::$errMsg = "更新仓位库存失败!";
             return false;
         }
         /**** 插入出库记录 *****/
         $paraArr = array('sku' => $sku, 'amount' => $sku_num, 'positionId' => $sku_info['positionId'], 'purchaseId' => $skuinfo['purchaseId'], 'ioType' => 1, 'ioTypeId' => 34, 'userId' => $_SESSION['userId'], 'reason' => '调拨出库');
         $record = CommonModel::addIoRecores($paraArr);
         //出库记录
         /** 暂时取消同步老ERP库存**/
         $info = CommonModel::updateIoRecord($sku, $sku_num, 2, '仓库调拨', $_SESSION['userCnName'], $sku_info['pName']);
         //var_dump($info);exit;
         if ($info['errCode'] != 200) {
             TransactionBaseModel::rollback();
             self::$errCode = "012";
             self::$errMsg = "同步旧ERP库存失败!";
             return false;
         }
         TransactionBaseModel::commit();
         self::$errCode = "0";
         self::$errMsg = "配货成功,请扫描下一个料号!";
         $arr['sku'] = $sku;
         $arr['num'] = $sku_info['num'];
         $arr['assignNum'] = $sku_info['assignNum'] + $sku_num;
         return $arr;
     } else {
         self::$errCode = "013";
         self::$errMsg = "更新料号状态失败!";
         return false;
     }
 }
Esempio n. 19
0
 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;
     }
 }
Esempio n. 20
0
        }
        write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
    } else {
        $info = whShelfModel::insertStore($sku, $second_count, 2);
        if (!$info) {
            $errCode = 412;
            $errMsg = "插入B仓总库存失败!";
            $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, $errMsg, $info, $sku, $second_count);
            write_log($log_file, $log_info);
            TransactionBaseModel::rollback();
            continue;
        }
        write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
    }
    //}
    TransactionBaseModel::commit();
}
function updateNewPostion($sku, $location)
{
    global $dbConn;
    $goodsinfos = OmAvailableModel::getTNameList("pc_goods", "sku,id", "where sku='{$sku}'");
    $pId = $goodsinfos[0]['id'];
    //产品id
    if ($location) {
        $sql1 = "select * from `wh_position_distribution` where pName = '{$location}'";
        $query = $dbConn->query($sql1);
        $wh_position_distribution = $dbConn->fetch_array($query);
        if ($wh_position_distribution) {
            $positionId = $wh_position_distribution['id'];
            //$postionId = OmAvailableModel::insertRow2("wh_position_distribution","set pName='$location',x_alixs=0,y_alixs=0,z_alixs=0,floor=0,is_enable=0,type=1,storeId=2");
            if ($positionId) {
Esempio n. 21
0
 public function act_orderWeighingFlat()
 {
     $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : "";
     $mailway = isset($_POST['channelId']) ? $_POST['channelId'] : "";
     //$partionId   = isset($_POST['partionId'])?$_POST['partionId']:"";//不作处理
     $orderweight = isset($_POST['orderweight']) ? $_POST['orderweight'] : "";
     if (!is_numeric($orderid) || empty($orderid)) {
         self::$errCode = 501;
         self::$errMsg = "错误的发货单号!";
         return false;
     }
     $where = "where id={$orderid}";
     $lists = orderWeighingModel::selectRecord($where);
     $calcweight = $lists[0]['calcWeight'] * 1000;
     //估算重量
     $userName = $_SESSION['userCnName'];
     /**重量拦截的逻辑**/
     $vip_users = C('weight_vip');
     //获取具有VIP权限的
     $lists = orderWeighingModel::selectOrderDetail($orderid);
     if (!in_array($userName, $vip_users)) {
         //判断是否具有vip操作权限
         $minRate = 0.8;
         $maxRate = 1.2;
     } else {
         $minRate = 0.5;
         $maxRate = 2;
     }
     if ($calcweight < 50 && $orderweight < 50) {
         if (abs($orderweight - $calcweight) >= 20) {
             self::$errCode = 509;
             self::$errMsg = "该订单重量与实际不符合!系统重量为{$calcweight}称重重量为{$orderweight}";
             return false;
         }
     } else {
         if (($orderweight < $calcweight * $minRate || $orderweight > $calcweight * $maxRate) && $calcweight != 0) {
             self::$errCode = 510;
             self::$errMsg = "该订单重量与实际不符合!系统重量为{$calcweight}称重重量为{$orderweight}";
             return false;
         }
     }
     TransactionBaseModel::begin();
     //更新状态,插入记录
     $userId = $_SESSION['userId'];
     $msg = orderWeighingModel::insertRecord($orderid, $userId);
     if (!$msg) {
         self::$errCode = 511;
         self::$errMsg = "插入称重记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     $msg = orderWeighingModel::updateRecord($orderid, $orderweight, $userId);
     if (!$msg) {
         self::$errCode = 512;
         self::$errMsg = "更新操作记录表失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //更新发货单实际重量和状态
     $orderData = array('orderWeight' => $orderweight, 'orderStatus' => PKS_WDISTRICT);
     $msg = WhShippingOrderModel::update($orderData, $orderid);
     //orderWeighingModel::updateStatus($orderid);
     if (!$msg) {
         self::$errCode = 513;
         self::$errMsg = "更新发货单重量和状态失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //插入运输方式跟踪号申请记录表
     $transportData = array('shipOrderId' => $orderid, 'createTime' => time());
     $msg = WhWaveOrderTransportModel::insert($transportData);
     if (!$msg) {
         self::$errCode = 514;
         self::$errMsg = "插入运输方式跟踪号记录表失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     WhPushModel::pushOrderStatus($orderid, 'PKS_WDISTRICT', $userId, time());
     //状态推送
     TransactionBaseModel::commit();
     return true;
 }
Esempio n. 22
0
 /**
  * whShelfAct::act_whPackageShelf()
  * 包材入库
  * @return void
  */
 public function act_whPackageShelf()
 {
     $userCnName = $_SESSION['userCnName'];
     $sku = trim($_POST['sku']) ? trim($_POST['sku']) : '';
     $nums = intval(trim($_POST['nums']));
     $log_file = 'packageWheself/' . date('Y-m-d') . '.txt';
     $date = date('Y-m-d H:i:s');
     if (!$sku) {
         self::$errCode = 01;
         self::$errMsg = "sku不能为空";
         return false;
     }
     if (!preg_match("/^MT\\d+\$/", $sku)) {
         self::$errCode = 02;
         self::$errMsg = "该模块只能入库包材!";
         return false;
     }
     if (!$nums) {
         self::$errCode = 03;
         self::$errMsg = "数量不能为空";
         return false;
     }
     $where = "where sku='{$sku}' and tallyStatus=0 and entryStatus = 0 and is_delete = 0";
     $tallying_list = packageCheckModel::selectList($where);
     if (empty($tallying_list)) {
         self::$errCode = 04;
         self::$errMsg = "无该料号点货信息";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     } else {
         $tallying_num = 0;
         foreach ($tallying_list as $tallying) {
             $tallying_num += $tallying['ichibanNums'] - $tallying['shelvesNums'];
         }
         if ($nums > $tallying_num) {
             self::$errCode = 05;
             self::$errMsg = "上架数不能大于点货良品数[{$tallying_num}]";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
             write_log($log_file, $log_info);
             return false;
         }
     }
     if ($nums < 1) {
         self::$errCode = 06;
         self::$errMsg = "上架数量不能小于1";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     }
     $where = " where sku = '{$sku}'";
     $skuinfo = whShelfModel::selectSku($where);
     if (empty($skuinfo)) {
         self::$errCode = 07;
         self::$errMsg = "无该料号信息";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s \r\n", $sku, $date, self::$errMsg);
         write_log($log_file, $log_info);
         return false;
     } else {
         $skuId = $skuinfo['id'];
         $purchaseId = $skuinfo['purchaseId'];
     }
     $return_num = $nums;
     $in_positionId = 0;
     $userId = $_SESSION['userId'];
     TransactionBaseModel::begin();
     /**** 更新总库存 *****/
     $actualStock = whShelfModel::selectSkuNums($sku);
     if (!empty($actualStock)) {
         $where = "where sku='{$sku}' and storeId=1";
         $info = whShelfModel::updateStoreNum($nums, $where);
         if (!$info) {
             self::$errCode = 00;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $nums, $where);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     } else {
         $info = whShelfModel::insertStore($sku, $nums, 1);
         if (!$info) {
             self::$errCode = 00;
             self::$errMsg = "更新总库存失败!";
             $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $info, $sku, $nums);
             write_log($log_file, $log_info);
             TransactionBaseModel::rollback();
             return false;
         }
         write_log($log_file, date('Y-m-d H:i:s') . '更新总库存成功!' . "{$sku}\r\n");
     }
     /**** 插入出入库记录 *****/
     $paraArr = array('sku' => $sku, 'amount' => $nums, 'positionId' => $in_positionId, 'purchaseId' => $purchaseId, 'ioType' => 2, 'ioTypeId' => 13, 'userId' => $userId, 'reason' => '上架入库');
     $record = CommonModel::addIoRecores($paraArr);
     //出库记录
     if (!$record) {
         self::$errCode = 010;
         self::$errMsg = "插入出入库记录失败!";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s \r\n", $sku, $date, self::$errMsg, $record, json_encode($paraArr));
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     write_log($log_file, date('Y-m-d H:i:s') . '插入入库记录成功!' . "{$sku}\r\n");
     //更新点货记录状态
     $where = "where sku='{$sku}' and tallyStatus=0 and ichibanNums>0 and is_delete=0";
     $list = packageCheckModel::selectList($where);
     $i = 0;
     while ($list[$i] && $nums) {
         $need_nums = $list[$i]['ichibanNums'] - $list[$i]['shelvesNums'];
         if ($nums >= $need_nums) {
             //更改状态
             $msg = whShelfModel::updateTallyStatus($list[$i]['id'], $need_nums);
             if (!$msg) {
                 self::$errCode = 011;
                 self::$errMsg = "更新点货记录状态失败!";
                 $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $msg, $list[$i]['id'], $need_nums);
                 write_log($log_file, $log_info);
                 TransactionBaseModel::rollback();
                 return false;
             }
             write_log($log_file, date('Y-m-d H:i:s') . '更新点货记录状态成功!' . "{$sku}\r\n");
             $nums = $nums - $need_nums;
         } else {
             $msg = whShelfModel::updateShelfNum($list[$i]['id'], $nums);
             if (!$msg) {
                 self::$errCode = 012;
                 self::$errMsg = "更新点货记录已上架数量失败!";
                 $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg, $msg, $list[$i]['id'], $nums);
                 write_log($log_file, $log_info);
                 TransactionBaseModel::rollback();
                 return false;
             }
             write_log($log_file, date('Y-m-d H:i:s') . '更新点货记录已上架数量成功!' . "{$sku}\r\n");
             $nums = 0;
         }
         $i++;
     }
     $time = time();
     //添加时间戳
     /*$purInfo = CommonModel::endPurchaseOrder($sku,$return_num, $time);             //api获取采购订单处理情况
     		if( !isset($purInfo['errorCode']) || $purInfo['errorCode'] != 0){
     			self::$errCode = 405;
     			self::$errMsg  = "完结采购订单出错,上架失败";
                 $log_info      = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s \r\n", $sku, $date, self::$errMsg,
                                                 json_encode($purInfo), $sku, $return_num);
                 write_log($log_file, $log_info);
     			TransactionBaseModel :: rollback();
     			return false;
     		}
             write_log($log_file, date('Y-m-d H:i:s').'完结采购订单成功'."{$sku}\r\n");*/
     //更新旧erp库存
     $update_onhand = CommonModel::updateOnhand($sku, $return_num, $userCnName, 0, '', $time);
     if ($update_onhand['errCode'] != 200) {
         self::$errCode = 415;
         self::$errMsg = "更新旧erp库存失败";
         $log_info = sprintf("料号:%s, 时间:%s,错误信息:%s,返回值:%s, 参数:%s, %s, %s \r\n", $sku, $date, self::$errMsg, is_array($update_onhand) ? json_encode($update_onhand) : $update_onhand, $sku, $return_num, $userCnName);
         write_log($log_file, $log_info);
         TransactionBaseModel::rollback();
         return false;
     }
     write_log($log_file, date('Y-m-d H:i:s') . '更新旧erp库存成功' . "{$sku}\r\n");
     TransactionBaseModel::commit();
     self::$errMsg = "料号[{$sku}]上架成功!";
     return true;
 }
Esempio n. 23
0
 public function act_packingTracknumber()
 {
     $orderid = isset($_POST['orderid']) ? $_POST['orderid'] : "";
     $tracknumber = isset($_POST['tracknumber']) ? $_POST['tracknumber'] : "";
     $userId = $_SESSION['userId'];
     //先核对订单
     //兼容 EUB或者 包裹 扫描的是 trackno 而非ebayid
     $p_real_ebayid = '#^\\d+$#';
     $p_trackno_eub = '#^(LK|RA|RB|RC|RR|RF|LN)\\d+(CN|HK|DE200)$#';
     $is_eub_package_type = false;
     if (preg_match($p_real_ebayid, $orderid)) {
     } else {
         if (preg_match($p_trackno_eub, $orderid)) {
             $is_eub_package_type = true;
         } else {
             self::$errCode = "001";
             self::$errMsg = "订单号[" . $orderid . "]格式有误";
             return false;
         }
     }
     if ($is_eub_package_type === true) {
         $record = ShippingOrderModel::getShippingOrderInfo("b.*", "where a.tracknumber='{$orderid}' and a.is_delete=0");
     } else {
         $record = ShippingOrderModel::getShippingOrder("*", "where id='{$orderid}'");
     }
     //验证发货单号 以及所属状态
     if (!$record) {
         self::$errCode = 404;
         self::$errMsg = "发货单号不存在!";
         return false;
     }
     if ($record[0]['orderStatus'] != 404) {
         self::$errCode = 405;
         self::$errMsg = "此发货单不在待包装!";
         if ($record[0]['orderStatus'] == 900) {
             self::$errMsg = "此发货单已废弃!";
         }
         return false;
     }
     //挂号的单需要再输入挂号条码
     $carrier = CommonModel::getShipingNameById($record[0]['transportId']);
     $partion = CommonModel::getChannelNameByIds($record[0]['transportId'], $record[0]['countryName']);
     $total_num = 0;
     $skuinfos = get_realskunum($record[0]['id']);
     foreach ($skuinfos as $or_sku => $or_nums) {
         $total_num += $or_nums;
     }
     if (carrier == '中国邮政挂号' && !preg_match("/^(RA|RB|RC|RR)\\d+(CN)\$/", $tracknumber)) {
         self::$errCode = 111;
         self::$errMsg = "录入失败,中国邮政挂号跟踪码不符合规范";
         return false;
     }
     if ($carrier == '香港小包挂号' && !preg_match("/^(RA|RB|RC|RR)\\d+(HK)\$/", $tracknumber)) {
         self::$errCode = 111;
         self::$errMsg = "录入失败,香港小包挂号跟踪码不符合规范";
         return false;
     }
     $p_str = "挂号条码:" . "<font color='#FF0000'>" . $tracknumber . "</font> <br>";
     TransactionBaseModel::begin();
     //更新订单状态
     $msg = OmAvailableModel::updateTNameRow("wh_shipping_order", "set orderStatus=405", "where id={$record[0]['id']}");
     if (!$msg) {
         self::$errCode = 409;
         self::$errMsg = "更新发货单状态记录失败!";
         $arr['partion'] = $partion;
         $arr['carrier'] = $carrier;
         TransactionBaseModel::rollback();
         return json_encode($arr);
         exit;
     }
     //更新操作记录
     $msg = packingScanOrderModel::updateOrderRecord($record[0]['id'], $userId);
     if (!$msg) {
         self::$errCode = 406;
         self::$errMsg = "更新发货单操作记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //插入包装记录
     $msg = packingScanOrderModel::insertPackingRecord($record[0]['id'], $userId);
     if (!$msg) {
         self::$errCode = 407;
         self::$errMsg = "插入包装记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     $msg = packingScanOrderModel::deleteTrackRecord($record[0]['id']);
     if (!$msg) {
         self::$errCode = 409;
         self::$errMsg = "删除跟踪记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     //录入挂号条码
     $msg = packingScanOrderModel::insertTrackRecord($tracknumber, $record[0]['id']);
     if (!$msg) {
         self::$errCode = 408;
         self::$errMsg = "插入包装记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     WhPushModel::pushOrderStatus($record[0]['id'], 'STATESHIPPED_BEWEIGHED', $userId, time(), '', $tracknumber);
     //状态推送
     $arr['partion'] = "<font color='#FF0000'>该订单属于" . $partion . ";含SKU总数:" . $total_num . "个</font><br>";
     $arr['carrier'] = $carrier;
     $arr['res'] = $arr['partion'] . "包装人员:" . "<font color='green'>" . $_SESSION['userCnName'] . "</font><br>" . "运输方式:" . "<font color='#FF0000'>" . $carrier . "</font> <br>" . $p_str . "扫描结果:<font color='#33CC33'>包装扫描成功!</font>";
     TransactionBaseModel::commit();
     return $arr;
 }
Esempio n. 24
0
 public function initDB()
 {
     global $dbConn;
     self::$dbConn = $dbConn;
 }
Esempio n. 25
0
 /**
  * WhGoodsAssignAct::process_sku()
  * 处理停售料号
  * @return
  */
 function process_sku($skus)
 {
     $log_file = 'clearSkuLocation/' . date('Y-m-d') . '.txt';
     $skus = array_filter($skus);
     //处理料号数组
     if (empty($skus)) {
         return FALSE;
     }
     $num_arr = array();
     //库存不为空料号
     $is_sale = array();
     //非停售料号
     $sucess = array();
     //清空成功料号
     $fail = array();
     //清空失败料号
     //print_r($skus);exit;
     foreach ($skus as $sku) {
         $goods_count = CommonModel::getGoodsCount($sku);
         //获取旧ERP库存
         if ($goods_count !== FALSE && $goods_count != 0) {
             //库存非零情况
             $num_arr[$sku] = $goods_count;
             continue;
         }
         $sku_info = packageCheckModel::selectSku($sku);
         //获取料号信息
         if (!in_array($sku_info[0]['goodsStatus'], array(2, 3))) {
             $is_sale[] = $sku;
             continue;
         }
         TransactionBaseModel::begin();
         //清空料号仓位
         $info = whShelfModel::clearSkuLocation($sku_info[0]['id']);
         $date = date('Y-m-d H:i:s');
         if ($info == TRUE) {
             $log_info = sprintf("料号:%s, 时间:%s, 信息:%s \r\n", $sku, $date, '新系统仓位清空成功');
             write_log($log_file, $log_info);
         } else {
             $log_info = sprintf("料号:%s, 时间:%s, 信息:%s \r\n", $sku, $date, '新系统仓位清空失败');
             write_log($log_file, $log_info);
             $fail[] = $sku;
             continue;
         }
         //同步清除老ERP仓位
         $info = CommonModel::clearSkuLocation($sku);
         //接口
         if ($info['errCode'] == 200) {
             $log_info = sprintf("料号:%s, 时间:%s, 信息:%s,返回值:%s \r\n", $sku, $date, '老ERP仓位清空成功', is_array($info) ? json_encode($info) : $info);
             write_log($log_file, $log_info);
             $sucess[] = $sku;
         } else {
             $log_info = sprintf("料号:%s, 时间:%s, 信息:%s,返回值:%s \r\n", $sku, $date, '老ERP仓位清空失败', is_array($info) ? json_encode($info) : $info);
             write_log($log_file, $log_info);
             $fail[] = $sku;
             TransactionBaseModel::rollback();
             continue;
         }
         TransactionBaseModel::commit();
     }
     return array('num_arr' => $num_arr, 'is_sale' => $is_sale, 'sucess' => $sucess, 'fail' => $fail);
 }
Esempio n. 26
0
 /**
  * WhGoodsAssignAct::act_editList()
  * 调拨单修改
  * @return void
  */
 public function act_editList()
 {
     $outStoreId = intval($_POST['outStoreId']);
     $inStoreId = intval($_POST['inStoreId']);
     $createdUid = intval($_POST['createdUid']);
     $sku = $_POST['sku'] ? $_POST['sku'] : array();
     $num = $_POST['num'] ? $_POST['num'] : array();
     $id = intval(trim($_POST['id'])) ? intval(trim($_POST['id'])) : 0;
     //print_r($id);exit;
     if ($outStoreId == $inStoreId) {
         self::$errCode = 401;
         self::$errMsg = '转出仓库和转入仓库不能相同!';
         return $res;
         exit;
     }
     if (!$outStoreId || !$inStoreId || !is_array($sku) || !is_array($num) || count($sku) != count($num) || !$id) {
         self::$errCode = 402;
         self::$errMsg = '数据不完整!';
         return $res;
         exit;
     }
     //$assignNumber          =   self::buildAssignNumber(); //获取调拨单编号
     TransactionBaseModel::begin();
     //删除原来的调拨明细
     $where = array('goodsAssignId' => $id);
     $update = array('is_delete' => 1);
     $info = WhGoodsAssignModel::updateAssignDetail($where, $update);
     if (!$info) {
         self::$errCode = 403;
         self::$errMsg = '调拨明细清除不成功!调拨单修改失败!';
         TransactionBaseModel::rollback();
         return $res;
         exit;
     }
     //更新调拨单信息
     $where = array('id' => $id);
     $update = array('inStoreId' => $inStoreId, 'outStoreId' => $outStoreId);
     $info = WhGoodsAssignModel::updateAssignListStatus($where, $update);
     $listDetails = self::buildDetails($sku, $num, $outStoreId, $id);
     //拼接调拨单明数据
     if ($listDetails === FALSE) {
         self::$errCode = 404;
         self::$errMsg = '参数不正确,生成调拨明细失败!';
         TransactionBaseModel::rollback();
         return $res;
         exit;
     }
     $info = WhGoodsAssignModel::addAssignListDetail($listDetails);
     if ($info == FALSE) {
         self::$errCode = 405;
         self::$errMsg = '生成调拨明细表失败!';
         TransactionBaseModel::rollback();
         return $res;
         exit;
     }
     TransactionBaseModel::commit();
     self::$errCode = 200;
     self::$errMsg = '修改成功!';
     return $res;
 }
Esempio n. 27
0
 public function act_orderPartionPack()
 {
     $partion = isset($_POST['partion']) ? trim($_POST['partion']) : "";
     $packageId = isset($_POST['packageid']) ? trim($_POST['packageid']) : "";
     $userId = $_SESSION['userId'];
     $msg = orderPartionModel::selectPartionPack($packageId);
     if ($msg[0]['partion'] != $partion) {
         self::$errCode = 608;
         self::$errMsg = "选择的分区与扫描口袋的分区不匹配!";
         return false;
     }
     TransactionBaseModel::begin();
     $where = " where partion='{$partion}' and scanUserId={$userId} and packageid is null";
     $data = orderPartionModel::selectData($where);
     if ($data[0]['totalNum'] == 0) {
         self::$errCode = 611;
         self::$errMsg = "已打包!";
         return false;
     }
     $result1 = orderPartionModel::updatePartionRecord($partion, $userId, $packageId);
     if (!$result1) {
         self::$errCode = 609;
         self::$errMsg = "更新分区记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     $result2 = orderPartionModel::updatePartionPack($packageId, $data[0]['totalNum'], $data[0]['totalWeight'], $userId);
     if (!$result1) {
         self::$errCode = 610;
         self::$errMsg = "更新口袋记录失败!";
         TransactionBaseModel::rollback();
         return false;
     }
     TransactionBaseModel::commit();
     return true;
 }
Esempio n. 28
0
 function act_allPass()
 {
     $userCnName = $_SESSION['userCnName'];
     $id_arr = $_POST['id'];
     $f_count = count($id_arr);
     $id = implode(',', $id_arr);
     $where = "where id in(" . $id . ") and auditStatus=0";
     $record_list = InvRecordModel::getInvRecordList("*", $where);
     $s_count = count($record_list);
     if ($f_count != $s_count) {
         self::$errCode = "401";
         self::$errMsg = "当前包含有不用审核的订单,请确认!";
         return false;
     }
     OmAvailableModel::begin();
     foreach ($record_list as $record) {
         $data = array();
         $id = $record['id'];
         $data = array('auditStatus' => 1);
         $Inv_info = InvRecordModel::getInvRecordList("*", "where id='{$id}'");
         $position_info = OmAvailableModel::getTNameList("wh_position_distribution", "id", "where pName='{$Inv_info[0]['location']}'");
         $skuinfo = whShelfModel::selectSku(" where sku='{$Inv_info[0]['sku']}'");
         $updatedata = InvRecordModel::update($data, "and id='{$id}'");
         if (!$updatedata) {
             self::$errCode = "402";
             self::$errMsg = "更新通过状态失败!";
             return false;
         }
         $tName = 'wh_product_position_relation';
         $set = "SET nums='{$Inv_info[0]['invNums']}'";
         $where = "WHERE pId='{$skuinfo['id']}' AND positionId='{$position_info[0]['id']}' AND is_delete=0 AND storeId=1";
         $affectRow = OmAvailableModel::updateTNameRow($tName, $set, $where);
         //库存变化
         if ($affectRow === false) {
             self::$errCode = "403";
             self::$errMsg = "更新具体仓位库存失败!";
             OmAvailableModel::rollback();
             return false;
         }
         $adjustNums = $Inv_info[0]['adjustNums'];
         if ($Inv_info[0]['invType'] == 2) {
             $adjustNums = "-" . $adjustNums;
         }
         $tName = 'wh_sku_location';
         $set = "SET actualStock=actualStock+'{$adjustNums}'";
         $where = "WHERE sku='{$Inv_info[0]['sku']}' AND storeId=1";
         $affectRow = WhIoRecordsModel::updateTNameRow($tName, $set, $where);
         //库存变化
         if ($affectRow === false) {
             self::$errCode = "404";
             self::$errMsg = "更新总库存失败!";
             OmAvailableModel::rollback();
             return false;
         }
         /**** 插入出入库记录 *****/
         if ($Inv_info[0]['invType'] == 2) {
             $ioType = 1;
             $ioTypeId = 11;
             $reason = '盘点出库';
         } else {
             $ioType = 2;
             $ioTypeId = 10;
             $reason = '盘点入库';
         }
         if ($adjustNums != 0) {
             $update_onhand = CommonModel::adjustInventory($Inv_info[0]['sku'], $adjustNums, $userCnName);
             if ($update_onhand == 0) {
                 self::$errCode = 415;
                 self::$errMsg = "更新旧erp库存失败";
                 OmAvailableModel::rollback();
                 return false;
             }
             $skuinfo = whShelfModel::selectSku(" where sku = '{$Inv_info[0]['sku']}'");
             $paraArr = array('sku' => $Inv_info[0]['sku'], 'amount' => abs($adjustNums), 'positionId' => $position_info[0]['id'], 'purchaseId' => $skuinfo['purchaseId'], 'ioType' => $ioType, 'ioTypeId' => $ioTypeId, 'userId' => $_SESSION['userId'], 'reason' => $reason);
             $record = CommonModel::addIoRecores($paraArr);
             //出库记录
             if (!$record) {
                 OmAvailableModel::rollback();
                 return false;
             }
         }
         //更新申请盘点表
         $waitInf = WaitInventoryModel::updateInv($Inv_info[0]['sku'], $_SESSION['userId']);
         if (!$waitInf) {
             self::$errCode = 414;
             self::$errMsg = "跟新申请盘点表失败!";
             TransactionBaseModel::rollback();
             return false;
         }
     }
     OmAvailableModel::commit();
     return true;
 }
Esempio n. 29
0
 function act_checkSkuNum()
 {
     $orderId = intval(trim($_POST['orderId']));
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     $sku_num = intval(trim($_POST['sku_num']));
     $log_file = 'pda_orderOutB/' . date('Y-m-d') . '.txt';
     $date = date('Y-m-d-H');
     if (!$orderId) {
         self::$errCode = "001";
         self::$errMsg = "请扫描订单id!";
         return FALSE;
     }
     if (!$sku) {
         self::$errCode = "002";
         self::$errMsg = "请扫描料号!";
         return FALSE;
     }
     if (!$sku_num) {
         self::$errCode = "003";
         self::$errMsg = "请输入料号配货数!";
         return FALSE;
     }
     $skuinfo = whShelfModel::selectSku(" where sku = '{$sku}'");
     //获取sku信息
     $where = array('orderId' => $orderId, 'sku' => $sku);
     $sku_info = Pda_orderOutBModel::selectOrderRecord($where);
     //获取订单下该料号的信息
     if (empty($sku_info)) {
         self::$errCode = "004";
         self::$errMsg = "该订单没有此料号!";
         return FALSE;
     }
     $sku_info = $sku_info[0];
     $sku_onhand = GroupDistributionModel::getSkuPositionStock("and c.sku='{$sku}' and a.storeId = 2");
     //查看该料号的B仓库存
     $now_num = $sku_num + $sku_info['scanNum'];
     //已配货数加上本次配货数
     if (!is_numeric($sku_num) || $now_num <= 0) {
         self::$errCode = "005";
         self::$errMsg = "配货数量必须大于0,请确认!";
         return FALSE;
     }
     if ($sku_info['amount'] < $now_num) {
         self::$errCode = "006";
         self::$errMsg = "配货数量不能大于订单数!";
         return false;
     }
     if ($sku_num > $sku_onhand[0]['nums']) {
         self::$errCode = "007";
         self::$errMsg = "配货数不能大于系统库存,请确认!";
         return false;
     }
     $uid = $_SESSION['userId'];
     $scanTime = time();
     $where = array('orderId' => $orderId, 'sku' => $sku);
     //拼接where条件
     $update = array('scanUser' => $uid, 'scanTime' => $scanTime, 'scanNum' => $now_num);
     //拼接更新字段
     TransactionBaseModel::begin();
     $info = Pda_orderOutBModel::updateOrderRecord($where, $update);
     if ($info) {
         $where = array('sku' => $sku, 'storeId' => 2);
         $update = array('actualStock' => "actualStock - {$sku_num}");
         $info = WhGoodsAssignModel::updateSkuLocation($where, $update);
         //更新wh_sku_location的调拨库存和总库存
         if (!$info) {
             TransactionBaseModel::rollback();
             self::$errCode = "010";
             self::$errMsg = "更新总库存失败!";
             return false;
         }
         $positionInfo = whShelfModel::selectPositionInfo('id', array('pName' => $sku_info['pName']));
         //仓位信息
         $where = array('pId' => $skuinfo['id'], 'positionId' => $positionInfo['id'], 'storeId' => 2);
         $update = array('nums' => "nums - {$sku_num}");
         $info = WhGoodsAssignModel::updateProdcutPosition($where, $update);
         //更新wh_product_position_relation的仓位库存
         if (!$info) {
             TransactionBaseModel::rollback();
             self::$errCode = "011";
             self::$errMsg = "更新仓位库存失败!";
             return false;
         }
         /**** 插入出库记录 *****/
         $paraArr = array('sku' => $sku, 'amount' => $sku_num, 'positionId' => $positionInfo['id'], 'purchaseId' => $skuinfo['purchaseId'], 'ioType' => 1, 'ioTypeId' => 6, 'userId' => $_SESSION['userId'], 'reason' => 'B仓订单配货出库', 'ordersn' => $orderId);
         $record = CommonModel::addIoRecores($paraArr);
         //出库记录
         /** 同步老ERP订单配货记录**/
         $is_scan = $sku_info['amount'] == $now_num ? 1 : 0;
         $info = CommonModel::updateOrderScanRecord($orderId, $sku, $sku_num, $sku_info['amount'], $is_scan, $_SESSION['userCnName']);
         if ($info['errCode'] != 200) {
             TransactionBaseModel::rollback();
             self::$errCode = "012";
             self::$errMsg = "更新ERP配货记录失败!";
             $log_info = sprintf("订单号:%s, 时间:%s, 提示信息:%s, 信息记录: %s \r\n", $orderId, $date, self::$errMsg, is_array($info) ? json_encode($info) : $info);
             write_log($log_file, $log_info);
             return false;
         }
         TransactionBaseModel::commit();
         $where = array('orderId' => $orderId, 'scanUser' => 0);
         $info = Pda_orderOutBModel::selectOrderRecord($where);
         //查看该订单下是否还有未配货料号
         if (empty($info)) {
             self::$errCode = "200";
             self::$errMsg = "该订单已配货完成, 请扫描下一订单号!";
             return TRUE;
         } else {
             self::$errCode = "0";
             self::$errMsg = "配货成功,请扫描下一个料号!";
             $arr['sku'] = $sku;
             $arr['num'] = $sku_info['amount'];
             $arr['assignNum'] = $now_num;
             return $arr;
         }
     } else {
         self::$errCode = "013";
         self::$errMsg = "更新料号状态失败!";
         return false;
     }
 }