can('dcat.admin.dealers.wallet_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'); } $dealer = Dealer::findOrFail($this->payload['id']); try { DB::beginTransaction(); (new WalletService())->changeBalance( $dealer->user, $input['change_balance'], DealerWalletAction::Recharge, '充值', Admin::user() ); 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->currency('change_balance', '充值金额')->symbol('¥')->required(); $this->confirm('是否确认充值?', '提交后该动作无法逆转'); } }