From 65ce4808c93d10d07ad1e1fc0ba72c74b6b0505c Mon Sep 17 00:00:00 2001 From: "DESKTOP-GMUNQ1B\\Administrator" <604446095@qq.com> Date: Wed, 18 Dec 2024 17:44:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=87=87=E8=B4=AD=E5=8D=95?= =?UTF-8?q?=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseProductOfferLists.php | 16 ++++++ .../PurchaseProductOfferLogic.php | 53 +++++++++++++------ .../PurchaseProductOffer.php | 2 + 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 5d72a652..05e5f5d9 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -49,6 +49,14 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc */ public function lists(): array { + $procurementOrderId = PurchaseProductOffer::where('source_order_id', $this->params['order_id'])->value('source_order_id'); + if ($procurementOrderId) { + foreach ($this->searchWhere as $k => &$v) { + if ($v[0] == 'order_id') { + $v[2] = $procurementOrderId; + } + } + } $store_name=$this->request->get('store_name'); if($store_name){ $ids=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id'); @@ -125,6 +133,14 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc if($this->is_ids==1){ return 0; } + $procurementOrderId = PurchaseProductOffer::where('source_order_id', $this->params['order_id'])->value('source_order_id'); + if ($procurementOrderId) { + foreach ($this->searchWhere as $k => &$v) { + if ($v[0] == 'order_id') { + $v[2] = $procurementOrderId; + } + } + } return PurchaseProductOffer::where($this->searchWhere)->count(); } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 7ca280fb..c00169aa 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -56,21 +56,44 @@ class PurchaseProductOfferLogic extends BaseLogic $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' => $procurementOrder['id'], - 'product_id' => $params['product_id'], - 'unit' => $params['unit'], - 'is_buyer' => $params['is_buyer'], - 'need_num' => $params['need_num'], - 'mark' => $mark, - 'buyer_id' => $params['buyer_id'], - 'package' => $find['package'], - 'store_info' => $find['store_info'], - 'marques' => $find['marques'], - 'after_sales' => $find['after_sales'], - 'status' => 0, - - ]); + $purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find(); + if ($purchaseProductOffer) { + $purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num']; + if (!empty($purchaseProductOffer['source_order_info'])) { + $sourceOrderInfo = $purchaseProductOffer['source_order_info']; + $sourceOrderInfo[] = [ + 'source_order_id' => $params['order_id'], + 'product_id' => $params['product_id'], + 'need_num' => $params['need_num'], + 'mark' => $mark, + ]; + $purchaseProductOffer->source_order_info = $sourceOrderInfo; + } + $purchaseProductOffer->save(); + } else { + PurchaseProductOffer::create([ + 'order_id' => $procurementOrder['id'], + 'product_id' => $params['product_id'], + 'unit' => $params['unit'], + 'is_buyer' => $params['is_buyer'], + 'need_num' => $params['need_num'], + 'mark' => $mark, + 'buyer_id' => $params['buyer_id'], + 'package' => $find['package'], + 'store_info' => $find['store_info'], + 'marques' => $find['marques'], + 'after_sales' => $find['after_sales'], + 'status' => 0, + 'source_order_info' => [ + [ + 'source_order_id' => $params['order_id'], + 'product_id' => $params['product_id'], + 'need_num' => $params['need_num'], + 'mark' => $mark, + ] + ] + ]); + } BeforehandOrderCartInfo::where(['bhoid' => $params['order_id'], 'product_id' => $params['product_id']])->update(['is_buyer' => 1]); Db::commit(); return true; diff --git a/app/common/model/purchase_product_offer/PurchaseProductOffer.php b/app/common/model/purchase_product_offer/PurchaseProductOffer.php index 4f76f0f9..1c6efb33 100644 --- a/app/common/model/purchase_product_offer/PurchaseProductOffer.php +++ b/app/common/model/purchase_product_offer/PurchaseProductOffer.php @@ -18,5 +18,7 @@ class PurchaseProductOffer extends BaseModel protected $name = 'purchase_product_offer'; protected $deleteTime = 'delete_time'; + protected $json = ['source_order_info']; + protected $jsonAssoc = true; } \ No newline at end of file