FundLogController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace App\Module\Fund\AdminControllers;
  3. use App\Module\Fund\Services\AccountService;
  4. use Spatie\RouteAttributes\Attributes\Resource;
  5. use UCore\DcatAdmin\AdminController;
  6. use UCore\DcatAdmin\FilterHelper;
  7. use UCore\DcatAdmin\GridHelper;
  8. use Dcat\Admin\Form;
  9. use Dcat\Admin\Grid;
  10. use Dcat\Admin\Show;
  11. use App\Module\Fund\Models\FundModel;
  12. use App\Module\Fund\Repositorys\FundLogRepository as FundLog;
  13. use UCore\DcatAdmin\Metrics\Examples\Link;
  14. /**
  15. * 资金日志
  16. */
  17. #[Resource('fund_log', names: 'dcat.admin.fund_log')]
  18. class FundLogController extends AdminController
  19. {
  20. protected $title='资金日志';
  21. /**
  22. * Make a grid builder.
  23. *
  24. * @return Grid
  25. */
  26. protected function grid()
  27. {
  28. return Grid::make(new FundLog(['user']), function (Grid $grid) {
  29. $helper = new GridHelper($grid,$this);
  30. $helper->disableAll();
  31. $helper->columnIdDesc();
  32. $helper->columnUserIDInfo();
  33. $helper->columnUsingKv('fund_id', AccountService::getFundsDesc(),'账户');
  34. $helper->columnc1000('amount','变化');
  35. $helper->columnc1000('before_balance','之前');
  36. $helper->columnc1000('later_balance','之后');
  37. $helper->columnAt('create_time');
  38. $grid->column('remark','备注');
  39. $grid->column('operate_type','关联')->expand(function(){
  40. $url = admin_url('404');
  41. $title = '未知';
  42. if($this->operate_type == 'Circulation'){
  43. $url = admin_route('fund_circulation.index',['id'=>$this->operate_id]);
  44. $title = '流转';
  45. }
  46. if($this->operate_type == 'Trade'){
  47. // dd($this);
  48. if(substr($this->operate_id,0,5) == 'order'){
  49. // 订单
  50. $url = admin_route('order.index',['id'=>substr($this->operate_id,6) ]);
  51. $title = '订单';
  52. }
  53. if(substr($this->operate_id,0,8) == 'Transfer'){
  54. // 订单
  55. $url = admin_route('transfer.index',['id'=>substr($this->operate_id,9) ]);
  56. $title = '划转';
  57. }
  58. }
  59. // dump($url,$this->operate_id);
  60. $link = new Link($title,$url);
  61. return $link;
  62. });
  63. // amount remark create_time later_balance before_balance
  64. $grid->filter(function (Grid\Filter $filter) {
  65. $filter->equal('user_id');
  66. $helper= new FilterHelper($filter,$this);
  67. $helper->equalRadio('fund_id',AccountService::getFundsDesc(),'账户');
  68. $filter->expand();
  69. $filter->panel();
  70. });
  71. $grid->disableCreateButton();
  72. $grid->actions(function (Grid\Displayers\Actions $actions) {
  73. // $actions->disableDelete();
  74. $actions->disableView();
  75. });
  76. });
  77. }
  78. /**
  79. * Make a show builder.
  80. *
  81. * @param mixed $id
  82. *
  83. * @return Show
  84. */
  85. protected function detail($id)
  86. {
  87. return Show::make($id, new FundLog(), function (Show $show) {
  88. $show->field('id');
  89. $show->field('service_id');
  90. $show->field('title');
  91. $show->field('title_i18n');
  92. });
  93. }
  94. /**
  95. * Make a form builder.
  96. *
  97. * @return Form
  98. */
  99. protected function form()
  100. {
  101. return Form::make(new FundLog(), function (Form $form) {
  102. });
  103. }
  104. }