From ffb57636ef70b8cb1c795679c6c47f676dac80e3 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 23 Jan 2025 11:40:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(xlsx):=20=E4=BC=98=E5=8C=96=20Excel=20?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=A8=A1=E6=9D=BF=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=80=80=E8=B4=A7=E6=94=BF=E7=AD=96=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了多个 Excel 导出模板的列结构和样式 - 在出库供货单模板中添加了退货政策说明内容 - 调整了部分字段的显示位置和格式 --- app/admin/controller/IndexController.php | 3 +- app/common/service/xlsx/OrderAllocation.php | 39 ++++++++----- app/common/service/xlsx/OrderInfo.php | 58 ++++++++++--------- app/common/service/xlsx/OrderOutbound.php | 47 ++++++++++++++- .../service/xlsx/OrderSupplyOutbound.php | 21 ++++++- 5 files changed, 122 insertions(+), 46 deletions(-) diff --git a/app/admin/controller/IndexController.php b/app/admin/controller/IndexController.php index be3c3f21e..a0182cb1e 100644 --- a/app/admin/controller/IndexController.php +++ b/app/admin/controller/IndexController.php @@ -33,7 +33,8 @@ class IndexController extends BaseAdminController public function demo3() { $id=$this->request->get('id'); - $res=DemoLogic::test3($id); + $warehouse_id=$this->request->get('warehouse_id',1); + $res=DemoLogic::test3($id,$warehouse_id); return $this->success('成功'); } } \ No newline at end of file diff --git a/app/common/service/xlsx/OrderAllocation.php b/app/common/service/xlsx/OrderAllocation.php index c50ab8dd0..b3f8098c1 100644 --- a/app/common/service/xlsx/OrderAllocation.php +++ b/app/common/service/xlsx/OrderAllocation.php @@ -50,21 +50,25 @@ class OrderAllocation $sheet->setCellValue('A4', '编号'); + $sheet->mergeCells('B4:E4'); $sheet->setCellValue('B4', '品名'); - $sheet->setCellValue('C4', '数量'); - $sheet->setCellValue('D4', '包装'); - $sheet->setCellValue('E4', '毛重'); - $sheet->setCellValue('F4', '净重(约)'); + $sheet->setCellValue('F4', '数量'); + // $sheet->setCellValue('D4', '包装'); + // $sheet->setCellValue('E4', '毛重'); + // $sheet->setCellValue('F4', '净重(约)'); $sheet->setCellValue('G4', '单位'); + $sheet->mergeCells('H4:I4'); $sheet->setCellValue('H4', '销售单价'); - $sheet->setCellValue('I4', '型号'); + // $sheet->setCellValue('I4', '型号'); $sheet->setCellValue('J4', '下单金额'); $sheet->setCellValue('K4', '发货量'); $sheet->setCellValue('L4', '实发量'); $sheet->setCellValue('M4', '结算金额'); - $sheet->setCellValue('N4', '售后'); - $sheet->setCellValue('O4', '正常损耗'); - $sheet->setCellValue('P4', '备注'); + $sheet->mergeCells('N4:P4'); + + // $sheet->setCellValue('N4', '售后'); + // $sheet->setCellValue('O4', '正常损耗'); + $sheet->setCellValue('N4', '备注'); // 设置默认的单元格样式 $defaultStyle = [ @@ -79,21 +83,24 @@ class OrderAllocation foreach ($data as $k => $v) { $sheet->setCellValue('A' . ($k + 5), $v['product_id']); + $sheet->mergeCells('B'. ($k + 5).':E'. ($k + 5)); $sheet->setCellValue('B' . ($k + 5), $v['store_name']); - $sheet->setCellValue('C' . ($k + 5), $v['cart_num']); - $sheet->setCellValue('D' . ($k + 5), $v['package']); - $sheet->setCellValue('E' . ($k + 5), $v['gross_weight']); - $sheet->setCellValue('F' . ($k + 5), $v['net_weight']); + $sheet->setCellValue('F' . ($k + 5), $v['cart_num']); + // $sheet->setCellValue('D' . ($k + 5), $v['package']); + // $sheet->setCellValue('E' . ($k + 5), $v['gross_weight']); + // $sheet->setCellValue('F' . ($k + 5), $v['net_weight']); $sheet->setCellValue('G' . ($k + 5), $v['unit_name']); + $sheet->mergeCells('H'. ($k + 5).':I'. ($k + 5)); $sheet->setCellValue('H' . ($k + 5), $v['price']); - $sheet->setCellValue('I' . ($k + 5), $v['marques']); + // $sheet->setCellValue('I' . ($k + 5), $v['marques']); $sheet->setCellValue('J' . ($k + 5), $v['total_price']); $sheet->setCellValue('K' . ($k + 5), $v['accept_num']); $sheet->setCellValue('L' . ($k + 5),$v['accept_num']); $sheet->setCellValue('M' . ($k + 5),$v['pay_price']); - $sheet->setCellValue('N' . ($k + 5),$v['after_sales']); - $sheet->setCellValue('O' . ($k + 5),$v['loss']); - $sheet->setCellValue('P' . ($k + 5),$v['mark']); + // $sheet->setCellValue('N' . ($k + 5),$v['after_sales']); + // $sheet->setCellValue('O' . ($k + 5),$v['loss']); + $sheet->mergeCells('N'. ($k + 5).':P'. ($k + 5)); + $sheet->setCellValue('N' . ($k + 5),$v['mark']); } diff --git a/app/common/service/xlsx/OrderInfo.php b/app/common/service/xlsx/OrderInfo.php index aba991db4..17d8e849f 100644 --- a/app/common/service/xlsx/OrderInfo.php +++ b/app/common/service/xlsx/OrderInfo.php @@ -41,22 +41,25 @@ class OrderInfo $sheet->setCellValue('O2', $order['order_id']??''); $sheet->setCellValue('A3', '编号'); + $sheet->mergeCells('B3:D3'); $sheet->setCellValue('B3', '品名'); - $sheet->setCellValue('C3', '毛重'); - $sheet->setCellValue('D3', '净重(约)'); + // $sheet->setCellValue('C3', '毛重'); + // $sheet->setCellValue('D3', '净重(约)'); + $sheet->mergeCells('E3:F3'); $sheet->setCellValue('E3', '单位'); - $sheet->setCellValue('F3', '采购单价'); + // $sheet->setCellValue('F3', '采购单价'); $sheet->setCellValue('G3', '下单数量'); - $sheet->setCellValue('H3', '实收量'); - $sheet->setCellValue('I3', '采购金额'); - $sheet->setCellValue('J3', '结算模式'); - $sheet->setCellValue('K3', '包装'); - $sheet->setCellValue('L3', '押金'); - $sheet->setCellValue('M3', '型号'); - $sheet->setCellValue('N3', '售后'); - $sheet->setCellValue('O3', '损耗'); - $sheet->setCellValue('P3', '供应商'); - $sheet->setCellValue('Q3', '备注'); + // $sheet->setCellValue('H3', '实收量'); + // $sheet->setCellValue('I3', '采购金额'); + // $sheet->setCellValue('J3', '结算模式'); + // $sheet->setCellValue('K3', '包装'); + // $sheet->setCellValue('L3', '押金'); + // $sheet->setCellValue('M3', '型号'); + // $sheet->setCellValue('N3', '售后'); + // $sheet->setCellValue('O3', '损耗'); + // $sheet->setCellValue('P3', '供应商'); + $sheet->mergeCells('H3:Q3'); + $sheet->setCellValue('H3', '备注'); $sheet->setCellValue('R3', '采购人'); // 设置默认的单元格样式 @@ -72,22 +75,25 @@ class OrderInfo foreach ($data as $k => $v) { $sheet->setCellValue('A' . ($k + 4), $v['product_id']); + $sheet->mergeCells('B'. ($k + 4).':D'. ($k + 4)); $sheet->setCellValue('B' . ($k + 4), $v['store_name']); - $sheet->setCellValue('C' . ($k + 4), $v['gross_weight']); - $sheet->setCellValue('D' . ($k + 4), $v['net_weight']); + // $sheet->setCellValue('C' . ($k + 4), $v['gross_weight']); + // $sheet->setCellValue('D' . ($k + 4), $v['net_weight']); + $sheet->mergeCells('E'. ($k + 4).':F'. ($k + 4)); $sheet->setCellValue('E' . ($k + 4), $v['unit_name']); - $sheet->setCellValue('F' . ($k + 4), $v['price']); + // $sheet->setCellValue('F' . ($k + 4), $v['price']); $sheet->setCellValue('G' . ($k + 4), $v['need_num']); - $sheet->setCellValue('H' . ($k + 4), $v['buyer_nums']); - $sheet->setCellValue('I' . ($k + 4), $v['total_price']); - $sheet->setCellValue('J' . ($k + 4), ''); - $sheet->setCellValue('K' . ($k + 4), $v['package']); - $sheet->setCellValue('L' . ($k + 4), $v['deposit']); - $sheet->setCellValue('M' . ($k + 4), $v['marques']); - $sheet->setCellValue('N' . ($k + 4), $v['after_sales']); - $sheet->setCellValue('O' . ($k + 4), $v['loss']); - $sheet->setCellValue('P' . ($k + 4), ''); - $sheet->setCellValue('Q' . ($k + 4), $v['mark']); + $sheet->mergeCells('H'. ($k + 4).':Q'. ($k + 4)); + // $sheet->setCellValue('H' . ($k + 4), $v['buyer_nums']); + // $sheet->setCellValue('I' . ($k + 4), $v['total_price']); + // $sheet->setCellValue('J' . ($k + 4), ''); + // $sheet->setCellValue('K' . ($k + 4), $v['package']); + // $sheet->setCellValue('L' . ($k + 4), $v['deposit']); + // $sheet->setCellValue('M' . ($k + 4), $v['marques']); + // $sheet->setCellValue('N' . ($k + 4), $v['after_sales']); + // $sheet->setCellValue('O' . ($k + 4), $v['loss']); + // $sheet->setCellValue('P' . ($k + 4), ''); + $sheet->setCellValue('H' . ($k + 4), $v['mark']); $sheet->setCellValue('R' . ($k + 4), $v['buyer_name']); } diff --git a/app/common/service/xlsx/OrderOutbound.php b/app/common/service/xlsx/OrderOutbound.php index 912a6d8e0..18ecb3759 100644 --- a/app/common/service/xlsx/OrderOutbound.php +++ b/app/common/service/xlsx/OrderOutbound.php @@ -115,6 +115,26 @@ class OrderOutbound $sheet->setCellValue('F' . $count + 9, '电话:',); $sheet->setCellValue('G' . $count + 9, '08302669767',); $sheet->setCellValue('H' . $count + 9, '签收:',); + $sheet->mergeCells('A' . ($count + 10) . ':I' . ($count + 10)); + $sheet->setCellValue('A' . ($count + 10), '退货政策说明:'); + + $sheet->mergeCells('A' . ($count + 11) . ':I' . ($count + 11)); + $title3 = '1、冻货、生鲜、散装农产品等商品:由于此类商品是客户专项订购、无法重复销售,'; + $sheet->setCellValue('A' . ($count + 11), $title3); + + $sheet->mergeCells('A' . ($count + 12) . ':I' . ($count + 12)); + $title3 ='一旦出库,恕不退换货,请务必在购买前确认商品信息及需求。'; + $sheet->setCellValue('A' . ($count + 12), $title3); + + + $sheet->mergeCells('A' . ($count + 13) . ':I' . ($count + 13)); + $title4 = '2、其余商品:出库之日起10日内,退货数量不得超过该商品购买数量的30%'; + $sheet->setCellValue('A' . ($count + 13), $title4); + + $sheet->mergeCells('A' . ($count + 14) . ':I' . ($count + 14)); + $title4 = '上述要求旨在保障库存管理及商品周转的合理性。'; + $sheet->setCellValue('A' . ($count + 14), $title4); + // 设置单元格的样式 $styleArray = [ 'font' => [ @@ -132,7 +152,7 @@ class OrderOutbound ], ], ]; - $sheet->getStyle('A1:I' . ($count + 9))->applyFromArray($styleArray); + $sheet->getStyle('A1:I' . ($count + 14))->applyFromArray($styleArray); // 保存文件到 public 下 @@ -151,6 +171,9 @@ class OrderOutbound return getenv('APP_URL').$url; } + /** + * 无价格供货单 + */ public function exportWithoutPrice($data,$order,$other_data) { $title='供 投 里 海 农 特 产 品 出 库 供 货 单'; @@ -246,6 +269,26 @@ class OrderOutbound $sheet->setCellValue('F' . $count + 9, '电话:',); $sheet->setCellValue('G' . $count + 9, '08302669767',); $sheet->setCellValue('H' . $count + 9, '签收:',); + $sheet->mergeCells('A' . ($count + 10) . ':I' . ($count + 10)); + $sheet->setCellValue('A' . ($count + 10), '退货政策说明:'); + + $sheet->mergeCells('A' . ($count + 11) . ':I' . ($count + 11)); + $title3 = '1、冻货、生鲜、散装农产品等商品:由于此类商品是客户专项订购、无法重复销售,'; + $sheet->setCellValue('A' . ($count + 11), $title3); + + $sheet->mergeCells('A' . ($count + 12) . ':I' . ($count + 12)); + $title3 ='一旦出库,恕不退换货,请务必在购买前确认商品信息及需求。'; + $sheet->setCellValue('A' . ($count + 12), $title3); + + + $sheet->mergeCells('A' . ($count + 13) . ':I' . ($count + 13)); + $title4 = '2、其余商品:出库之日起10日内,退货数量不得超过该商品购买数量的30%'; + $sheet->setCellValue('A' . ($count + 13), $title4); + + $sheet->mergeCells('A' . ($count + 14) . ':I' . ($count + 14)); + $title4 = '上述要求旨在保障库存管理及商品周转的合理性。'; + $sheet->setCellValue('A' . ($count + 14), $title4); + // 设置单元格的样式 $styleArray = [ 'font' => [ @@ -263,7 +306,7 @@ class OrderOutbound ], ], ]; - $sheet->getStyle('A1:I' . ($count + 9))->applyFromArray($styleArray); + $sheet->getStyle('A1:I' . ($count + 14))->applyFromArray($styleArray); // 保存文件到 public 下 diff --git a/app/common/service/xlsx/OrderSupplyOutbound.php b/app/common/service/xlsx/OrderSupplyOutbound.php index 905b71a3f..1844a2d75 100644 --- a/app/common/service/xlsx/OrderSupplyOutbound.php +++ b/app/common/service/xlsx/OrderSupplyOutbound.php @@ -128,6 +128,25 @@ class OrderSupplyOutbound $sheet->setCellValue('F' . $count + 9, '电话:',); $sheet->setCellValue('G' . $count + 9, '08302669767',); $sheet->setCellValue('H' . $count + 9, '签收:',); + $sheet->mergeCells('A' . ($count + 10) . ':K' . ($count + 10)); + $sheet->setCellValue('A' . ($count + 10), '退货政策说明:'); + + $sheet->mergeCells('A' . ($count + 11) . ':K' . ($count + 11)); + $title3 = '1、冻货、生鲜、散装农产品等商品:由于此类商品是客户专项订购、无法重复销售,'; + $sheet->setCellValue('A' . ($count + 11), $title3); + + $sheet->mergeCells('A' . ($count + 12) . ':K' . ($count + 12)); + $title3 ='一旦出库,恕不退换货,请务必在购买前确认商品信息及需求。'; + $sheet->setCellValue('A' . ($count + 12), $title3); + + + $sheet->mergeCells('A' . ($count + 13) . ':K' . ($count + 13)); + $title4 = '2、其余商品:出库之日起10日内,退货数量不得超过该商品购买数量的30%'; + $sheet->setCellValue('A' . ($count + 13), $title4); + + $sheet->mergeCells('A' . ($count + 14) . ':K' . ($count + 14)); + $title4 = '上述要求旨在保障库存管理及商品周转的合理性。'; + $sheet->setCellValue('A' . ($count + 14), $title4); // 设置单元格的样式 $styleArray = [ 'font' => [ @@ -145,7 +164,7 @@ class OrderSupplyOutbound ], ], ]; - $sheet->getStyle('A1:K' . ($count + 9))->applyFromArray($styleArray); + $sheet->getStyle('A1:K' . ($count + 14))->applyFromArray($styleArray); // 保存文件到 public 下