can('dcat.admin.wallet_logs.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); $walletService = new WalletService(); $walletService->changeBalance($user, $input['change_balance']??0, WalletLog::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', '充值金额')->symbol('¥')->default(0)->saving(function ($value) { return bcmul($value, 100); })->required(); $this->confirm('是否确认充值可提?', '提交后该动作无法逆转'); } }