From 9c47db2244c26fd3f5167ae6fd67defcdd8d4739 Mon Sep 17 00:00:00 2001 From: lemon <15040771@qq.com> Date: Tue, 14 Sep 2021 16:55:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DemandProductController.php | 3 +-- app/Admin/Repositories/DemandProduct.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 app/Admin/Repositories/DemandProduct.php diff --git a/app/Admin/Controllers/DemandProductController.php b/app/Admin/Controllers/DemandProductController.php index 381d311..0b51f17 100644 --- a/app/Admin/Controllers/DemandProductController.php +++ b/app/Admin/Controllers/DemandProductController.php @@ -3,11 +3,10 @@ namespace App\Admin\Controllers; use App\Admin\Extensions\Grid\AuditDemandProduct; -use App\Admin\Repositories\Product; +use App\Admin\Repositories\DemandProduct; use App\Common\ProductStatus; use App\Common\UserStatus; use App\Models\Category; -use App\Models\DemandProduct; use App\Models\Supplier; use Dcat\Admin\Form; use Dcat\Admin\Grid; diff --git a/app/Admin/Repositories/DemandProduct.php b/app/Admin/Repositories/DemandProduct.php new file mode 100644 index 0000000..d2a7f68 --- /dev/null +++ b/app/Admin/Repositories/DemandProduct.php @@ -0,0 +1,16 @@ + Date: Tue, 14 Sep 2021 17:03:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=AB=9E=E6=A0=87=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DemandBiddingController.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/app/AdminSupplier/Controllers/DemandBiddingController.php b/app/AdminSupplier/Controllers/DemandBiddingController.php index 151d8e2..cdc5483 100755 --- a/app/AdminSupplier/Controllers/DemandBiddingController.php +++ b/app/AdminSupplier/Controllers/DemandBiddingController.php @@ -109,18 +109,6 @@ class DemandBiddingController extends AdminController $form->disableViewButton(); $form->disableViewCheck(); - $demand_id = request('demand_id'); - - $isBidding = \App\Models\DemandBidding::query() - ->where('demand_id',$demand_id) - ->where([ - 'bidding_user_type' => DemandTraits::$col[1], - 'bidding_user_id' => Admin::user()->id - ]) - ->exists(); - if ($demand_id && $isBidding) { - Admin::exit('你已经竞标过了,无需重复参加'); - } $form->display('id')->disable(); if(request('is_bidding',0)) { @@ -145,6 +133,21 @@ class DemandBiddingController extends AdminController $form->bidding_user_id = Admin::user()->id; }); + $form->saving(function (Form $form) { + if ($form->isCreating()) { + $isBidding = \App\Models\DemandBidding::query() + ->where('demand_id',$form->demand_id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[1], + 'bidding_user_id' => Admin::user()->id + ]) + ->exists(); + if ($isBidding) { + Admin::exit('你已经竞标过了,无需重复参加'); + } + } + }); + $form->saved(function (Form $form) { $provinceId = Demand::query()->where('id',$this->demand_id)->value('province_id');