fix(xlsx): 修复订单信息导出时的空值错误

- 在 OrderInfo、OrderList 和 OrderOutbound 类中,为可能为空的字段添加了空值合并操作
- 避免了因未处理空值而导致的报错,提高了代码的健壮性
This commit is contained in:
mkm 2024-11-04 17:54:58 +08:00
parent b057d4bae8
commit 02228255fa
3 changed files with 15 additions and 15 deletions

View File

@ -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']??'');

View File

@ -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', '编号');

View File

@ -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, '销售地址:',);