From 43802dadc7e3e8bf64c15353d1bb77963c3449d9 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Sat, 14 Dec 2024 15:59:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=BF=87=E6=BB=A4=E6=89=B9=E5=8F=91=E5=95=86?= =?UTF-8?q?=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/lists/store_product/StoreProductLists.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 9abcc58f..4a7561b1 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -71,6 +71,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $query = StoreProduct::where($this->searchWhere); if (isset($this->params['type_filter'])) { + $query->where('product_type', '<>', 5); if ($this->params['type_filter'] == 0) { $query->where(function ($query) { $query->where('product_type', 6)->whereOr('is_show', 0); 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 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BE=9B=E8=B4=A7?= =?UTF-8?q?=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 下 From ce0dbca714d1457ff0bda355badb25de29ebce54 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Sat, 14 Dec 2024 17:21:23 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=A2=84=E8=AE=A2=E5=8D=95=E5=88=86=E6=8B=A3=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderCartInfoController.php | 7 +++++++ .../BeforehandOrderCartInfoLogic.php | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php index 4e016f16..35226807 100644 --- a/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php +++ b/app/admin/controller/beforehand_order_cart_info/BeforehandOrderCartInfoController.php @@ -142,4 +142,11 @@ class BeforehandOrderCartInfoController extends BaseAdminController return $this->data($result); } + public function fix() + { + $params = $this->request->get(); + BeforehandOrderCartInfoLogic::fixAcceptNum($params); + return $this->data([]); + } + } \ No newline at end of file diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 301d8224..459ff753 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -283,4 +283,15 @@ class BeforehandOrderCartInfoLogic extends BaseLogic { return BeforehandOrderCartInfo::findOrEmpty($params['id'])->toArray(); } + + public static function fixAcceptNum($params) + { + $cartInfo = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select(); + foreach ($cartInfo as $k => $v) { + if ($v['cart_num'] != $v['accept_num']) { + $v->save(['accept_num' => $v['cart_num']]); + } + } + } + } From f81575085f5d23eacb1c993800184c80fda8855f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sat, 14 Dec 2024 17:29:27 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=80=E9=94=AE=E6=8A=A5=E6=8D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeforehandOrderController.php | 10 +++ .../beforehand_order/BeforehandOrderLogic.php | 74 +++++++++++++++++++ .../WarehouseProductLogic.php | 22 +++--- 3 files changed, 96 insertions(+), 10 deletions(-) diff --git a/app/admin/controller/beforehand_order/BeforehandOrderController.php b/app/admin/controller/beforehand_order/BeforehandOrderController.php index 9416f84a..9bc689e1 100644 --- a/app/admin/controller/beforehand_order/BeforehandOrderController.php +++ b/app/admin/controller/beforehand_order/BeforehandOrderController.php @@ -98,7 +98,17 @@ class BeforehandOrderController extends BaseAdminController return $this->success('出库成功', [], 1, 1); } + /** + * 一键报损出库 + */ + public function createOutboundDamageOrder() + { + $params = $this->request->post(); + $params['admin_id'] = $this->adminId; + $result = BeforehandOrderLogic::createOutboundOrder($params); + return $this->success('出库成功', [], 1, 1); + } /** * @notes 订单转预定单 * @return \think\response\Json diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index e351cb24..7bfe3ad1 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -414,6 +414,80 @@ class BeforehandOrderLogic extends BaseLogic throw new BusinessException($e->getMessage()); } } + + /** + * @notes 一键报损出库 + * @param array $params + * @return bool + * @author admin + * @date 2024/09/30 11:26 + */ + public static function createOutboundDamageOrder(array $params): bool + { + $warehouse_id = $params['warehouse_id']; + $admin_id = $params['admin_id']; + $mark = $params['remark'] ?? ''; + $order = BeforehandOrder::where('id', $params['id'])->find(); + if (!$order) { + throw new BusinessException('该订单不存在'); + } + if ($order['order_type'] != 7) { + throw new BusinessException('不是报损单,无法出库'); + } + if ($order['outbound_id'] > 0) { + throw new BusinessException('该订单已创建出库单'); + } + $info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select(); + + $count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id'); + if ($count > 0) { + throw new BusinessException('订单中有数量为0的商品,请先处理'); + } + Db::startTrans(); + try { + $arr = [ + 'oid' => 0, + 'warehouse_id' => $warehouse_id, + 'store_id' => 0, + 'supplier_id' => 0, + 'code' => getNewOrderId('BS'), + 'admin_id' => $admin_id, + 'financial_pm' => 0, + 'batch' => 0, + 'mark' => $mark, + ]; + $arr['delivery_time'] = time(); + $res = WarehouseOrder::create($arr); + foreach ($info as $key => $arr) { + $data = [ + 'warehouse_id' => $warehouse_id, + 'product_id' => $arr['product_id'], + 'store_id' => 0, + 'financial_pm' => 0, + 'batch' => 1, + 'order_type' => $order['order_type'], + 'nums' => $arr['cart_num'], + 'status' => 1, + 'admin_id' => $admin_id, + 'total_price' => $arr['total_price'], + 'price' => $arr['price'], + 'purchase' => $arr['purchase'], + 'oid' => $res['id'], + 'code' => $res['code'], + 'unit' => $arr['unit'] ?? 0, + ]; + WarehouseProductLogic::setOutbound($data); + } + $finds = WarehouseProduct::where('oid', $res['id'])->field('sum(nums) as nums,sum(total_price) as total_price')->find(); + WarehouseOrder::where('id', $res['id'])->update(['total_price' => $finds['total_price'], 'nums' => $finds['nums']]); + $order->save(['outbound_id' => $res['id'], 'is_outbound' => 1, 'pay_price' => $finds['total_price']]); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * @notes 订单转预定单 * @param array $params diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index cad46c9d..ace971a5 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -125,16 +125,18 @@ class WarehouseProductLogic extends BaseLogic if ($params['order_type'] != 6) { $storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find(); if ($storege) { - SystemStoreStorage::create([ - 'store_id' => $params['store_id'], - 'admin_id' => $params['admin_id'], - 'order_type' => $params['order_type'], - 'staff_id' => 0, - 'type' => 1, - 'product_id' => $params['product_id'], - 'nums' => $params['nums'], - 'status' => 0 - ]); + if($params['order_type']!=7){ + SystemStoreStorage::create([ + 'store_id' => $params['store_id'], + 'admin_id' => $params['admin_id'], + 'order_type' => $params['order_type'], + 'staff_id' => 0, + 'type' => 1, + 'product_id' => $params['product_id'], + 'nums' => $params['nums'], + 'status' => 0 + ]); + } $after_nums = bcsub($storege['nums'], $params['nums']); $total_price = bcmul($after_nums, $params['purchase'], 2); WarehouseProductStorege::update(['nums' => bcsub($storege['nums'], $params['nums']), 'total_price' => $total_price], ['id' => $storege['id']]);