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.
102 lines
3.8 KiB
102 lines
3.8 KiB
<?php
|
|
namespace App\Admin\Renderable;
|
|
|
|
use Dcat\Admin\Grid;
|
|
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;
|
|
$startTime = $this->start_time ?? null;
|
|
$endTime = $this->end_time ?? null;
|
|
$marketId = $this->market_id ?? 0;
|
|
if(empty($startTime) && empty($endTime)){
|
|
$startTime = date('Y-m-d', time());
|
|
$endTime = date('Y-m-d', time());
|
|
}
|
|
$model = OrderMainModel::where('type', OrderMainModel::ORDER_TYPE_ONLINE)
|
|
->where('shipping_type', OrderMainModel::ORDER_SHIPPING_TYPE_MARKET)
|
|
->whereIn('state',OrderMainModel::ORDER_STATE_FINISH)
|
|
->where('created_at','>=',strtotime('2020-10-01 00:00:00'));;
|
|
if($horsemanId > 0){
|
|
$model->where('horseman_id',$horsemanId);
|
|
}
|
|
if($startTime){
|
|
$startTime = $startTime.' 00:00:00';
|
|
$model->where('created_at','>=',strtotime($startTime));
|
|
}
|
|
if($endTime){
|
|
$endTime = $endTime.' 23:59:59';
|
|
$model->where('created_at','<=',strtotime($endTime));
|
|
}
|
|
if($marketId > 0){
|
|
$model->where('market_id',$marketId);
|
|
}
|
|
return Grid::make($model, function (Grid $grid) use($marketId){
|
|
$marketList = MarketModel::getMarketArray();
|
|
|
|
$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, $marketId){
|
|
|
|
$filter->equal('user_id','下单用户懒ID')->width(3);
|
|
|
|
$filter->equal('global_order_id','订单编号')->width(3);
|
|
if(!$marketId){
|
|
$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;
|
|
$startTime = $this->payload['start_time'] ?? request()->input('start_time', null);
|
|
$endTime = $this->payload['end_time'] ?? request()->input('end_time', null);
|
|
$marketId = $this->payload['market_id'] ?? 0;
|
|
|
|
return [
|
|
'horseman_id' => $horsemanId,
|
|
'start_time' => $startTime,
|
|
'end_time' => $endTime,
|
|
'market_id' => $marketId,
|
|
];
|
|
}
|
|
}
|