Example #1
0
 function act_getActualStockBySS()
 {
     $sku = isset($_GET['sku']) ? $_GET['sku'] : '';
     //sku
     $storeId = isset($_GET['storeId']) ? $_GET['storeId'] : 1;
     //订单记录id
     if (empty($sku)) {
         self::$errCode = 1;
         self::$errMsg = 'empty sku';
         return 0;
     }
     $tName = 'wh_sku_location';
     $select = 'actualStock';
     $where = "WHERE sku='{$sku}' AND storeId='{$storeId}'";
     $whActualStockList = SkuStockModel::getTNameList($tName, $select, $where);
     if (empty($whShipOrderIdList)) {
         //未找到originOrderId对应的shipOrderId
         self::$errCode = 2;
         self::$errMsg = 'empty whActualStockList';
         return 0;
     }
     $actualStock = $whShipOrderIdList[0]['actualStock'];
     self::$errCode = 200;
     self::$errMsg = 'success';
     return $actualStock;
 }
Example #2
0
 function view_updateBatchPosition()
 {
     $uploadfile = date("Y") . date("m") . date("d") . rand(1, 3009) . ".xls";
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (move_uploaded_file($_FILES['upfile']['tmp_name'], 'upload/' . $uploadfile)) {
             $status = "<font color='green'>文件上传成功!</font><br />";
             $fileName = 'upload/' . $uploadfile;
             $filePath = $fileName;
             require_once "../lib/PHPExcel.php";
             $PHPExcel = new PHPExcel();
             $PHPReader = new PHPExcel_Reader_Excel2007();
             if (!$PHPReader->canRead($filePath)) {
                 $PHPReader = new PHPExcel_Reader_Excel5();
                 if (!$PHPReader->canRead($filePath)) {
                     echo 'no Excel';
                     return;
                 }
             }
             $PHPExcel = $PHPReader->load($filePath);
             $currentSheet = $PHPExcel->getSheet(0);
             /**取得一共有多少行*/
             $allRow = $currentSheet->getHighestRow();
             $skuStockAct = new SkuStockAct();
             /**从第二行开始输出,因为excel表中第一行为列名*/
             for ($c = 2; $c <= $allRow; $c++) {
                 $aa = 'A' . $c;
                 //sku
                 $bb = 'B' . $c;
                 //所在仓库
                 $cc = 'C' . $c;
                 //旧仓位
                 $dd = 'D' . $c;
                 //新仓位
                 $sku = trim($currentSheet->getCell($aa)->getValue());
                 $whName = trim($currentSheet->getCell($bb)->getValue());
                 $oldPosition = trim($currentSheet->getCell($cc)->getValue());
                 $newPosition = trim($currentSheet->getCell($dd)->getValue());
                 if (empty($sku) || empty($whName) || empty($oldPosition) || empty($newPosition)) {
                     echo "<font color='red'>第 {$c} 行 存在空列,该行更新失败</font><br />";
                     continue;
                 }
                 $sku = str_pad(trim($sku), 3, '0', STR_PAD_LEFT);
                 $tName = 'pc_goods';
                 $select = 'id';
                 $where = "WHERE sku='{$sku}'";
                 $skuList = $skuStockAct->act_getTNameList($tName, $select, $where);
                 if (empty($skuList)) {
                     echo "<font color='red'>第 {$c} 行 sku {$sku} 不存在,该行更新失败</font><br />";
                     continue;
                 }
                 $skuId = $skuList[0]['id'];
                 //wh_product_position_relation中的pid
                 $tName = 'wh_store';
                 $select = 'id';
                 $where = "WHERE whName='{$whName}'";
                 $whStoreList = $skuStockAct->act_getTNameList($tName, $select, $where);
                 if (empty($whStoreList)) {
                     echo "<font color='red'>第 {$c} 行 仓库 {$whName} 不存在,该行更新失败</font><br />";
                     continue;
                 }
                 $whStoreId = $whStoreList[0]['id'];
                 $tName = 'wh_position_distribution';
                 $select = 'id';
                 $where = "WHERE pName='{$oldPosition}'";
                 $positionList = $skuStockAct->act_getTNameList($tName, $select, $where);
                 if (empty($positionList)) {
                     echo "<font color='red'>第 {$c} 行 旧仓位号 {$oldPosition} 不存在,该行更新失败</font><br />";
                     continue;
                 }
                 $oldPositionId = $positionList[0]['id'];
                 $tName = 'wh_position_distribution';
                 $select = 'id';
                 $where = "WHERE pName='{$newPosition}'";
                 $positionList = $skuStockAct->act_getTNameList($tName, $select, $where);
                 if (empty($positionList)) {
                     echo "<font color='red'>第 {$c} 行 新仓位号 {$newPosition} 不存在,该行更新失败</font><br />";
                     continue;
                 }
                 $newPositionId = $positionList[0]['id'];
                 $tName = 'wh_product_position_relation';
                 $where = "WHERE is_delete=0 AND storeId='{$whStoreId}' AND positionId='{$newPositionId}'";
                 $count = $skuStockAct->act_getTNameCount($tName, $where);
                 if ($count > 0) {
                     echo "<font color='red'>第 {$c} 行 新仓位 {$newPosition} 已经被占用,更新失败!</font><br/>";
                     continue;
                 }
                 $tName = 'wh_product_position_relation';
                 $set = "SET positionId='{$newPositionId}'";
                 $where = "WHERE pid='{$skuId}' AND positionId='{$oldPositionId}' AND storeId='{$whStoreId}'";
                 $affectRows = $skuStockAct->act_updateTNameRow($tName, $set, $where);
                 if (!$affectRows) {
                     echo "<font color='orange'>第 {$c} 行 无数据修改,更新失败!</font><br/>";
                     continue;
                 } else {
                     echo "<font color='green'>第 {$c} 行 ,sku:{$sku} 更新成功!旧仓位为:{$oldPosition} ,新仓位为:{$newPosition}</font><br/>";
                 }
             }
             /*============================================  end  =============================================================*/
             unlink($filePath);
             //删除导入文件
         }
         echo "<font color='red'> 文件上传失败!</font><br />";
     } else {
         echo "<font color='red'> 文件上传失败!</font><br />";
     }
 }