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/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/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 => '流拍' ];