Ejemplo n.º 1
0
 public function view_scanSubmit()
 {
     $returnData = array('code' => 0, 'msg' => '');
     if (empty($_SESSION['userId'])) {
         //未登陆
         $returnData['msg'] = '登陆超时 请重新登陆!';
         echo json_encode($returnData);
         exit;
     }
     $orderSn = isset($_GET['orderSn']) ? trim($_GET['orderSn']) : NULL;
     //备货单号
     $sku = isset($_GET['sku']) ? trim($_GET['sku']) : NULL;
     //sku
     $num = isset($_GET['sku']) ? intval($_GET['num']) : NULL;
     //数量
     if (empty($orderSn) || empty($sku) || empty($num)) {
         $returnData['msg'] = '参数不完整!';
         echo json_encode($returnData);
         exit;
     }
     $sku = get_goodsSn($sku);
     $preGoods_Obj = new PreGoodsOrdderManageModel();
     $orderInfo = $preGoods_Obj->getOrderInfo($orderSn);
     if (FALSE === $orderInfo) {
         $returnData['code'] = '备货单不存在!';
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
     if ($orderInfo['status'] != 2) {
         $returnData['msg'] = '该备货待不是待拣货配货单!';
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
     $skuInfo = $preGoods_Obj->getSKUinfo($orderInfo['id'], $sku);
     if (FALSE === $skuInfo) {
         $returnData['msg'] = 'sku不存在!';
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
     if ($skuInfo['amount'] == $skuInfo['scantnum']) {
         //如果订单数量和扫描数量一致 则表示该料号已经扫描完成
         $returnData['msg'] = 'sku配货完毕 ,无需再配!';
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
     $waiteScan = $skuInfo['amount'] - $skuInfo['scantnum'];
     //待配货数量
     if ($num > $waiteScan) {
         //扫描数量和待配货数量不一致 则不予通过
         $returnData['msg'] = '配货数量大于应配货数量!';
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
     $isend = FALSE;
     $outStock_obj = new OwPreGoodsOutStockModel();
     $result = $outStock_obj->outStock($sku, $num, $_SESSION['userId'], $orderInfo['id'], $isend, $waiteScan, $orderSn);
     if (FALSE === $result) {
         $returnData['msg'] = OwPreGoodsOutStockModel::$errmsg;
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     } else {
         $returnData['msg'] = '更新成功!';
         $returnData['code'] = $isend ? 2 : 1;
         $returnData['sku'] = $sku;
         echo json_encode($returnData);
         exit;
     }
 }
Ejemplo n.º 2
0
 public function outStock($sku, $num, $opuser, $orderid, &$isEnd, $waitScan, $orderSn)
 {
     $isLastOne = true;
     //是否为最后一个待配货sku
     $preGoods_Obj = new PreGoodsOrdderManageModel();
     $allSkuInfo = $preGoods_Obj->getSKUDetail($orderid);
     //订单的全部sku列表
     foreach ($allSkuInfo as $row) {
         //判断该料号配完以后是否可以终结该备货单
         if ($row['amount'] != $row['scantnum'] && $row['sku'] != $sku) {
             $isLastOne = FALSE;
         }
     }
     if ($waitScan != $num) {
         $isLastOne = FALSE;
     }
     $isEnd = $isLastOne;
     //$this->logRequest(" sku==> $sku 数量==> $num");                           //记录请求日志
     $paramArr['method'] = 'ow_pregood_changestock';
     //API名称
     $paramArr['sku'] = $sku;
     $paramArr['num'] = $num;
     $paramArr['orderSn'] = $orderSn;
     $paramArr['operUser'] = getUserNameById($opuser);
     $messageInfo = UserCacheModel::callOpenSystem2($paramArr);
     //先到老系统扣库存
     if (FALSE === $messageInfo) {
         //请求开发系统出错
         self::$errmsg = '请求开放系统出错!';
         return FALSE;
     }
     $code = isset($messageInfo['code']) ? trim($messageInfo['code']) : '';
     if ($code !== 'success') {
         //扣库存失败
         self::$errmsg = $messageInfo['msg'];
         return FALSE;
     }
     $sku = mysql_real_escape_string($sku);
     $this->dbConn->begin();
     $rcordInfo = $this->getSkuInboxRecords($sku);
     if (FALSE === $rcordInfo) {
         //还没有封箱库存记录 则新增一条记录
         $insertResult = $this->insertNewInboxRecords($sku, $num);
         if (FALSE === $insertResult) {
             //插入失败 回滚
             $this->dbConn->rollback();
             self::$errmsg = "新增封箱库存记录失败!";
             return FALSE;
         }
     } else {
         //追加库存
         $updateSql = "update wh_inboxStock set num=num+{$num} where sku='{$sku}'";
         $updateQuery = $this->dbConn->query($updateSql);
         if (FALSE === $updateQuery) {
             //更新封箱库存失败 回滚
             $this->dbConn->rollback();
             self::$errmsg = "更新封箱库存失败!";
             return FALSE;
         }
     }
     $time = time();
     $updateOrder = "\n                update wh_prepDetail set scantnum=scantnum+{$num}, scantime={$time}, scanuser='******' where \n                sku='{$sku}' and orderid='{$orderid}'\n            ";
     $upOrderQuery = $this->dbConn->query($updateOrder);
     //更新备货单的扫描数量
     if (FALSE === $upOrderQuery) {
         $this->dbConn->rollback();
         self::$errmsg = '更新备货单数据失败!';
         return FALSE;
     }
     if (TRUE === $isLastOne) {
         //配货完成 修改备货单状态
         $upStatusSql = "update wh_prepGoodsOrder set status=3 where id='{$orderid}'";
         $upStatusQuery = $this->dbConn->query($upStatusSql);
         if (FALSE === $upStatusQuery) {
             $this->dbConn->rollback();
             self::$errmsg = '更新备货单状态失败!';
             return FALSE;
         }
     }
     $originNum = isset($rcordInfo['num']) ? $rcordInfo['num'] : 0;
     $logSql = "insert into wh_skuscanLog (orderId, sku, scanNum, originNum, opuser, scanTime) values\n                    ({$orderid}, '{$sku}', '{$num}', '{$originNum}', '{$opuser}', '{$time}')\n                ";
     $logResult = $this->dbConn->query($logSql);
     //记录操作日志
     if (FALSE === $logResult) {
         //写日志失败 回滚
         $this->dbConn->rollback();
         self::$errmsg = '写入操作日志失败!';
         return FALSE;
     }
     $this->dbConn->commit();
     return TRUE;
 }