链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

78 lines
2.6 KiB

<?php
namespace App\Admin\Renderable;
use Dcat\Admin\Grid;
use App\Admin\Common\Type;
use Dcat\Admin\Grid\LazyRenderable;
use App\Models\ImsCjdcOrderMain as OrderMainModel;
use App\Models\v3\Market as MarketModel;
class OrderDeliveryById extends LazyRenderable
{
protected $title = '配送记录';
public function grid(): Grid
{
// 获取外部传递的参数
$horsemanId = $this->horseman_id ?? 0;
$model = new OrderMainModel();
if($horsemanId > 0){
$model->where('horseman_id',$horsemanId)->where('type',1)->where('shipping_type',1);
}
// dd($model->where('horseman_id',$horsemanId));
return Grid::make($model, function (Grid $grid) {
$marketList = MarketModel::getMarketArray();
$grid->column('horseman_id','配送员ID');
// $grid->column('user_id','配送员姓名');
$grid->column('global_order_id','订单编号');
$grid->column('market_id','下单市场')->display(function($marketId) use($marketList){
return $marketList[$marketId] ?? '';
});
$grid->column('state','状态')
->using(
OrderMainModel::STATE_LIST
);
$grid->column('created_at','下单时间')->display(function($createdAt){
return date('Y-m-d H:i:s',$createdAt);
});
// 搜索
$grid->filter(function (Grid\Filter $filter) use($marketList){
$filter->equal('user_id','下单用户懒ID')->width(3);
$filter->equal('global_order_id','订单编号')->width(3);
$filter->equal('market_id','下单市场')->select($marketList)->width(4);
$filter->whereBetween('created_at',function($q){
$start = $this->input['start'] ?? null;
$end = $this->input['end'] ?? null;
if($start !== null){
$q->where('created_at','>=',strtotime($start));
}
if($end !== null){
$q->where('created_at','<=',strtotime($end));
}
})->datetime()->width(7);
});
$grid->model()->orderBy('id','desc');
// 每页10条
$grid->paginate(10);
$grid->disableActions();
$grid->disableRowSelector();
});
}
public function default()
{
// 获取外部传递的参数
$horsemanId = $this->payload['horseman_id'] ?? 0;
return [
'horseman_id' => $horsemanId,
];
}
}