From c0cdd0974bcf296ae16e78c71e503cb40914fdea Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Wed, 18 Dec 2024 14:48:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/beforehand_order/BeforehandOrderLists.php | 2 ++ .../logic/beforehand_order/BeforehandOrderLogic.php | 4 ++++ .../PurchaseProductOfferLogic.php | 12 +++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index 847474bcb..9b2e84200 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -110,6 +110,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte $item->outbound = '无须出库'; } elseif ($item->order_type == 6) { $item->order_type_name = '往期补单'; + } elseif ($item->order_type == 7) { + $item->order_type_name = '采购订单'; } $item->msg = ''; $count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id'); diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 418b1f089..8699bdc60 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -678,6 +678,10 @@ class BeforehandOrderLogic extends BaseLogic { $order_info = new OrderInfo(); $order = BeforehandOrder::where('id', $params['id'])->find(); + if ($order['order_type'] == 7 && $params['print'] == 1) { + $order->is_buying = 1; + $order->save(); + } $order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name'); $data = PurchaseProductOffer::where('order_id', $params['id'])->select()->each(function ($item) { $find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,unit,gross_weight,net_weight')->withTrashed()->find(); diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index ad3c317c1..7ca280fb6 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -41,13 +41,23 @@ class PurchaseProductOfferLogic extends BaseLogic { Db::startTrans(); try { + $procurementOrder = BeforehandOrder::where('order_type', 7)->where('is_buying', 0)->find(); + if (empty($procurementOrder)) { + $beforeOrder = BeforehandOrder::where('id', $params['order_id'])->findOrEmpty()->toArray(); + unset($beforeOrder['id'], $beforeOrder['create_time'], $beforeOrder['update_time']); + $procurementOrder = new BeforehandOrder(); + $procurementOrder->setAttrs($beforeOrder); + $procurementOrder->order_id = getNewOrderId('CG'); + $procurementOrder->order_type = 7; + $procurementOrder->save(); + } $mark = $params['mark'] ?? ''; if ($mark == '') { $mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark'); } $find=StoreProduct::where('id',$params['product_id'])->find(); PurchaseProductOffer::create([ - 'order_id' => $params['order_id'], + 'order_id' => $procurementOrder['id'], 'product_id' => $params['product_id'], 'unit' => $params['unit'], 'is_buyer' => $params['is_buyer'], From 9de998ec839c9a6594bcf000ab973fc539ea0e40 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 18 Dec 2024 16:00:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E9=A2=84?= =?UTF-8?q?=E5=94=AE=E8=AE=A2=E5=8D=95=E4=B8=AD=E5=95=86=E5=93=81=E5=B7=B2?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=B6=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在查询商品时使用 withTrashed() 方法,以包含软删除的商品 - 避免在商品被删除后创建预售订单时出现错误 --- app/admin/logic/beforehand_order/BeforehandOrderLogic.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php index 8699bdc60..0d5801906 100644 --- a/app/admin/logic/beforehand_order/BeforehandOrderLogic.php +++ b/app/admin/logic/beforehand_order/BeforehandOrderLogic.php @@ -190,9 +190,9 @@ class BeforehandOrderLogic extends BaseLogic $total_prices = $v['total_price']; $v['uid'] = $params['user_id']; $v['store_id'] = $params['store_id']; - $find = StoreBranchProduct::where('store_id', $params['store_id'])->where('product_id', $v['product_id'])->find(); + $find = StoreBranchProduct::where('store_id', $params['store_id'])->where('product_id', $v['product_id'])->withTrashed()->find(); if (!$find) { - $product = StoreProduct::where('id', $v['product_id'])->find(); + $product = StoreProduct::where('id', $v['product_id'])->withTrashed()->find(); $find = StoreProductLogic::ordinary($product, $params['store_id'], 0, $product); }