WxUsedRefundController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace App\Admin\Controllers\Used;
  3. use App\Admin\Repositories\WxRefund;
  4. use App\Wen\Utils\Settings;
  5. use Dcat\Admin\Form;
  6. use Dcat\Admin\Grid;
  7. use Dcat\Admin\Show;
  8. use Dcat\Admin\Http\Controllers\AdminController;
  9. class WxUsedRefundController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. $app_coin_name = Settings::get('app_coin_name', '硬币');
  19. return Grid::make(new WxRefund(), function (Grid $grid) use ($app_coin_name){
  20. $grid->simplePaginate();
  21. $grid->model()->where('goods_type', 6)->orderBy('id', 'desc');
  22. $grid->column('id')->sortable();
  23. $grid->column('users', '头像')->display(function ($v) {
  24. return '<img src="' . ($this->user['user_avatar'] ?? Settings::get('img_default', 'https://img.mini.minisns.cn/icons/dafault.png')) . '" style="border-radius:50px;width:30px;" />';
  25. })->width('50px');
  26. $grid->column('user')->display(function ($v) {
  27. if($v && $v['user_name']){
  28. return '<a target="_blank" href="'.admin_url('users?id='.$v['id']).'">'.$v['user_name'].'</a>' ?? '用户已删除';
  29. }
  30. return '用户已删除';
  31. })->width('100px');
  32. // $grid->column('order_good_id');
  33. // $grid->column('order_id');
  34. $grid->column('goods_id');
  35. $grid->column('product_id');
  36. $grid->column('amount')->display(function ($v) use ($app_coin_name){
  37. if($this->credit_type == 1){
  38. return '¥'.$v;
  39. }else{
  40. return $v.$app_coin_name;
  41. }
  42. })->sortable();
  43. $grid->column('created_at');
  44. $grid->column('updated_at')->sortable();
  45. $grid->filter(function (Grid\Filter $filter) {
  46. $filter->equal('id');
  47. });
  48. $grid->disableBatchActions();
  49. $grid->disableActions();
  50. $grid->disableCreateButton();
  51. });
  52. }
  53. /**
  54. * Make a show builder.
  55. *
  56. * @param mixed $id
  57. *
  58. * @return Show
  59. */
  60. protected function detail($id)
  61. {
  62. return Show::make($id, new WxRefund(), function (Show $show) {
  63. $show->field('id');
  64. $show->field('user_id');
  65. $show->field('order_good_id');
  66. $show->field('order_id');
  67. $show->field('goods_id');
  68. $show->field('product_id');
  69. $show->field('amount');
  70. $show->field('created_at');
  71. $show->field('updated_at');
  72. $show->disableDeleteButton();
  73. $show->disableEditButton();
  74. });
  75. }
  76. /**
  77. * Make a form builder.
  78. *
  79. * @return Form
  80. */
  81. protected function form()
  82. {
  83. return Form::make(new WxRefund(), function (Form $form) {
  84. $form->display('id');
  85. $form->text('user_id');
  86. $form->text('order_good_id');
  87. $form->text('order_id');
  88. $form->text('goods_id');
  89. $form->text('product_id');
  90. $form->text('amount');
  91. $form->display('created_at');
  92. $form->display('updated_at');
  93. $form->deleting(function (Form $form){
  94. global $__MINI_GLOBAL_TENANT_ID__;
  95. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  96. return $form->response()->error('权限不足,不可以删除其他分站对象');
  97. }
  98. });
  99. });
  100. }
  101. }