@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('transactions', function (Blueprint $table) { |
|
| 16 | + Schema::create('transactions', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->morphs('holder'); |
| 19 | 19 | $table->unsignedBigInteger('wallet_id')->comment('钱包 id'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('wallets', function (Blueprint $table) { |
|
| 16 | + Schema::create('wallets', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->morphs('holder'); |
| 19 | 19 | $table->string('currency', 20)->default('CNY')->comment('货币'); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('transfers', function (Blueprint $table) { |
|
| 16 | + Schema::create('transfers', function(Blueprint $table) { |
|
| 17 | 17 | $table->bigIncrements('id'); |
| 18 | 18 | $table->morphs('from'); |
| 19 | 19 | $table->unsignedBigInteger('from_wallet_id'); |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | public static function get(int $key): int |
| 27 | 27 | { |
| 28 | - return (int)(static::$rows[$key] ?? 0); |
|
| 28 | + return (int) (static::$rows[$key] ?? 0); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | protected function change(string $type, int $amount, ?array $meta, bool $confirmed): Transaction |
| 68 | 68 | { |
| 69 | - return DB::transaction(function () use ($type, $amount, $meta, $confirmed) { |
|
| 69 | + return DB::transaction(function() use ($type, $amount, $meta, $confirmed) { |
|
| 70 | 70 | if ($confirmed) { |
| 71 | 71 | $this->addBalance($amount); |
| 72 | 72 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | $this->exists or $this->save(); |
| 106 | 106 | |
| 107 | 107 | if (!WalletProxy::has($this->getKey())) { |
| 108 | - WalletProxy::set($this->getKey(), (int)($balance ?? 0)); |
|
| 108 | + WalletProxy::set($this->getKey(), (int) ($balance ?? 0)); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | return WalletProxy::get($this->getKey()); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $wallet = $transferable->getReceiptWallet($this->currency); |
| 129 | 129 | |
| 130 | - return DB::transaction(function () use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 130 | + return DB::transaction(function() use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 131 | 131 | $fee = Tax::fee($wallet, $amount); |
| 132 | 132 | $withdraw = $this->withdraw($amount + $fee, $meta); |
| 133 | 133 | $deposit = $wallet->deposit($amount, $meta); |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | { |
| 187 | 187 | $wallet = $transferable->getReceiptWallet($this->currency); |
| 188 | 188 | |
| 189 | - return DB::transaction(function () use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 189 | + return DB::transaction(function() use ($transferable, $amount, $wallet, $meta, $action) { |
|
| 190 | 190 | $fee = Tax::fee($wallet, $amount); |
| 191 | 191 | $withdraw = $this->forceWithdraw($amount + $fee, $meta); |
| 192 | 192 | $deposit = $wallet->deposit($amount, $meta); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | public function coefficient(string $currency = ''): float |
| 215 | 215 | { |
| 216 | - return config('wallet.coefficient.' . $currency , 100.); |
|
| 216 | + return config('wallet.coefficient.' . $currency, 100.); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | public function getFeePercent(): float |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | trait CanPay { |
| 12 | 12 | public function pay(Product $product, string $action = Transfer::ACTION_PAID, bool $force = false): Transfer |
| 13 | 13 | { |
| 14 | - if (! $product->canBePaid($this, $force)) { |
|
| 14 | + if (!$product->canBePaid($this, $force)) { |
|
| 15 | 15 | throw new ProductEnded(trans('wallet::errors.product_stock')); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -60,12 +60,12 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $transfer = $this->paid($product, $action); |
| 62 | 62 | |
| 63 | - if (! $transfer) { |
|
| 63 | + if (!$transfer) { |
|
| 64 | 64 | throw (new ModelNotFoundException()) |
| 65 | 65 | ->setModel(config('wallet.transfer.model')); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return \DB::transaction(function () use ($transfer) { |
|
| 68 | + return \DB::transaction(function() use ($transfer) { |
|
| 69 | 69 | $transfer->withdraw->update([ |
| 70 | 70 | 'confirmed' => false, |
| 71 | 71 | ]); |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function getWallet(string $currency): ?Wallet |
| 21 | 21 | { |
| 22 | - if (! in_array($currency, config('wallet.currencies'))) { |
|
| 22 | + if (!in_array($currency, config('wallet.currencies'))) { |
|
| 23 | 23 | throw new CurrencyInvalid(trans('wallet::errors.currency_unsupported')); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $wallet = $this->wallets()->where('currency', $currency)->first(); |
| 27 | 27 | |
| 28 | - if (! $wallet) { |
|
| 28 | + if (!$wallet) { |
|
| 29 | 29 | $wallet = $this->wallets()->create([ |
| 30 | 30 | 'currency' => $currency, |
| 31 | 31 | 'balance' => 0 |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | { |
| 65 | 65 | $transfer = $this->paid($product, $action); |
| 66 | 66 | |
| 67 | - if (! $transfer) { |
|
| 67 | + if (!$transfer) { |
|
| 68 | 68 | throw (new ModelNotFoundException()) |
| 69 | 69 | ->setModel(config('wallet.transfer.model')); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - return \DB::transaction(function () use ($transfer) { |
|
| 72 | + return \DB::transaction(function() use ($transfer) { |
|
| 73 | 73 | $transfer->withdraw->update([ |
| 74 | 74 | 'confirmed' => false, |
| 75 | 75 | ]); |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | |
| 20 | 20 | if (\function_exists('config_path')) { |
| 21 | 21 | $this->publishes([ |
| 22 | - __DIR__ . '/../config/wallet.php' => config_path('wallet.php') |
|
| 22 | + __DIR__ . '/../config/wallet.php' => config_path('wallet.php') |
|
| 23 | 23 | ], 'wallet-config'); |
| 24 | 24 | } |
| 25 | 25 | |