链街Dcat后台
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.

164 lines
4.9 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\LanzuMpWithdraw;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Admin;
  8. use Dcat\Admin\Controllers\AdminController;
  9. use App\Models\MpBalance;
  10. class LanzuMpWithdrawController extends AdminController
  11. {
  12. /**
  13. * Make a grid builder.
  14. *
  15. * @return Grid
  16. */
  17. protected function grid()
  18. {
  19. return Grid::make(new LanzuMpWithdraw(['mpInfo']), function (Grid $grid) {
  20. $grid->id->sortable();
  21. $grid->column('mpInfo.name','服务商名字');
  22. $grid->money;
  23. $grid->status('提现状态')->using([-1=>'拒绝',0=>'审核中',1=>'通过'])
  24. ->label([-1=>'danger',0=>'default',1=>'success']);
  25. $grid->created_at;
  26. $grid->filter(function (Grid\Filter $filter) {
  27. $filter->equal('id');
  28. });
  29. $grid->actions(function (Grid\Displayers\Actions $actions) {
  30. $actions->disableDelete();
  31. // $actions->disableEdit();
  32. $actions->disableQuickEdit();
  33. $actions->disableView();
  34. });
  35. });
  36. }
  37. /**
  38. * Make a show builder.
  39. *
  40. * @param mixed $id
  41. *
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. return Show::make($id, new LanzuMpWithdraw(['mpInfo']), function (Show $show) {
  47. $show->id;
  48. $show->mp_id;
  49. $show->column('服务商名称','mpInfo.name');
  50. $show->money;
  51. $show->status;
  52. $show->created_at;
  53. $show->updated_at;
  54. });
  55. }
  56. /**
  57. * Make a form builder.
  58. *
  59. * @return Form
  60. */
  61. protected function lanzu_bis_form(){
  62. //管理员或者lanzu_bis操作
  63. return Form::make(new LanzuMpWithdraw(['mpInfo']), function (Form $form) {
  64. $form->footer(function ($footer) {
  65. // 去掉`查看`checkbox
  66. $footer->disableViewCheck();
  67. // 去掉`继续编辑`checkbox
  68. $footer->disableEditingCheck();
  69. // 去掉`继续创建`checkbox
  70. $footer->disableCreatingCheck();
  71. });
  72. $form->tools(function (Form\Tools $tools) {
  73. // 去掉跳转详情页按钮
  74. $tools->disableView();
  75. // 去掉删除按钮
  76. $tools->disableDelete();
  77. $tools->disableList();
  78. });
  79. // dd($form->model()->mp_info['name']);
  80. $mpName = $form->model()->mp_info['name'];
  81. //dd( $mpName);
  82. $form->display('id');
  83. $form->text('mp_id','服务商ID')->disable();
  84. $form->display('','服务商名')->value($mpName);
  85. $form->text('money','提现金额')->disable()->required();
  86. $form->hidden('is_operated');
  87. $form->saving(function (Form $form) {
  88. $form->is_operated = 1;
  89. });
  90. if($form->model()->is_operated){
  91. $status = '';
  92. if($form->model()->status==1){
  93. $status = '审核通过';
  94. }
  95. if($form->model()->status==-1){
  96. $status = '拒绝';
  97. }
  98. $form->display('','审核状态')->value($status);
  99. $form->disableSubmitButton();
  100. $form->disableResetButton();
  101. }else{
  102. $form->radio('status')->options([1 => '通过审核', -1=> '拒绝'])->default(-1);;
  103. }
  104. });
  105. }
  106. protected function form()
  107. {
  108. $current_user = Admin::user();
  109. if(!$current_user->isRole('lanzu_mp')){
  110. return $this->lanzu_bis_form();
  111. }
  112. //如果是服务商角色
  113. $mp = MpBalance::where('user_id',$current_user->id)
  114. ->where('user_type',1)->first();
  115. $balance = 0;
  116. if($mp){
  117. $balance = $mp->balance;
  118. }
  119. return Form::make(new LanzuMpWithdraw(), function (Form $form) use($current_user,$balance) {
  120. $form->footer(function ($footer) {
  121. // 去掉`查看`checkbox
  122. $footer->disableViewCheck();
  123. // 去掉`继续编辑`checkbox
  124. $footer->disableEditingCheck();
  125. // 去掉`继续创建`checkbox
  126. $footer->disableCreatingCheck();
  127. });
  128. $form->tools(function (Form\Tools $tools) {
  129. // 去掉跳转列表按钮
  130. $tools->disableList();
  131. });
  132. $form->display('id');
  133. $form->hidden('mp_id')->value($current_user->id);
  134. $form->text('balance','当前可提现余额')->value($balance)->disable()->help('当前可提现金额');
  135. $form->number('money','提现金额')->required();
  136. $form->ignore(['balance']);
  137. //$form->text('status');
  138. });
  139. }
  140. }