From acee5e304910d604ed9ed468c703472b2ec912cd Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 14 Dec 2024 16:28:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BE=9B=E8=B4=A7=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../beforehand_order/BeforehandOrderLogic.php | 13 ++++--- .../service/xlsx/OrderSupplyOutbound.php | 36 +++++++++++-------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index ec7dd990..e351cb24 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -737,15 +737,17 @@ class BeforehandOrderLogic extends BaseLogic $data = WarehouseProduct::where('oid', $order['outbound_id'])->where('nums', '>', 0)->select(); $total_price = 0; + $pay_price = 0; $total_profit = 0; foreach ($data as $k => &$v) { $find = StoreProduct::where('id', $v['product_id'])->field('top_cate_id,store_name,unit,after_sales')->withTrashed()->find(); $v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name'); $v['store_name'] = $find['store_name']; $v['mark'] = $find['after_sales']; - $v['total_price'] = bcmul($v['purchase'], $v['nums'], 2); - $v['profit']= bcsub($v['price'], $v['purchase'], 2); - // $total_profit = bcadd($total_profit, $v['profit'], 2); + $v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); + $v['profit']= bcsub($v['total_price'], $v['pay_price'], 2); + $total_profit = bcadd($total_profit, $v['profit'], 2); + $pay_price = bcadd($pay_price, $v['pay_price'], 2); $total_price = bcadd($total_price, $v['total_price'], 2); } $order['system_store_name'] = SystemStore::where('id', $order['store_id'])->value('name'); @@ -753,8 +755,9 @@ class BeforehandOrderLogic extends BaseLogic unset($order['other_data']); $find = WarehouseOrder::where('id', $order['outbound_id'])->find(); $order['order_id'] = $find['code']; - $order['pay_price'] = $total_price; - // $order['total_profit'] = $total_profit; + $order['pay_price'] = $pay_price; + $order['total_profit'] = $total_profit; + $order['total_price'] = $total_price; $file_path = $order_info->export($data, $order, $other_data, 2); return $file_path; } diff --git a/app/common/service/xlsx/OrderSupplyOutbound.php b/app/common/service/xlsx/OrderSupplyOutbound.php index 1e1bf532..52d8f1db 100644 --- a/app/common/service/xlsx/OrderSupplyOutbound.php +++ b/app/common/service/xlsx/OrderSupplyOutbound.php @@ -24,13 +24,13 @@ class OrderSupplyOutbound $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // 合并单元格A1到K1 - $sheet->mergeCells('A1:I1'); + $sheet->mergeCells('A1:K1'); $sheet->mergeCells('D2:E2'); $sheet->mergeCells('H2:I2'); $sheet->mergeCells('G2:I2'); - $sheet->mergeCells('H3:I3'); + $sheet->mergeCells('J3:K3'); $sheet->setCellValue('A1', $title); $sheet->setCellValue('A2', '姓名:'); @@ -47,10 +47,12 @@ class OrderSupplyOutbound $sheet->setCellValue('B3', '品名'); $sheet->setCellValue('C3', '单位'); $sheet->setCellValue('D3', '数量'); - $sheet->setCellValue('E3', '供货价'); - $sheet->setCellValue('F3', '出库价'); - $sheet->setCellValue('G3', '出库总价'); - $sheet->setCellValue('H3', '备注'); + $sheet->setCellValue('E3', '出库单价'); + $sheet->setCellValue('F3', '出库总价'); + $sheet->setCellValue('G3', '供货价'); + $sheet->setCellValue('H3', '供货总价'); + $sheet->setCellValue('I3', '利润'); + $sheet->setCellValue('J3', '备注'); // 设置默认的单元格样式 $defaultStyle = [ @@ -68,11 +70,13 @@ class OrderSupplyOutbound $sheet->setCellValue('B' . ($k + 4), $v['store_name']); $sheet->setCellValue('C' . ($k + 4), $v['unit_name']); $sheet->setCellValue('D' . ($k + 4), $v['nums']); - $sheet->setCellValue('E' . ($k + 4), $v['purchase']); - $sheet->setCellValue('F' . ($k + 4), $v['price']); - $sheet->setCellValue('G' . ($k + 4), $v['total_price']); - $sheet->mergeCells('H' . ($k + 4) . ':I' . $k + 4); - $sheet->setCellValue('H' . ($k + 4), $v['mark']); + $sheet->setCellValue('E' . ($k + 4), $v['price']); + $sheet->setCellValue('F' . ($k + 4), $v['total_price']); + $sheet->setCellValue('G' . ($k + 4), $v['purchase']); + $sheet->setCellValue('H' . ($k + 4), $v['pay_price']); + $sheet->setCellValue('I' . ($k + 4), $v['profit']); + $sheet->mergeCells('J' . ($k + 4) . ':K' . $k + 4); + $sheet->setCellValue('J' . ($k + 4), $v['mark']); } $count = count($data); @@ -88,13 +92,15 @@ class OrderSupplyOutbound $sheet->setCellValue('A' . ($count + 6),'出库合计:'); $sheet->setCellValue('C' . ($count + 6),'出库金额:'); - $sheet->setCellValue('D' . ($count + 6),$order['pay_price']==0?$order['total_price']:$order['pay_price']); + $sheet->setCellValue('D' . ($count + 6),$order['total_price']); $sheet->setCellValue('E' . ($count + 6),'实收押金:'); $sheet->setCellValue('G' . ($count + 6),'供货总价:'); - $sheet->setCellValue('H' . ($count + 6),$order['pay_price']==0?$order['total_price']:$order['pay_price']); + $sheet->setCellValue('H' . ($count + 6),$order['pay_price']); + $sheet->setCellValue('I' . ($count + 6),'总利润:'); + $sheet->setCellValue('J' . ($count + 6),$order['total_profit']); $sheet->setCellValue('A' . ($count + 7),'应收:'); - $sheet->setCellValue('B' . ($count + 7),$order['pay_price']==0?$order['total_price']:$order['pay_price']); + $sheet->setCellValue('B' . ($count + 7),$order['pay_price']); $sheet->setCellValue('C' . ($count + 7),'应退:'); $sheet->setCellValue('F' . ($count + 7),'门店:'); $sheet->mergeCells('G' . ($count + 7) . ':I' . $count + 7); @@ -136,7 +142,7 @@ class OrderSupplyOutbound ], ], ]; - $sheet->getStyle('A1:I' . ($count + 9))->applyFromArray($styleArray); + $sheet->getStyle('A1:K' . ($count + 9))->applyFromArray($styleArray); // 保存文件到 public 下