WxShopRefundController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  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 WxShopRefundController 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()->whereNotIn('goods_type', [6,7])->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');
  37. $grid->column('amount')->display(function ($v) use ($app_coin_name){
  38. if($this->credit_type == 1){
  39. return '¥'.$v;
  40. }else{
  41. return $v.$app_coin_name;
  42. }
  43. })->sortable();
  44. $grid->column('created_at');
  45. $grid->column('updated_at')->sortable();
  46. $grid->filter(function (Grid\Filter $filter) {
  47. $filter->equal('id');
  48. });
  49. $grid->disableBatchActions();
  50. $grid->disableActions();
  51. $grid->disableCreateButton();
  52. });
  53. }
  54. /**
  55. * Make a show builder.
  56. *
  57. * @param mixed $id
  58. *
  59. * @return Show
  60. */
  61. protected function detail($id)
  62. {
  63. return Show::make($id, new WxRefund(), function (Show $show) {
  64. $show->field('id');
  65. $show->field('user_id');
  66. $show->field('order_good_id');
  67. $show->field('order_id');
  68. $show->field('goods_id');
  69. $show->field('product_id');
  70. $show->field('amount');
  71. $show->field('created_at');
  72. $show->field('updated_at');
  73. });
  74. }
  75. /**
  76. * Make a form builder.
  77. *
  78. * @return Form
  79. */
  80. protected function form()
  81. {
  82. return Form::make(new WxRefund(), function (Form $form) {
  83. $form->display('id');
  84. $form->text('user_id');
  85. $form->text('order_good_id');
  86. $form->text('order_id');
  87. $form->text('goods_id');
  88. $form->text('product_id');
  89. $form->text('amount');
  90. $form->display('created_at');
  91. $form->display('updated_at');
  92. $form->deleting(function (Form $form){
  93. global $__MINI_GLOBAL_TENANT_ID__;
  94. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  95. return $form->response()->error('权限不足,不可以删除其他分站对象');
  96. }
  97. });
  98. });
  99. }
  100. }