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.
101 lines
3.0 KiB
101 lines
3.0 KiB
<?php
|
|
|
|
namespace App\Admin\Controllers;
|
|
|
|
use App\Models\OrderNotify;
|
|
use Dcat\Admin\Form;
|
|
use Dcat\Admin\Grid;
|
|
use Dcat\Admin\Http\Controllers\AdminController;
|
|
use Dcat\Admin\Show;
|
|
use Illuminate\Support\Str;
|
|
|
|
class OrderNotifyController extends AdminController
|
|
{
|
|
/**
|
|
* Make a grid builder.
|
|
*
|
|
* @return Grid
|
|
*/
|
|
protected function grid()
|
|
{
|
|
return Grid::make(new OrderNotify(), function (Grid $grid) {
|
|
$grid->model()->orderBy('id', 'desc');
|
|
|
|
$grid->column('id')->sortable();
|
|
$grid->column('order_id');
|
|
$grid->column('state')
|
|
->using(admin_trans('order.options.state'))
|
|
->label([
|
|
0 => 'primary',
|
|
1 => 'warning',
|
|
2 => 'success',
|
|
3 => 'danger',
|
|
4 => 'gray',
|
|
]);
|
|
$grid->column('push_time');
|
|
$grid->column('response_time');
|
|
$grid->column('response_code');
|
|
$grid->column('response_body')->display(fn($v) => e(Str::limit($v, 15)))->width('15%');
|
|
$grid->column('push_duration')->display(function ($v) {
|
|
if ($this->response_code === null) {
|
|
return '';
|
|
}
|
|
return ($v / 1000).'秒';
|
|
});
|
|
|
|
$grid->disableCreateButton();
|
|
$grid->disableEditButton();
|
|
$grid->disableDeleteButton();
|
|
$grid->disableBatchDelete();
|
|
|
|
$grid->filter(function (Grid\Filter $filter) {
|
|
$filter->equal('order_id')->width(3);
|
|
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a show builder.
|
|
*
|
|
* @param mixed $id
|
|
*
|
|
* @return Show
|
|
*/
|
|
protected function detail($id)
|
|
{
|
|
return Show::make($id, new OrderNotify(), function (Show $show) {
|
|
$show->disableEditButton();
|
|
$show->disableDeleteButton();
|
|
$show->field('id');
|
|
$show->field('order_id');
|
|
$show->field('state')->using(admin_trans('order.options.state'));
|
|
$show->field('push_time');
|
|
$show->field('push_body')->unescape()->as(function ($v) {
|
|
parse_str($v, $r);
|
|
return '推送数据:<pre>'.e($v).'</pre><br/>PHP数组:<pre>'.var_export($r, true).'</pre>';
|
|
});
|
|
$show->field('response_time');
|
|
$show->field('response_code');
|
|
$show->field('response_body')->unescape()->as(fn($v) => '<pre>'.e($v).'</pre>');
|
|
$show->field('push_duration')->as(function ($v) {
|
|
if ($this->response_code === null) {
|
|
return '';
|
|
}
|
|
return ($v / 1000).'秒';
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Make a form builder.
|
|
*
|
|
* @return Form
|
|
*/
|
|
protected function form()
|
|
{
|
|
return Form::make(new OrderNotify(), function (Form $form) {
|
|
$form->display('id');
|
|
});
|
|
}
|
|
}
|