예제 #1
0
 public function addBoxToaOrder($boxId, $orderid, $opuser)
 {
     $time = time();
     $box_obj = new BoxManageModel();
     $inBox_obj = new OwInBoxStockModel();
     $skuDetail = $box_obj->getBoxSkuDetail($boxId);
     $this->dbConn->begin();
     foreach ($skuDetail as $skuInfo) {
         $tmp = $skuInfo['num'];
         $inboxInfo = $inBox_obj->getInbocStockInfo($skuInfo['sku']);
         if (FALSE === $inboxInfo) {
             //该料号没有封箱库存信息
             $this->dbConn->rollback();
             self::$errMsg = $skuInfo['sku'] . "没有封箱库存信息!";
             return FALSE;
         }
         if ($inboxInfo['num'] < $skuInfo['num']) {
             //如果封箱库存小于箱子中的库存数量 则会导致封箱库存不够扣
             $this->dbConn->rollback();
             self::$errMsg = $skuInfo['sku'] . "封箱库存小于发货数量!";
             return FALSE;
         }
         $upsql = "update wh_inboxStock set num=num-{$tmp} where sku='{$skuInfo['sku']}'";
         //扣除封箱库存
         $upquery = $this->dbConn->query($upsql);
         if (FALSE === $upquery) {
             $this->dbConn->rollback();
             self::$errMsg = $skuInfo['sku'] . "扣除封箱库存失败!";
             return FALSE;
         }
     }
     $sql = "\n                update wh_boxinuse set replenshId='{$orderid}', sendScanTime='{$time}', \n                sendScanUser='******', status='3' where boxid='{$boxId}'\n        ";
     $query = $this->dbConn->query($sql);
     if (FALSE === $query) {
         //更新状态失败
         $this->dbConn->rollback();
         self::$errMsg = '更新箱子状态失败!';
         return FALSE;
     }
     $logSql = "\n                insert into wh_boxOpLog (boxId, opcode, opuser, optime) values ('{$boxId}', 'send', '{$opuser}', '{$time}');\n                ";
     $logquery = $this->dbConn->query($logSql);
     if (FALSE === $logquery) {
         //记录日志出错
         $this->dbConn->rollback();
         self::$errMsg = '记录日志出错!';
         return FALSE;
     }
     $upd = "UPDATE wh_boxDetail SET stu = '2' WHERE boxId = '{$boxId}' AND is_delete = 0";
     $rtnUpd = $this->dbConn->query($upd);
     if ($rtnUpd === FALSE) {
         $this->dbConn->rollback();
         self::$errMsg = '更新装箱料号状态出错';
         return FALSE;
     }
     $this->dbConn->commit();
     return TRUE;
 }