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

139 lines
4.6 KiB

5 months ago
5 months ago
5 months ago
  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('errCode');
  49. $grid->column('errMsg');
  50. $grid->column('success_time');
  51. $grid->column('created_at');
  52. $grid->column('updated_at')->sortable();
  53. $grid->disableCreateButton();
  54. $grid->disableEditButton();
  55. $grid->disableDeleteButton();
  56. $grid->disableBatchDelete();
  57. $grid->showColumnSelector();
  58. $grid->hideColumns(['if_code', 'currency', 'bank_name', 'bank_code', 'client_ip', 'transfer_desc', 'notify_url', 'ext_param', 'channel_extra', 'channel_order_no', 'errCode', 'errMsg']);
  59. $grid->filter(function (Grid\Filter $filter) {
  60. $filter->equal('id')->width(3);
  61. $filter->equal('mch_no')->width(3)->select(Merchant::getAllMerchant());
  62. $filter->equal('app_id')->width(3);
  63. $filter->equal('mch_order_no')->width(3);
  64. $filter->equal('account_no')->width(3);
  65. $filter->equal('state')->width(3)->select(admin_trans('order.options.state'));
  66. $filter->between('success_time')->width(3)->datetime(['timeZone' => config('app.timezone')]);
  67. $filter->between('created_at')->width(3)->datetime();
  68. });
  69. });
  70. }
  71. /**
  72. * Make a show builder.
  73. *
  74. * @param mixed $id
  75. *
  76. * @return Show
  77. */
  78. protected function detail($id)
  79. {
  80. return Show::make($id, new Order(), function (Show $show) {
  81. $show->disableEditButton();
  82. $show->disableDeleteButton();
  83. $show->field('id');
  84. $show->field('if_code');
  85. $show->field('mch_no');
  86. $show->field('app_id');
  87. $show->field('mch_order_no');
  88. $show->field('entry_type');
  89. $show->field('amount')->as(fn ($v) => bcdiv($v, 100, 2));
  90. $show->field('currency');
  91. $show->field('account_no');
  92. $show->field('account_name');
  93. $show->field('bank_name');
  94. $show->field('bank_code');
  95. $show->field('client_ip');
  96. $show->field('transfer_desc');
  97. $show->field('notify_url');
  98. $show->field('ext_param');
  99. $show->field('channel_extra');
  100. $show->field('state')
  101. ->using(admin_trans('order.options.state'))
  102. ->dot([
  103. 0 => 'primary',
  104. 1 => 'warning',
  105. 2 => 'success',
  106. 3 => 'danger',
  107. 4 => 'gray',
  108. ]);
  109. $show->field('transfer_id');
  110. $show->field('channel_order_no');
  111. $show->field('errCode');
  112. $show->field('errMsg');
  113. $show->field('success_time');
  114. $show->field('created_at');
  115. $show->field('updated_at');
  116. });
  117. }
  118. /**
  119. * Make a form builder.
  120. *
  121. * @return Form
  122. */
  123. protected function form()
  124. {
  125. return Form::make(new Order(), function (Form $form) {
  126. $form->disableViewButton();
  127. $form->display('id');
  128. });
  129. }
  130. }