From a8be80039b211a4c8621a01fe4a3ce5bd3e9f056 Mon Sep 17 00:00:00 2001 From: lemon <15040771@qq.com> Date: Sat, 18 Sep 2021 15:25:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AB=9E=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DemandController.php | 19 +++- .../Controllers/DemandBiddingController.php | 2 +- .../Controllers/DemandController.php | 26 ++++-- .../Controllers/MyDemandProductController.php | 4 +- .../Controllers/WorkorderController.php | 2 +- .../Extensions/Grid/ChooseDemand.php | 86 +++++++++++++++++++ app/AdminGuide/Lazys/DemandBiddingLazys.php | 48 +++++++++++ app/AdminGuide/Repositories/Workorder.php | 16 ++++ .../Controllers/DemandController.php | 22 +++-- .../Extensions/Grid/ChooseDemand.php | 2 +- app/Traits/DemandTraits.php | 2 +- 11 files changed, 205 insertions(+), 24 deletions(-) create mode 100644 app/AdminGuide/Extensions/Grid/ChooseDemand.php create mode 100644 app/AdminGuide/Lazys/DemandBiddingLazys.php create mode 100755 app/AdminGuide/Repositories/Workorder.php diff --git a/app/AdminAgent/Controllers/DemandController.php b/app/AdminAgent/Controllers/DemandController.php index 4c1b0e7..23ef5f5 100755 --- a/app/AdminAgent/Controllers/DemandController.php +++ b/app/AdminAgent/Controllers/DemandController.php @@ -80,18 +80,31 @@ class DemandController extends AdminController }); }else{ $grid->column('bidding','竞标') - ->if(function (){ + ->if(function () { $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[0], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == Arr::first(DemandTraits::$col) && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[0], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == Arr::first(DemandTraits::$col) && $isNotBidding; + }) + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); }); } diff --git a/app/AdminGuide/Controllers/DemandBiddingController.php b/app/AdminGuide/Controllers/DemandBiddingController.php index 2b9cad1..18c64f0 100755 --- a/app/AdminGuide/Controllers/DemandBiddingController.php +++ b/app/AdminGuide/Controllers/DemandBiddingController.php @@ -2,7 +2,7 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Repositories\DemandBidding; +use App\AdminGuide\Repositories\DemandBidding; use App\Models\Demand; use App\Traits\DemandTraits; use Dcat\Admin\Admin; diff --git a/app/AdminGuide/Controllers/DemandController.php b/app/AdminGuide/Controllers/DemandController.php index 085f1d4..e75078a 100755 --- a/app/AdminGuide/Controllers/DemandController.php +++ b/app/AdminGuide/Controllers/DemandController.php @@ -2,12 +2,9 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; -use App\Models\AgentProduct; -use App\Models\Product; +use App\AdminGuide\Lazys\DemandBiddingLazys; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminGuide\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; @@ -79,18 +76,31 @@ class DemandController extends AdminController }); }else{ $grid->column('bidding','竞标') - ->if(function (){ + ->if(function () { $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[2], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[2] && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[2], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[2] && $isNotBidding; + }) + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); }); } diff --git a/app/AdminGuide/Controllers/MyDemandProductController.php b/app/AdminGuide/Controllers/MyDemandProductController.php index 902aacd..ffeb391 100755 --- a/app/AdminGuide/Controllers/MyDemandProductController.php +++ b/app/AdminGuide/Controllers/MyDemandProductController.php @@ -2,14 +2,12 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; use App\Common\ProductStatus; use App\Models\AgentProduct; use App\Models\Channel; use App\Models\Product; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminGuide\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; diff --git a/app/AdminGuide/Controllers/WorkorderController.php b/app/AdminGuide/Controllers/WorkorderController.php index b36cd0b..c31a0b4 100755 --- a/app/AdminGuide/Controllers/WorkorderController.php +++ b/app/AdminGuide/Controllers/WorkorderController.php @@ -2,7 +2,7 @@ namespace App\AdminGuide\Controllers; -use App\AdminAgent\Repositories\Workorder; +use App\AdminGuide\Repositories\Workorder; use App\Common\AgentType; use App\Http\Controllers\Controller; use App\Models\Agent; diff --git a/app/AdminGuide/Extensions/Grid/ChooseDemand.php b/app/AdminGuide/Extensions/Grid/ChooseDemand.php new file mode 100644 index 0000000..e120b9e --- /dev/null +++ b/app/AdminGuide/Extensions/Grid/ChooseDemand.php @@ -0,0 +1,86 @@ +id = $biddingId; + $this->title = '选中竞标'; + } + + protected function html() + { + $class = 'btn btn-sm btn-success'; + $this->appendHtmlAttribute('class', $class); + $this->defaultHtmlAttribute('href', 'javascript:;'); + + return "formatHtmlAttributes()}>{$this->title}"; + } + + public function handle(Request $request) + { + $demandBiddingId = request('bidding_id',0); + $demandBidding = DemandBidding::find($demandBiddingId); + if (empty($demandBidding)) { + return $this->response()->error('订单异常'); + } + + $demand = \App\Models\Demand::find($demandBidding->demand_id); + + if (empty($demand)) { + return $this->response()->error('订单异常'); + } + + DB::beginTransaction(); + try { + $demandBidding->state = 1; + $demandBidding->save(); + //改变订单状态 + $demand->bidding_id = $demandBidding->id; + $demand->bidding_user_id = $demandBidding->bidding_user_id; + $demand->state = DemandTraits::$stateKey[1]; + $demand->save(); + //如果是地接类型 绑定地接到订单 + if ($demand->bidding_user_type == DemandTraits::$col[2]){ + $agentProduct = AgentProduct::find($demand->agent_product_id); + $agentProduct->guide_id = $demandBidding->bidding_user_id; + $agentProduct->guide_price = $demandBidding->price; + $agentProduct->save(); + } + DB::commit(); + return $this->response()->success("选中竞标成功")->refresh(); + } catch (\Exception $e) { + Log::error('选中竞标失败::'.$e->getTraceAsString()); + DB::rollBack(); + return $this->response()->error($e->getMessage()); + } + } + + public function confirm() + { + return ['确定要选中该竞标吗?', '']; + } + + public function parameters() + { + return ['bidding_id' => $this->id]; + } +} diff --git a/app/AdminGuide/Lazys/DemandBiddingLazys.php b/app/AdminGuide/Lazys/DemandBiddingLazys.php new file mode 100644 index 0000000..cfe0285 --- /dev/null +++ b/app/AdminGuide/Lazys/DemandBiddingLazys.php @@ -0,0 +1,48 @@ +model()->where('demand_id',$demandId); + $grid->column('id'); + $grid->column('price','出价')->sortable(); + $grid->column('comment','内容'); + $grid->column('biddingUser.name','竞拍人'); + $grid->column('bidding','竞标') + ->if(function () use ($demand){ + return $demand->state == 1; + }) + ->then(function (Grid\Column $column) { + $column->append(new ChooseDemand($this->id)); + }) + ->if(function () use ($demand){ + return $demand->state == 2; + }) + ->then(function (Grid\Column $column) use ($demand){ + if ($demand->bidding_id == $this->id) { + $column->append('已中标'); + } else { + $column->append('未中标'); + } + }); + $grid->column('created_at'); + $grid->disableActions(); + $grid->disableRowSelector(); + }); + } +} diff --git a/app/AdminGuide/Repositories/Workorder.php b/app/AdminGuide/Repositories/Workorder.php new file mode 100755 index 0000000..a30407b --- /dev/null +++ b/app/AdminGuide/Repositories/Workorder.php @@ -0,0 +1,16 @@ + $this->id]); }); }else{ - $grid->column('bidding', '竞标') + $grid->column('bidding','竞标') ->if(function () { - // $isBidding 表示参加过竞标后不再显示 $isBidding = DemandBidding::query() ->where('demand_id',$this->id) ->where([ 'bidding_user_type' => DemandTraits::$col[1], 'bidding_user_id' => Admin::user()->id ]) - ->doesntExist(); + ->exists(); return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[1] && $isBidding; }) ->then(function (Grid\Column $column) { - $column->append('发起竞标'); + $column->display('已竞标'); + }) + ->if(function (){ + $isNotBidding = DemandBidding::query() + ->where('demand_id',$this->id) + ->where([ + 'bidding_user_type' => DemandTraits::$col[1], + 'bidding_user_id' => Admin::user()->id + ]) + ->doesntExist(); + return $this->state == 1 && $this->bidding_user_type == DemandTraits::$col[1] && $isNotBidding; }) - ->else() - ->display(''); + ->then(function (Grid\Column $column) { + $column->append('参与竞标'); + }); } $grid->column('created_at')->sortable(); diff --git a/app/AdminSupplier/Extensions/Grid/ChooseDemand.php b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php index 6834bf5..9620f70 100644 --- a/app/AdminSupplier/Extensions/Grid/ChooseDemand.php +++ b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php @@ -1,6 +1,6 @@ '竞标中' , - 2 => '已竞标' , + 2 => '已结标' , 3 => '流拍' ]; From 90c4459bbbb5b9377be49d25baefa4e0dd104bcb Mon Sep 17 00:00:00 2001 From: lemon <15040771@qq.com> Date: Sat, 18 Sep 2021 15:28:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=9A=E4=BD=99use?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DemandController.php | 2 +- .../Controllers/FinanceStatisticsController.php | 1 - .../Controllers/MyBiddingProductController.php | 3 +-- .../Controllers/MyDemandProductController.php | 4 +--- .../Controllers/ProductStatisticsController.php | 4 ---- .../Controllers/WithdrawalAlipayController.php | 2 +- .../Controllers/WorkorderController.php | 2 +- app/AdminSupplier/Lazys/DemandBiddingLazys.php | 4 ++-- app/AdminSupplier/Renderable/SelectProduct.php | 1 - app/AdminSupplier/Repositories/Workorder.php | 16 ++++++++++++++++ 10 files changed, 23 insertions(+), 16 deletions(-) create mode 100755 app/AdminSupplier/Repositories/Workorder.php diff --git a/app/AdminSupplier/Controllers/DemandController.php b/app/AdminSupplier/Controllers/DemandController.php index d95e62c..94d3f61 100755 --- a/app/AdminSupplier/Controllers/DemandController.php +++ b/app/AdminSupplier/Controllers/DemandController.php @@ -5,7 +5,7 @@ namespace App\AdminSupplier\Controllers; use App\AdminSupplier\Lazys\DemandBiddingLazys; use App\Models\DemandProduct; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminSupplier\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; diff --git a/app/AdminSupplier/Controllers/FinanceStatisticsController.php b/app/AdminSupplier/Controllers/FinanceStatisticsController.php index a7785e0..260a5a3 100755 --- a/app/AdminSupplier/Controllers/FinanceStatisticsController.php +++ b/app/AdminSupplier/Controllers/FinanceStatisticsController.php @@ -3,7 +3,6 @@ namespace App\AdminSupplier\Controllers; use App\AdminSupplier\Metrics\Examples\FinanceStatistics; -use App\AdminAgent\Metrics\Examples\ProductStatistics; use App\Common\OrderStatus; use App\Common\PayType; use App\Models\Order; diff --git a/app/AdminSupplier/Controllers/MyBiddingProductController.php b/app/AdminSupplier/Controllers/MyBiddingProductController.php index 383a6da..ab69f64 100755 --- a/app/AdminSupplier/Controllers/MyBiddingProductController.php +++ b/app/AdminSupplier/Controllers/MyBiddingProductController.php @@ -5,12 +5,11 @@ namespace App\AdminSupplier\Controllers; use App\Common\ProductStatus; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminSupplier\Repositories\Demand; use Dcat\Admin\Admin; use Dcat\Admin\Grid; use Dcat\Admin\Http\Controllers\AdminController; use App\Traits\DemandTraits; -use Dcat\Admin\Repositories\EloquentRepository; class MyBiddingProductController extends AdminController { diff --git a/app/AdminSupplier/Controllers/MyDemandProductController.php b/app/AdminSupplier/Controllers/MyDemandProductController.php index de1024d..8f42998 100755 --- a/app/AdminSupplier/Controllers/MyDemandProductController.php +++ b/app/AdminSupplier/Controllers/MyDemandProductController.php @@ -2,13 +2,11 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Actions\Grid\DemandConfirm; -use App\AdminAgent\Lazys\DemandBiddingLazys; use App\Common\ProductStatus; use App\Models\AgentProduct; use App\Models\Product; use App\Traits\ResponseHelper; -use App\AdminAgent\Repositories\Demand; +use App\AdminSupplier\Repositories\Demand; use App\Models\DemandBidding; use Dcat\Admin\Admin; use Dcat\Admin\Form; diff --git a/app/AdminSupplier/Controllers/ProductStatisticsController.php b/app/AdminSupplier/Controllers/ProductStatisticsController.php index 8ef902e..77d4c8e 100755 --- a/app/AdminSupplier/Controllers/ProductStatisticsController.php +++ b/app/AdminSupplier/Controllers/ProductStatisticsController.php @@ -2,11 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Tools\DataReportDate; -use App\AdminAgent\Metrics\Examples\FinanceStatistics; -use App\AdminAgent\Metrics\Examples\OrderStatistics; use App\AdminSupplier\Metrics\Examples\ProductStatistics; -use App\AdminAgent\Metrics\Examples\UserStatistics; use App\Common\OrderStatus; use App\Common\ProductStatus; use App\Models\AgentProduct; diff --git a/app/AdminSupplier/Controllers/WithdrawalAlipayController.php b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php index bda9fd6..ff194d8 100755 --- a/app/AdminSupplier/Controllers/WithdrawalAlipayController.php +++ b/app/AdminSupplier/Controllers/WithdrawalAlipayController.php @@ -2,7 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Repositories\WithdrawalAlipay; +use App\AdminSupplier\Repositories\WithdrawalAlipay; use App\Common\StatementType; use App\Models\Agent; use App\Models\Supplier; diff --git a/app/AdminSupplier/Controllers/WorkorderController.php b/app/AdminSupplier/Controllers/WorkorderController.php index 2bca5a5..1023808 100755 --- a/app/AdminSupplier/Controllers/WorkorderController.php +++ b/app/AdminSupplier/Controllers/WorkorderController.php @@ -2,7 +2,7 @@ namespace App\AdminSupplier\Controllers; -use App\AdminAgent\Repositories\Workorder; +use App\AdminSupplier\Repositories\Workorder; use App\Http\Controllers\Controller; use App\Models\Agent; use App\Models\AgentProductItem; diff --git a/app/AdminSupplier/Lazys/DemandBiddingLazys.php b/app/AdminSupplier/Lazys/DemandBiddingLazys.php index 306efd5..d0876c6 100644 --- a/app/AdminSupplier/Lazys/DemandBiddingLazys.php +++ b/app/AdminSupplier/Lazys/DemandBiddingLazys.php @@ -3,8 +3,8 @@ namespace App\AdminSupplier\Lazys; -use App\AdminAgent\Extensions\Grid\ChooseDemand; -use App\AdminAgent\Repositories\DemandBidding; +use App\AdminSupplier\Extensions\Grid\ChooseDemand; +use App\AdminSupplier\Repositories\DemandBidding; use App\Models\Demand; use App\Traits\DemandTraits; use Dcat\Admin\Grid; diff --git a/app/AdminSupplier/Renderable/SelectProduct.php b/app/AdminSupplier/Renderable/SelectProduct.php index ad6c093..755f07b 100644 --- a/app/AdminSupplier/Renderable/SelectProduct.php +++ b/app/AdminSupplier/Renderable/SelectProduct.php @@ -2,7 +2,6 @@ namespace App\AdminSupplier\Renderable; use App\Common\ProductStatus; -use App\AdminAgent\Repositories\Product; use App\Models\DemandProduct; use Dcat\Admin\Admin; use Dcat\Admin\Grid; diff --git a/app/AdminSupplier/Repositories/Workorder.php b/app/AdminSupplier/Repositories/Workorder.php new file mode 100755 index 0000000..b5cd4f3 --- /dev/null +++ b/app/AdminSupplier/Repositories/Workorder.php @@ -0,0 +1,16 @@ +