can('dcat.admin.quota_v1_send_jobs.recharge'); } /** * Handle the form request. * * @param array $input * * @return mixed */ public function handle(array $input) { if (($input['change_balance'] ?? 0) <= 0) { return $this->response()->error('增加配额必须大于0'); } try { DB::beginTransaction(); //获取当前操作人; $adminUser = Admin::user(); $user = User::findOrFail($input['user_id'] ?? 0); $quotaV1Service = new QuotaV1Service(); $quotaV1Service->changeBalance($user, $input['change_balance'] ?? 0, QuotaV1Log::ACTION_ADMIN_RECHARGE, '后台增加', $adminUser); DB::commit(); } catch (Throwable $th) { DB::rollBack(); report($th); return $this->response()->error('操作失败:'.$th->getMessage()); } return $this->response() ->success(__('admin.update_succeeded')) ->refresh(); } /** * Build a form here. */ public function form() { $this->select('user_id', '用户手机号')->ajax(admin_route('api.users'))->required(); $this->currency('change_balance', '增加配额')->digits(3)->required(); $this->confirm('是否确认增加老配额?', '提交后该动作无法逆转'); } }