diff --git a/app/AdminAgent/Controllers/DemandController.php b/app/AdminAgent/Controllers/DemandController.php
index e062f21..c22a9cf 100755
--- a/app/AdminAgent/Controllers/DemandController.php
+++ b/app/AdminAgent/Controllers/DemandController.php
@@ -179,41 +179,41 @@ class DemandController extends AdminController
});
}
- public function binding()
- {
- $demandBiddingId = request('demand_bidding_id',0);
- $demandBidding = DemandBidding::find($demandBiddingId);
- if (empty($demandBidding)) {
- return false;
- }
-
- $demand = \App\Models\Demand::find($demandBidding->demand_id);
-
- if (empty($demand)) {
- return false;
- }
-
- 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->save();
- }
- DB::commit();
- } catch (\Exception $e) {
- Log::error('选中竞标失败::'.$e->getTraceAsString());
- DB::rollBack();
- return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
- }
- return back();
- }
+ //public function binding()
+ //{
+ // $demandBiddingId = request('demand_bidding_id',0);
+ // $demandBidding = DemandBidding::find($demandBiddingId);
+ // if (empty($demandBidding)) {
+ // return false;
+ // }
+ //
+ // $demand = \App\Models\Demand::find($demandBidding->demand_id);
+ //
+ // if (empty($demand)) {
+ // return false;
+ // }
+ //
+ // 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->save();
+ // }
+ // DB::commit();
+ // } catch (\Exception $e) {
+ // Log::error('选中竞标失败::'.$e->getTraceAsString());
+ // DB::rollBack();
+ // return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
+ // }
+ // return back();
+ //}
}
diff --git a/app/AdminAgent/Extensions/Grid/ChooseDemand.php b/app/AdminAgent/Extensions/Grid/ChooseDemand.php
new file mode 100644
index 0000000..f76d1cc
--- /dev/null
+++ b/app/AdminAgent/Extensions/Grid/ChooseDemand.php
@@ -0,0 +1,85 @@
+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->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/AdminAgent/Lazys/DemandBiddingLazys.php b/app/AdminAgent/Lazys/DemandBiddingLazys.php
index 6ace0f9..d8121a7 100644
--- a/app/AdminAgent/Lazys/DemandBiddingLazys.php
+++ b/app/AdminAgent/Lazys/DemandBiddingLazys.php
@@ -3,6 +3,7 @@
namespace App\AdminAgent\Lazys;
+use App\AdminAgent\Extensions\Grid\ChooseDemand;
use App\AdminAgent\Repositories\DemandBidding;
use App\Models\Demand;
use App\Traits\DemandTraits;
@@ -27,7 +28,7 @@ class DemandBiddingLazys extends LazyRenderable
return $demand->state == 1;
})
->then(function (Grid\Column $column) {
- $column->append('选中竞标');
+ $column->append(new ChooseDemand($this->id));
})
->if(function () use ($demand){
return $demand->state == 2;
diff --git a/app/AdminAgent/routes.php b/app/AdminAgent/routes.php
index 0e45856..33fe648 100644
--- a/app/AdminAgent/routes.php
+++ b/app/AdminAgent/routes.php
@@ -36,7 +36,5 @@ Route::group([
$router->resource('article/list', 'ArticleController');
$router->resource('setting', 'SettingController');
$router->resource('channel/list', 'ChannelController');
-
- //api
- $router->any('/api/demand/binding', 'DemandController@binding');
+
});
diff --git a/app/AdminSupplier/Controllers/DemandController.php b/app/AdminSupplier/Controllers/DemandController.php
index 0e42df9..4a3a52c 100755
--- a/app/AdminSupplier/Controllers/DemandController.php
+++ b/app/AdminSupplier/Controllers/DemandController.php
@@ -2,7 +2,7 @@
namespace App\AdminSupplier\Controllers;
-use App\AdminAgent\Lazys\DemandBiddingLazys;
+use App\AdminSupplier\Lazys\DemandBiddingLazys;
use App\Models\AgentProduct;
use App\Models\DemandProduct;
use App\Models\Product;
@@ -172,54 +172,54 @@ class DemandController extends AdminController
});
}
- public function binding()
- {
- $demandBiddingId = request('demand_bidding_id',0);
- $demandBidding = DemandBidding::find($demandBiddingId);
- if (empty($demandBidding)) {
- return false;
- }
-
- $demand = \App\Models\Demand::find($demandBidding->demand_id);
-
- if (empty($demand)) {
- return false;
- }
-
- 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();
- //将产品绑给代理商
- $demandProduct = DemandProduct::find($demand->demand_product_id);
- $product = new Product();
-
- $product->supplier_id = $demandProduct->supplier_id;
- $product->category_id = $demandProduct->category_id;
- $product->title = $demandProduct->title;
- $product->price = $demandBidding->price;
- $product->original_price = $demandBidding->price;
- $product->pictures = $demandProduct->pictures;
- $product->stock = $demand->stock;
- $product->know = $demandProduct->know;
- $product->content = $demandProduct->content;
- $product->agent_id = $demandBidding->bidding_user_id;
- $product->save();
-
- $demand->product_id = $product->id;
- $demand->save();
- DB::commit();
- } catch (\Exception $e) {
- Log::error('选中竞标失败::'.$e->getTraceAsString());
- DB::rollBack();
- return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
- }
- return back();
- }
+ //public function binding()
+ //{
+ // $demandBiddingId = request('demand_bidding_id',0);
+ // $demandBidding = DemandBidding::find($demandBiddingId);
+ // if (empty($demandBidding)) {
+ // return false;
+ // }
+ //
+ // $demand = \App\Models\Demand::find($demandBidding->demand_id);
+ //
+ // if (empty($demand)) {
+ // return false;
+ // }
+ //
+ // 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();
+ // //将产品绑给代理商
+ // $demandProduct = DemandProduct::find($demand->demand_product_id);
+ // $product = new Product();
+ //
+ // $product->supplier_id = $demandProduct->supplier_id;
+ // $product->category_id = $demandProduct->category_id;
+ // $product->title = $demandProduct->title;
+ // $product->price = $demandBidding->price;
+ // $product->original_price = $demandBidding->price;
+ // $product->pictures = $demandProduct->pictures;
+ // $product->stock = $demand->stock;
+ // $product->know = $demandProduct->know;
+ // $product->content = $demandProduct->content;
+ // $product->agent_id = $demandBidding->bidding_user_id;
+ // $product->save();
+ //
+ // $demand->product_id = $product->id;
+ // $demand->save();
+ // DB::commit();
+ // } catch (\Exception $e) {
+ // Log::error('选中竞标失败::'.$e->getTraceAsString());
+ // DB::rollBack();
+ // return $this->jsonFail(1001,'选中竞标失败,稍后重试或联系管理员!'.$e->getMessage());
+ // }
+ // return back();
+ //}
}
diff --git a/app/AdminSupplier/Extensions/Grid/ChooseDemand.php b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php
new file mode 100644
index 0000000..72cdbd2
--- /dev/null
+++ b/app/AdminSupplier/Extensions/Grid/ChooseDemand.php
@@ -0,0 +1,99 @@
+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 false;
+ }
+
+ $demand = \App\Models\Demand::find($demandBidding->demand_id);
+
+ if (empty($demand)) {
+ return false;
+ }
+
+ 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();
+ //将产品绑给代理商
+ $demandProduct = DemandProduct::find($demand->demand_product_id);
+ $product = new Product();
+
+ $product->supplier_id = $demandProduct->supplier_id;
+ $product->category_id = $demandProduct->category_id;
+ $product->title = $demandProduct->title;
+ $product->price = $demandBidding->price;
+ $product->original_price = $demandBidding->price;
+ $product->pictures = $demandProduct->pictures;
+ $product->stock = $demand->stock;
+ $product->know = $demandProduct->know;
+ $product->content = $demandProduct->content;
+ $product->agent_id = $demandBidding->bidding_user_id;
+ $product->save();
+
+ $demand->product_id = $product->id;
+ $demand->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/AdminSupplier/Lazys/DemandBiddingLazys.php b/app/AdminSupplier/Lazys/DemandBiddingLazys.php
new file mode 100644
index 0000000..22de287
--- /dev/null
+++ b/app/AdminSupplier/Lazys/DemandBiddingLazys.php
@@ -0,0 +1,48 @@
+model()->where('demand_id',$demandId);
+ $grid->column('id');
+ $grid->column('price','出价');
+ $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/AdminSupplier/routes.php b/app/AdminSupplier/routes.php
index 6c01c34..9cc76b4 100644
--- a/app/AdminSupplier/routes.php
+++ b/app/AdminSupplier/routes.php
@@ -25,6 +25,4 @@ Route::group([
$router->resource('demand_product', 'DemandProductController');
$router->resource('my_demand_product', 'MyDemandProductController');
$router->resource('my_bidding_product', 'MyBiddingProductController');
- //api
- $router->any('/api/demand/binding', 'DemandController@binding');
});