PointCirculationController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace App\Module\Point\AdminControllers;
  3. use App\Module\Point\AdminControllers\Helper\FilterHelper;
  4. use App\Module\Point\AdminControllers\Helper\GridHelper;
  5. use App\Module\Point\AdminControllers\Helper\ShowHelper;
  6. use App\Module\Point\Repositorys\PointCirculationRepository;
  7. use Dcat\Admin\Grid;
  8. use Dcat\Admin\Show;
  9. use Spatie\RouteAttributes\Attributes\Resource;
  10. use UCore\DcatAdmin\AdminController;
  11. /**
  12. * 种植点数流转控制器
  13. *
  14. * 路由: /admin/point/point-circulation
  15. * 菜单: 积分管理 -> 点数流转
  16. * 功能: 查看用户种植点数账户间的流转记录
  17. */
  18. #[Resource('point-point-circulation', names: 'admin.point.point-circulation', except: ['create', 'store', 'edit', 'update', 'destroy'])]
  19. class PointCirculationController extends AdminController
  20. {
  21. /**
  22. * 数据仓库
  23. */
  24. protected string $repository = PointCirculationRepository::class;
  25. /**
  26. * 页面标题
  27. */
  28. protected $title = '点数流转';
  29. /**
  30. * 列表页面
  31. */
  32. protected function grid(): Grid
  33. {
  34. return Grid::make(new PointCirculationRepository(), function (Grid $grid) {
  35. $gridHelper = new GridHelper($grid,$this);
  36. $grid->column('id', 'ID')->sortable();
  37. $gridHelper->columnCirculationInfo();
  38. $gridHelper->columnPoints('amount', '流转积分');
  39. $grid->column('re_type', '关联类型');
  40. $grid->column('re_id', '关联ID');
  41. $gridHelper->columnStatus();
  42. $grid->column('remark', '备注')->limit(30);
  43. $gridHelper->columnTimestamp('create_time', '创建时间');
  44. $grid->filter(function (Grid\Filter $filter) {
  45. $filterHelper = new FilterHelper($filter,$this);
  46. $filterHelper->equalUserId();
  47. $filter->equal('from_point_id', '源积分类型')->select([
  48. 1 => '经验积分',
  49. 2 => '成就积分',
  50. 3 => '活动积分',
  51. 4 => '签到积分',
  52. 5 => '推荐积分',
  53. ]);
  54. $filter->equal('to_point_id', '目标积分类型')->select([
  55. 1 => '经验积分',
  56. 2 => '成就积分',
  57. 3 => '活动积分',
  58. 4 => '签到积分',
  59. 5 => '推荐积分',
  60. ]);
  61. $filterHelper->equalReType();
  62. $filterHelper->equalStatus();
  63. $filterHelper->betweenTimestamp('create_time', '创建时间');
  64. $filterHelper->likeRemark();
  65. });
  66. $grid->disableCreateButton();
  67. $grid->disableEditButton();
  68. $grid->disableDeleteButton();
  69. $grid->actions(function (Grid\Displayers\Actions $actions) {
  70. $actions->disableEdit();
  71. $actions->disableDelete();
  72. });
  73. $grid->tools(function (Grid\Tools $tools) {
  74. $tools->append('<a href="/admin/point/point" class="btn btn-sm btn-primary">用户积分</a>');
  75. });
  76. });
  77. }
  78. /**
  79. * 详情页面
  80. */
  81. protected function detail($id): Show
  82. {
  83. return Show::make($id, new PointCirculationRepository(), function (Show $show) {
  84. $showHelper = new ShowHelper($show,$this);
  85. $show->field('id', 'ID');
  86. $showHelper->fieldCirculationInfo();
  87. $showHelper->fieldPoints('amount', '流转积分');
  88. $show->field('re_type', '关联类型');
  89. $show->field('re_id', '关联ID');
  90. $showHelper->fieldStatus();
  91. $show->field('remark', '备注');
  92. $showHelper->fieldTimestamp('create_time', '创建时间');
  93. $showHelper->fieldTimestamp('update_time', '更新时间');
  94. $show->disableEditButton();
  95. $show->disableDeleteButton();
  96. });
  97. }
  98. /**
  99. * 禁用表单页面
  100. */
  101. protected function form()
  102. {
  103. return redirect()->back()->with('error', '积分流转记录不允许编辑');
  104. }
  105. }