支付宝记账本
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.
 
 

135 lines
4.5 KiB

<?php
namespace App\Admin\Controllers;
use App\Models\Merchant;
use App\Models\Order;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
class OrderController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new Order(), function (Grid $grid) {
$grid->model()->orderBy('id', 'desc');
$grid->column('id')->sortable();
$grid->column('if_code');
$grid->column('mch_no');
$grid->column('app_id');
$grid->column('mch_order_no');
$grid->column('entry_type');
$grid->column('amount')->display(fn ($v) => bcdiv($v, 100, 2));
$grid->column('currency');
$grid->column('account_no');
$grid->column('account_name');
$grid->column('bank_name');
$grid->column('bank_code');
$grid->column('client_ip');
$grid->column('transfer_desc');
$grid->column('notify_url');
$grid->column('ext_param');
$grid->column('channel_extra');
$grid->column('state')
->using(admin_trans('order.options.state'))
->dot([
0 => 'primary',
1 => 'warning',
2 => 'success',
3 => 'danger',
4 => 'gray',
]);
$grid->column('transfer_id');
$grid->column('channel_order_no');
$grid->column('success_time');
$grid->column('created_at');
$grid->column('updated_at')->sortable();
$grid->disableCreateButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableBatchDelete();
$grid->showColumnSelector();
$grid->hideColumns(['if_code', 'currency', 'bank_name', 'bank_code', 'client_ip', 'transfer_desc', 'notify_url', 'ext_param', 'channel_extra', 'channel_order_no']);
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('id')->width(3);
$filter->equal('mch_no')->width(3)->select(Merchant::getAllMerchant());
$filter->equal('app_id')->width(3);
$filter->equal('mch_order_no')->width(3);
$filter->equal('account_no')->width(3);
$filter->equal('state')->width(3)->select(admin_trans('order.options.state'));
$filter->between('success_time')->width(3)->datetime(['timeZone' => config('app.timezone')]);
$filter->between('created_at')->width(3)->datetime();
});
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new Order(), function (Show $show) {
$show->disableEditButton();
$show->disableDeleteButton();
$show->field('id');
$show->field('if_code');
$show->field('mch_no');
$show->field('app_id');
$show->field('mch_order_no');
$show->field('entry_type');
$show->field('amount')->as(fn ($v) => bcdiv($v, 100, 2));
$show->field('currency');
$show->field('account_no');
$show->field('account_name');
$show->field('bank_name');
$show->field('bank_code');
$show->field('client_ip');
$show->field('transfer_desc');
$show->field('notify_url');
$show->field('ext_param');
$show->field('channel_extra');
$show->field('state')
->using(admin_trans('order.options.state'))
->dot([
0 => 'primary',
1 => 'warning',
2 => 'success',
3 => 'danger',
4 => 'gray',
]);
$show->field('transfer_id');
$show->field('channel_order_no');
$show->field('success_time');
$show->field('created_at');
$show->field('updated_at');
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new Order(), function (Form $form) {
$form->disableViewButton();
$form->display('id');
});
}
}