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

  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Merchant;
  4. use App\Models\Order;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class OrderController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new Order(), function (Grid $grid) {
  19. $grid->model()->orderBy('id', 'desc');
  20. $grid->column('id')->sortable();
  21. $grid->column('if_code');
  22. $grid->column('mch_no');
  23. $grid->column('app_id');
  24. $grid->column('mch_order_no');
  25. $grid->column('entry_type');
  26. $grid->column('amount')->display(fn ($v) => bcdiv($v, 100, 2));
  27. $grid->column('currency');
  28. $grid->column('account_no');
  29. $grid->column('account_name');
  30. $grid->column('bank_name');
  31. $grid->column('bank_code');
  32. $grid->column('client_ip');
  33. $grid->column('transfer_desc');
  34. $grid->column('notify_url');
  35. $grid->column('ext_param');
  36. $grid->column('channel_extra');
  37. $grid->column('state')
  38. ->using(admin_trans('order.options.state'))
  39. ->dot([
  40. 0 => 'primary',
  41. 1 => 'warning',
  42. 2 => 'success',
  43. 3 => 'danger',
  44. 4 => 'gray',
  45. ]);
  46. $grid->column('transfer_id');
  47. $grid->column('channel_order_no');
  48. $grid->column('success_time');
  49. $grid->column('created_at');
  50. $grid->column('updated_at')->sortable();
  51. $grid->disableCreateButton();
  52. $grid->disableEditButton();
  53. $grid->disableDeleteButton();
  54. $grid->disableBatchDelete();
  55. $grid->showColumnSelector();
  56. $grid->hideColumns(['if_code', 'currency', 'bank_name', 'bank_code', 'client_ip', 'transfer_desc', 'notify_url', 'ext_param', 'channel_extra', 'channel_order_no']);
  57. $grid->filter(function (Grid\Filter $filter) {
  58. $filter->equal('id')->width(3);
  59. $filter->equal('mch_no')->width(3)->select(Merchant::getAllMerchant());
  60. $filter->equal('app_id')->width(3);
  61. $filter->equal('mch_order_no')->width(3);
  62. $filter->equal('account_no')->width(3);
  63. $filter->equal('state')->width(3)->select(admin_trans('order.options.state'));
  64. $filter->between('success_time')->width(3)->datetime(['timeZone' => config('app.timezone')]);
  65. $filter->between('created_at')->width(3)->datetime();
  66. });
  67. });
  68. }
  69. /**
  70. * Make a show builder.
  71. *
  72. * @param mixed $id
  73. *
  74. * @return Show
  75. */
  76. protected function detail($id)
  77. {
  78. return Show::make($id, new Order(), function (Show $show) {
  79. $show->disableEditButton();
  80. $show->disableDeleteButton();
  81. $show->field('id');
  82. $show->field('if_code');
  83. $show->field('mch_no');
  84. $show->field('app_id');
  85. $show->field('mch_order_no');
  86. $show->field('entry_type');
  87. $show->field('amount')->as(fn ($v) => bcdiv($v, 100, 2));
  88. $show->field('currency');
  89. $show->field('account_no');
  90. $show->field('account_name');
  91. $show->field('bank_name');
  92. $show->field('bank_code');
  93. $show->field('client_ip');
  94. $show->field('transfer_desc');
  95. $show->field('notify_url');
  96. $show->field('ext_param');
  97. $show->field('channel_extra');
  98. $show->field('state')
  99. ->using(admin_trans('order.options.state'))
  100. ->dot([
  101. 0 => 'primary',
  102. 1 => 'warning',
  103. 2 => 'success',
  104. 3 => 'danger',
  105. 4 => 'gray',
  106. ]);
  107. $show->field('transfer_id');
  108. $show->field('channel_order_no');
  109. $show->field('success_time');
  110. $show->field('created_at');
  111. $show->field('updated_at');
  112. });
  113. }
  114. /**
  115. * Make a form builder.
  116. *
  117. * @return Form
  118. */
  119. protected function form()
  120. {
  121. return Form::make(new Order(), function (Form $form) {
  122. $form->disableViewButton();
  123. $form->display('id');
  124. });
  125. }
  126. }