diff --git a/app/admin/controller/store_order/StoreOrderController.php b/app/admin/controller/store_order/StoreOrderController.php index 2a23d28a9..2d386ac93 100644 --- a/app/admin/controller/store_order/StoreOrderController.php +++ b/app/admin/controller/store_order/StoreOrderController.php @@ -159,13 +159,18 @@ class StoreOrderController extends BaseAdminController $total_price=0; foreach ($data as $key => &$value) { $find=StoreProduct::where('id',$value->product_id)->find(); - $value->store_name=$find['store_name']; - $value->store_info=$find['store_info']; - $value->unit_name=StoreProductUnit::where('id',$value->unit_id)->value('name'); + $value->store_name=$find['store_name']??''; + $value->store_info=$find['store_info']??''; + if(!empty($find['unit_id'])){ + $value->unit_name=StoreProductUnit::where('id',$find['unit_id'])->value('name'); + }else{ + $value->unit_name=''; + } $total_num+=$value->cart_num; $total_price+=$value->total_price; } $file_path = $xlsx->export($data,$system_store,$total_num,$total_price); - return response()->download($file_path, $system_store.'.xlsx'); + + return $this->success('导出成功', ['url' => $file_path]); } } diff --git a/app/admin/controller/store_order_cart_info/StoreOrderCartInfoController.php b/app/admin/controller/store_order_cart_info/StoreOrderCartInfoController.php index b56782235..8bce62073 100644 --- a/app/admin/controller/store_order_cart_info/StoreOrderCartInfoController.php +++ b/app/admin/controller/store_order_cart_info/StoreOrderCartInfoController.php @@ -96,6 +96,6 @@ class StoreOrderCartInfoController extends BaseAdminController $total_price+=$value->total_price; } $file_path = $xlsx->export($data,$system_store,$total_num,$total_price); - return response()->download($file_path, $system_store.'.xlsx'); + return $this->success('导出成功', ['url' => $file_path]); } } \ No newline at end of file diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index da01c9eb7..8518e8bcd 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -126,9 +126,10 @@ class OrderDetail // 保存文件到 public 下 $writer = new Xlsx($spreadsheet); - $file_path = public_path() . '/export/' . date('Y-m') . '/' . $system_store . '.xlsx'; + $url = '/export/' . date('Y-m') . '/' . $system_store . '.xlsx'; + $file_path = public_path() . $url; // 保存文件到 public 下 $writer->save($file_path); - return $file_path; + return getenv('APP_URL').$url; } }