1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Admin\Actions\Form;
- use App\Models\User;
- use App\Models\UserEpisodesRecord;
- use App\Models\UserWithdraw;
- use Carbon\Carbon;
- use Dcat\Admin\Contracts\LazyRenderable;
- use Dcat\Admin\Traits\LazyWidget;
- use Dcat\Admin\Widgets\Form;
- class WithdrawReview extends Form implements LazyRenderable
- {
- use LazyWidget;
- public function handle(array $input)
- {
- $status = $input['status'];
- try {
- $withdraw = UserWithdraw::find($input['id']);
- if ($status > 0) {
- $withdraw->status = $status;
- // 审核通过或者拒绝
- if($status == 1 || $status == 3){
- $withdraw->review_at = Carbon::now()->toDateTimeString();
- }
- if($status == 2){
- $withdraw->withdraw_at = Carbon::now()->toDateTimeString();
- }
- $withdraw->save();
- }
- // 驳回返还收益
- if($withdraw->status == 3){
- $user = User::find($withdraw->user_id);
- $user->income = $user->income + $withdraw->price;
- $user->save();
- }
- } catch (\Exception $exception) {
- return $this->response()->error($exception->getMessage());
- }
- return $this->response()->success('success')->refresh();
- }
- public function form()
- {
- $id = isset($this->payload['id']) ? $this->payload['id'] : 0;
- $this->hidden('id')->value($id);
- $this->radio('status', '审核结果')
- ->options(config('global.withdraw_status'))->default(1);
- $this->disableResetButton();
- }
- }
|