11 changed files with 205 additions and 24 deletions
-
19app/AdminAgent/Controllers/DemandController.php
-
2app/AdminGuide/Controllers/DemandBiddingController.php
-
26app/AdminGuide/Controllers/DemandController.php
-
4app/AdminGuide/Controllers/MyDemandProductController.php
-
2app/AdminGuide/Controllers/WorkorderController.php
-
86app/AdminGuide/Extensions/Grid/ChooseDemand.php
-
48app/AdminGuide/Lazys/DemandBiddingLazys.php
-
16app/AdminGuide/Repositories/Workorder.php
-
22app/AdminSupplier/Controllers/DemandController.php
-
2app/AdminSupplier/Extensions/Grid/ChooseDemand.php
-
2app/Traits/DemandTraits.php
@ -0,0 +1,86 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\AdminGuide\Extensions\Grid; |
||||
|
|
||||
|
use App\Models\AgentProduct; |
||||
|
use App\Models\DemandBidding; |
||||
|
use App\Traits\DemandTraits; |
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
use Illuminate\Http\Request; |
||||
|
use Illuminate\Support\Facades\DB; |
||||
|
use Illuminate\Support\Facades\Log; |
||||
|
|
||||
|
/** |
||||
|
* 供应商审核 |
||||
|
* Class AuditSupplier |
||||
|
* @package App\Admin\Extensions\Grid |
||||
|
*/ |
||||
|
class ChooseDemand extends RowAction |
||||
|
{ |
||||
|
private $id; |
||||
|
|
||||
|
public function __construct($biddingId = '') |
||||
|
{ |
||||
|
parent::__construct('选中竞标'); |
||||
|
$this->id = $biddingId; |
||||
|
$this->title = '选中竞标'; |
||||
|
} |
||||
|
|
||||
|
protected function html() |
||||
|
{ |
||||
|
$class = 'btn btn-sm btn-success'; |
||||
|
$this->appendHtmlAttribute('class', $class); |
||||
|
$this->defaultHtmlAttribute('href', 'javascript:;'); |
||||
|
|
||||
|
return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>"; |
||||
|
} |
||||
|
|
||||
|
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]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\AdminGuide\Lazys; |
||||
|
|
||||
|
use App\AdminGuide\Extensions\Grid\ChooseDemand; |
||||
|
use App\AdminGuide\Repositories\DemandBidding; |
||||
|
use App\Models\Demand; |
||||
|
use App\Traits\DemandTraits; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Grid\LazyRenderable; |
||||
|
use Illuminate\Support\Arr; |
||||
|
|
||||
|
class DemandBiddingLazys extends LazyRenderable |
||||
|
{ |
||||
|
public function grid(): Grid |
||||
|
{ |
||||
|
return Grid::make(new DemandBidding(['biddingUser']), function (Grid $grid) { |
||||
|
$demandId = request('demand_id',''); |
||||
|
$demand = Demand::find($demandId); |
||||
|
$grid->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('<span class="text-success">已中标</span>'); |
||||
|
} else { |
||||
|
$column->append('<span class="text-danger">未中标</span>'); |
||||
|
} |
||||
|
}); |
||||
|
$grid->column('created_at'); |
||||
|
$grid->disableActions(); |
||||
|
$grid->disableRowSelector(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\AdminGuide\Repositories; |
||||
|
|
||||
|
use App\Models\Workorder as Model; |
||||
|
use Dcat\Admin\Repositories\EloquentRepository; |
||||
|
|
||||
|
class Workorder extends EloquentRepository |
||||
|
{ |
||||
|
/** |
||||
|
* Model. |
||||
|
* |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $eloquentClass = Model::class; |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue