Example #1
0
 public function initDB()
 {
     global $dbConn;
     self::$dbConn = $dbConn;
     //mysql_query('SET NAMES UTF8');
 }
 function act_checkSkuNum()
 {
     $orderId = intval(trim($_POST['orderId']));
     $sku = trim($_POST['sku']);
     $sku = get_goodsSn($sku);
     //转义sku
     $sku_num = intval(trim($_POST['sku_num']));
     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;
     }
     $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];
     $now_num = $sku_num + $sku_info['checkNum'];
     //已接收数加上本次接收数
     if (!is_numeric($sku_num) || $now_num <= 0) {
         self::$errCode = "005";
         self::$errMsg = "接收总数必须大于0,请确认!";
         return FALSE;
     }
     if ($sku_info['scanNum'] < $now_num) {
         self::$errCode = "006";
         self::$errMsg = "接收数不能大于订单配货数!";
         return false;
     }
     $uid = $_SESSION['userId'];
     $scanTime = time();
     $where = array('orderId' => $orderId, 'sku' => $sku);
     //拼接where条件
     $update = array('checkUser' => $uid, 'checkTime' => $scanTime, 'checkNum' => $now_num);
     //拼接更新字段
     $info = Pda_orderOutBModel::updateOrderRecord($where, $update);
     if ($info == FALSE) {
         self::$errCode = "007";
         self::$errMsg = "更新料号状态失败!";
         return FALSE;
     }
     $where = array('orderId' => $orderId, 'checkUser' => 0);
     $info = Pda_orderOutBModel::selectOrderRecord($where);
     //查看该订单下是否还有未接受料号
     if (empty($info)) {
         self::$errCode = "200";
         self::$errMsg = "该订单接收完成,请扫描下一订单号!";
         return TRUE;
     }
     self::$errCode = "0";
     self::$errMsg = "接收成功,请扫描下一个料号!";
     $arr['sku'] = $sku;
     $arr['num'] = $sku_info['scanNum'];
     $arr['assignNum'] = $now_num;
     return $arr;
 }
Example #3
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;
     }
 }