diff --git a/app/common/service/xlsx/Beforehand.php b/app/common/service/xlsx/Beforehand.php index e21951e6f..894eac0e7 100644 --- a/app/common/service/xlsx/Beforehand.php +++ b/app/common/service/xlsx/Beforehand.php @@ -8,6 +8,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; + class Beforehand { public function export($data, $system_store) @@ -183,8 +185,15 @@ class Beforehand // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); - $url = '/export/' . date('Y-m') . '/' . $order['info'].'出库单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir. '/' . $order['info'].'出库单-'.date('Y-m-d H:i') . '.xlsx'; + $url = '/export/'.date('Y-m'). '/' . $order['info'].'出库单-'.date('Y-m-d H:i') . '.xlsx'; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderAllocation.php b/app/common/service/xlsx/OrderAllocation.php index 83ac3ace0..c50ab8dd0 100644 --- a/app/common/service/xlsx/OrderAllocation.php +++ b/app/common/service/xlsx/OrderAllocation.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单分配 @@ -161,8 +162,15 @@ class OrderAllocation // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); - $url = '/export/' . date('Y-m') . '/' .'订单分配-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir. '/' .'订单分配-'.date('Y-m-d H:i') . '.xlsx'; + $url = '/export/'.date('Y-m'). '/' .'订单分配-'.date('Y-m-d H:i') . '.xlsx'; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index d210cad63..e9208edc4 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; class OrderDetail { @@ -148,8 +149,15 @@ class OrderDetail // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); - $url = '/export/' . date('Y-m') . '/' . $system_store.'出库单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' . $system_store.'出库单-'.date('Y-m-d H:i') . '.xlsx'; + $url = '/export/'.date('Y-m') . '/' . $system_store.'出库单-'.date('Y-m-d H:i') . '.xlsx'; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderInfo.php b/app/common/service/xlsx/OrderInfo.php index e7bbae9c0..aba991db4 100644 --- a/app/common/service/xlsx/OrderInfo.php +++ b/app/common/service/xlsx/OrderInfo.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 采购信息 @@ -124,8 +125,15 @@ class OrderInfo // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); - $url = '/export/' . date('Y-m') . '/' .'采购信息-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .'采购信息-'.date('Y-m-d H:i') . '.xlsx'; + $url = '/export/'.date('Y-m') . '/' .'采购信息-'.date('Y-m-d H:i') . '.xlsx'; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderList.php b/app/common/service/xlsx/OrderList.php index 61fa1abb9..a58af6184 100644 --- a/app/common/service/xlsx/OrderList.php +++ b/app/common/service/xlsx/OrderList.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单清单 @@ -159,8 +160,15 @@ class OrderList // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir. '/' .'供投里海农特产品下单清单-'.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .'供投里海农特产品下单清单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderOutbound.php b/app/common/service/xlsx/OrderOutbound.php index 52cf93c8f..49281bdbf 100644 --- a/app/common/service/xlsx/OrderOutbound.php +++ b/app/common/service/xlsx/OrderOutbound.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单出库 @@ -141,8 +142,15 @@ class OrderOutbound // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderOutboundFinance.php b/app/common/service/xlsx/OrderOutboundFinance.php index 862c44abf..52af0a4be 100644 --- a/app/common/service/xlsx/OrderOutboundFinance.php +++ b/app/common/service/xlsx/OrderOutboundFinance.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 财务订单出库 @@ -143,8 +144,15 @@ class OrderOutboundFinance // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/OrderSupplyOutbound.php b/app/common/service/xlsx/OrderSupplyOutbound.php index fbd6fa44d..905b71a3f 100644 --- a/app/common/service/xlsx/OrderSupplyOutbound.php +++ b/app/common/service/xlsx/OrderSupplyOutbound.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单出库 @@ -149,8 +150,15 @@ class OrderSupplyOutbound // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .$title2.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/ReturnSupplier.php b/app/common/service/xlsx/ReturnSupplier.php index 076724d26..6371aee6d 100644 --- a/app/common/service/xlsx/ReturnSupplier.php +++ b/app/common/service/xlsx/ReturnSupplier.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单退供应商 @@ -111,8 +112,15 @@ class ReturnSupplier // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .'供投里海农特产品退供应商结算单-'.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .'供投里海农特产品退供应商结算单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/StockReturn.php b/app/common/service/xlsx/StockReturn.php index 178b63c3d..e8ca2030b 100644 --- a/app/common/service/xlsx/StockReturn.php +++ b/app/common/service/xlsx/StockReturn.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; /** * 订单退库 @@ -127,8 +128,15 @@ class StockReturn // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .'供投里海农特产品退库结算单-'.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .'供投里海农特产品退库结算单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url; diff --git a/app/common/service/xlsx/WarehouseOrdeRentry.php b/app/common/service/xlsx/WarehouseOrdeRentry.php index 93c84ca36..d2b7c8703 100644 --- a/app/common/service/xlsx/WarehouseOrdeRentry.php +++ b/app/common/service/xlsx/WarehouseOrdeRentry.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Border; +use Webman\Exception\BusinessException; class WarehouseOrdeRentry { @@ -120,8 +121,15 @@ class WarehouseOrdeRentry // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); + $dir=public_path().'/export/'.date('Y-m'); + if (!file_exists($dir)) { + // 尝试创建目录 + if (!mkdir($dir)) { + throw new BusinessException('创建目录失败:/export/' . date('Y-m')); + } + } + $file_path = $dir . '/' .$this->company.'公司入库单-'.date('Y-m-d H:i') . '.xlsx'; $url = '/export/' . date('Y-m') . '/' .$this->company.'公司入库单-'.date('Y-m-d H:i') . '.xlsx'; - $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); return getenv('APP_URL').$url;