From 02228255fa7458671e03bb53ba14cbf85e0fb87d Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 4 Nov 2024 17:54:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(xlsx):=20=E4=BF=AE=E5=A4=8D=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=87=BA=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 OrderInfo、OrderList 和 OrderOutbound 类中,为可能为空的字段添加了空值合并操作 - 避免了因未处理空值而导致的报错,提高了代码的健壮性 --- app/common/service/xlsx/OrderInfo.php | 6 +++--- app/common/service/xlsx/OrderList.php | 18 +++++++++--------- app/common/service/xlsx/OrderOutbound.php | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/common/service/xlsx/OrderInfo.php b/app/common/service/xlsx/OrderInfo.php index ea68df9d..e7bbae9c 100644 --- a/app/common/service/xlsx/OrderInfo.php +++ b/app/common/service/xlsx/OrderInfo.php @@ -28,14 +28,14 @@ class OrderInfo $sheet->setCellValue('A1', '采 购 信 息'); $sheet->setCellValue('A2', '姓名:'); - $sheet->setCellValue('B2', $other_data->nickname); + $sheet->setCellValue('B2', $other_data->nickname??''); $sheet->getColumnDimension('B')->setAutoSize(true); $sheet->getColumnDimension('Q')->setAutoSize(true); $sheet->setCellValue('D2', '电话:'); - $sheet->setCellValue('E2', $other_data->phone); + $sheet->setCellValue('E2', $other_data->phone??''); $sheet->setCellValue('G2', '收货地址:'); - $sheet->setCellValue('I2', $other_data->address); + $sheet->setCellValue('I2', $other_data->address??''); $sheet->setCellValue('M2', '订单编号:'); $sheet->setCellValue('O2', $order['order_id']??''); diff --git a/app/common/service/xlsx/OrderList.php b/app/common/service/xlsx/OrderList.php index 4d58eaaa..caef8a8e 100644 --- a/app/common/service/xlsx/OrderList.php +++ b/app/common/service/xlsx/OrderList.php @@ -38,31 +38,31 @@ class OrderList $sheet->setCellValue('A1', '供 投 里 海 农 特 产 品 下 单 清 单'); $sheet->setCellValue('A2', '姓名:'); - $sheet->setCellValue('B2', $other_data->nickname); + $sheet->setCellValue('B2', $other_data->nickname??''); $sheet->getColumnDimension('C')->setAutoSize(true); $sheet->setCellValue('D2', '电话:'); - $sheet->setCellValue('E2', $other_data->phone); + $sheet->setCellValue('E2', $other_data->phone??''); $sheet->setCellValue('G2', '收货地址:'); - $sheet->setCellValue('I2', $other_data->address); + $sheet->setCellValue('I2', $other_data->address??''); $sheet->setCellValue('M2', '订单编号:'); $sheet->setCellValue('O2', $order['order_id']??''); $sheet->setCellValue('A3', '厨师:'); - $sheet->setCellValue('B3', $other_data->chef); + $sheet->setCellValue('B3', $other_data->chef??''); $sheet->setCellValue('D3', '电话:'); - $sheet->setCellValue('E3', $other_data->chef_phone); + $sheet->setCellValue('E3', $other_data->chef_phone??''); $sheet->setCellValue('G3', '事由:'); - $sheet->setCellValue('I3', $other_data->purpose); + $sheet->setCellValue('I3', $other_data->purpose??''); $sheet->setCellValue('L3', '桌数:'); - $sheet->setCellValue('M3', $other_data->tables); + $sheet->setCellValue('M3', $other_data->tables??''); $sheet->setCellValue('N3', '办事时间:'); - $sheet->setCellValue('P3', $other_data->days); + $sheet->setCellValue('P3', $other_data->days??''); $sheet->setCellValue('A4', '下单时间:'); $sheet->setCellValue('B4', $order['create_time']??''); $sheet->setCellValue('D4', '送货时间:'); - $sheet->setCellValue('F4', $other_data->arrival_time); + $sheet->setCellValue('F4', $other_data->arrival_time??''); $sheet->setCellValue('A5', '编号'); diff --git a/app/common/service/xlsx/OrderOutbound.php b/app/common/service/xlsx/OrderOutbound.php index 31f583fe..302db32f 100644 --- a/app/common/service/xlsx/OrderOutbound.php +++ b/app/common/service/xlsx/OrderOutbound.php @@ -27,12 +27,12 @@ class OrderOutbound $sheet->setCellValue('A1', '供 投 里 海 农 特 产 品 出 库 结 算 单'); $sheet->setCellValue('A2', '姓名:'); - $sheet->setCellValue('B2', $other_data->nickname); + $sheet->setCellValue('B2', $other_data->nickname??''); $sheet->getColumnDimension('B')->setWidth(16); $sheet->getColumnDimension('H')->setAutoSize(true); $sheet->setCellValue('C2', '电话:'); - $sheet->setCellValue('D2', $other_data->phone); + $sheet->setCellValue('D2', $other_data->phone??''); $sheet->setCellValue('F2', '订单编号:'); $sheet->setCellValue('G2', $order['order_id']??''); @@ -87,7 +87,7 @@ class OrderOutbound $sheet->mergeCells('B' . ($count + 8) . ':I' . $count + 8); $sheet->setCellValue('A'. ($count + 8), '收货地址:'); - $sheet->setCellValue('B'. ($count + 8), $other_data->address); + $sheet->setCellValue('B'. ($count + 8), $other_data->address??''); $sheet->mergeCells('B' . ($count + 9) . ':E' . $count + 9); $sheet->setCellValue('A' . $count + 9, '销售地址:',);