WithdrawReview.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Admin\Actions\Form;
  3. use App\Models\User;
  4. use App\Models\UserEpisodesRecord;
  5. use App\Models\UserWithdraw;
  6. use Dcat\Admin\Contracts\LazyRenderable;
  7. use Dcat\Admin\Traits\LazyWidget;
  8. use Dcat\Admin\Widgets\Form;
  9. class WithdrawReview extends Form implements LazyRenderable
  10. {
  11. use LazyWidget;
  12. public function handle(array $input)
  13. {
  14. $status = $input['status'];
  15. try {
  16. $withdraw = UserWithdraw::find($input['id']);
  17. if ($status > 0) {
  18. $withdraw->status = $status;
  19. $withdraw->save();
  20. }
  21. // 驳回返还收益
  22. if($withdraw->status == 3){
  23. $user = User::find($withdraw->user_id);
  24. $user->income = $user->income + $withdraw->price;
  25. $user->save();
  26. }
  27. } catch (\Exception $exception) {
  28. return $this->response()->error($exception->getMessage());
  29. }
  30. return $this->response()->success('success')->refresh();
  31. }
  32. public function form()
  33. {
  34. $id = isset($this->payload['id']) ? $this->payload['id'] : 0;
  35. $this->hidden('id')->value($id);
  36. $this->radio('status', '审核结果')
  37. ->options(config('global.withdraw_status'))->default(1);
  38. $this->disableResetButton();
  39. }
  40. }