链街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.
 
 
 
 

89 lines
3.1 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;
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);
}
return Grid::make($model, function (Grid $grid) {
$grid->column('id','ID');
$grid->column('user_id','配送员姓名');
$grid->column('global_order_id','订单编号');
$grid->column('market_id','下单市场');
$grid->column('created_at','下单时间')->display(function($createdAt){
return date('Y-m-d H:i:s',$createdAt);;
});
$grid->column('status','状态')
->using(
[]
)
->label(
config('label.status_label')
);
$grid->column('created_at')->display(function($createdAt){
return date('Y-m-d H:i:s',$createdAt);
});
// 搜索
$grid->filter(function (Grid\Filter $filter){
$userTypeList = Type::USER_TYPE_LIST;
$moneyTypeList = Type::MONEY_TYPE_LIST;
$sourceTYpeList = Type::SOURCE_TYPE_LIST;
unset($userTypeList[0],$moneyTypeList[0]);
$filter->equal('id','流水表ID')->width(3);
$filter->equal('user_id','账户ID')->width(3);
$filter->equal('current_balance','账户余额')->width(3);
$filter->equal('money','流水金额')->width(3);
$filter->equal('source_id','关联流水ID')->width(3);
$filter->equal('money_type','流水类型')->select($userTypeList)->width(4);
$filter->equal('user_type','账户类型')->select($moneyTypeList)->width(4);
$filter->equal('source_type','关联类型')->select($sourceTYpeList)->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,
];
}
}