Exemplo n.º 1
0
 public static function updateInv($sku, $invPeopleId, $storeId = 1)
 {
     self::initDB();
     $time = time();
     $sql = "select actualStock from wh_sku_location where sku='{$sku}' and storeId={$storeId} ";
     $sku_location = self::$dbConn->fetch_first($sql);
     if (empty($sku_location)) {
         $invNums = 0;
     } else {
         $invNums = $sku_location['actualStock'];
     }
     $update_sql = "update wh_waitforInventory_list set invStatus=1,invNums={$invNums},invPeopleId={$invPeopleId},invTime={$time} \n\t\t\t\t\t\t  where sku='{$sku}' and invStatus=0 and storeId={$storeId}";
     $query = self::$dbConn->query($update_sql);
     if ($query) {
         return true;
     } else {
         self::$errCode = "003";
         self::$errMsg = "error";
         return false;
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public function act_markUnusual1()
 {
     $userId = $_SESSION['userId'];
     $orderids = isset($_POST['orderids']) ? $_POST['orderids'] : '';
     if (empty($orderids)) {
         self::$errCode = 0;
         self::$errMsg = '请选择发货单号!';
         return;
     }
     if (!is_numeric($orderids)) {
         $tracknumber = $orderids;
         $info = orderWeighingModel::selectOrderId($tracknumber);
         if (!$info) {
             self::$errCode = 501;
             self::$errMsg = "此跟踪号不存在!";
             return false;
         }
         $orderids = $info[0]['shipOrderId'];
     }
     $order_arr = explode(',', $orderids);
     OmAvailableModel::begin();
     $po_obj = new PackingOrderModel();
     $qresult = $po_obj->changeStatusToUnusual($orderids);
     if ($qresult) {
         foreach ($order_arr as $order) {
             $order_info = orderWeighingModel::selectOrderDetail($order);
             foreach ($order_info as $o_info) {
                 $data = array();
                 $sku_info = InvRecordModel::getSkuInfo($o_info['sku']);
                 $data = array('sku' => $o_info['sku'], 'applicantId' => $userId, 'applicantionTime' => time(), 'invReasonId' => 4, 'invStatus' => 0, 'systemNums' => $sku_info['actualStock']);
                 $insertid = WaitInventoryModel::insertRow($data);
                 if (!$insertid) {
                     self::$errCode = 0;
                     self::$errMsg = '标记异常发货单失败!';
                     OmAvailableModel::rollback();
                     return false;
                 }
             }
         }
         self::$errCode = 200;
         self::$errMsg = '标记异常发货单成功!';
         OmAvailableModel::commit();
         return true;
     } else {
         self::$errCode = 0;
         self::$errMsg = '标记异常发货单失败!';
         return false;
     }
 }