From e4b5bcd6a46aeca7b4e4689a64b8d85ba1c36799 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 15 Dec 2024 15:14:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 9 ++++ .../beforehand_order/BeforehandOrderLogic.php | 45 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 9bc689e1c..d4c07c6d1 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -255,6 +255,15 @@ class BeforehandOrderController extends BaseAdminController $file_path = BeforehandOrderLogic::OrderOutbound($params); } return $this->success('导出成功', ['url' => $file_path]); + } + /** + * 导出会员出库 + */ + public function order_outbound3() + { + $params = $this->request->post(); + $file_path = BeforehandOrderLogic::OrderOutbound3($params); + return $this->success('导出成功', ['url' => $file_path]); } /** * 导出财务出库 diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 7bfe3ad12..13fdc5bc8 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -17,6 +17,7 @@ use app\common\model\store_category\StoreCategory; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_product\StoreProduct; +use app\common\model\store_product_group_price\StoreProductGroupPrice; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; use app\common\model\user\User; @@ -835,4 +836,48 @@ class BeforehandOrderLogic extends BaseLogic $file_path = $order_info->export($data, $order, $other_data, 2); return $file_path; } + + /** + * 导出供货出库 + */ + public static function OrderOutbound3($params) + { + $order_info = new OrderSupplyOutbound(); + $order = BeforehandOrder::where('id', $params['id'])->find(); + if ($order['outbound_id'] <= 0) { + throw new BusinessException('订单未出库,不能导出出库单'); + } + $order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name'); + $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['purchase']=StoreProductGroupPrice::where('product_id',$v['product_id'])->where('group_id',18)->value('price'); + if($v['purchase']){ + $v['pay_price'] = bcmul($v['purchase'], $v['nums'], 2); + }else{ + $v['pay_price']=0; + } + $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'); + $other_data = $order['other_data']; + unset($order['other_data']); + $find = WarehouseOrder::where('id', $order['outbound_id'])->find(); + $order['order_id'] = $find['code']; + $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; + } }