Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F118098551
D4971.1775621714.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D4971.1775621714.diff
View Options
diff --git a/src/app/Console/Commands/Wallet/ChargeCommand.php b/src/app/Console/Commands/Wallet/ChargeCommand.php
--- a/src/app/Console/Commands/Wallet/ChargeCommand.php
+++ b/src/app/Console/Commands/Wallet/ChargeCommand.php
@@ -11,14 +11,14 @@
*
* @var string
*/
- protected $signature = 'wallet:charge {wallet?}';
+ protected $signature = 'wallet:charge {--topup : Only top-up wallets} {--dry-run} {wallet?}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Charge wallets';
+ protected $description = 'Charge wallets, and trigger a topup on charged wallets.';
/**
* Execute the console command.
@@ -42,6 +42,22 @@
}
$wallets = [$wallet];
+ } elseif ($this->option('topup')) {
+ // Find wallets that need to be topped up
+ $wallets = \App\Wallet::select('wallets.id')
+ ->join('users', 'users.id', '=', 'wallets.user_id')
+ ->join('wallet_settings', function (\Illuminate\Database\Query\JoinClause $join) {
+ $join->on('wallet_settings.wallet_id', '=', 'wallets.id')
+ ->where('wallet_settings.key', '=', 'mandate_balance');
+ })
+ ->whereNull('users.deleted_at')
+ ->whereRaw('wallets.balance < (wallet_settings.value * 100)')
+ ->whereNot(
+ 'users.status',
+ '&',
+ \App\User::STATUS_DEGRADED | \App\User::STATUS_SUSPENDED | \App\User::STATUS_DELETED
+ )
+ ->cursor();
} else {
// Get all wallets, excluding deleted accounts
$wallets = \App\Wallet::select('wallets.id')
@@ -51,7 +67,15 @@
}
foreach ($wallets as $wallet) {
- \App\Jobs\WalletCheck::dispatch($wallet->id);
+ if ($this->option('dry-run')) {
+ $this->info($wallet->id);
+ } else {
+ if ($this->option('topup')) {
+ \App\Jobs\WalletCharge::dispatch($wallet->id);
+ } else {
+ \App\Jobs\WalletCheck::dispatch($wallet->id);
+ }
+ }
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 8, 4:15 AM (17 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18845717
Default Alt Text
D4971.1775621714.diff (2 KB)
Attached To
Mode
D4971: --topup mode for wallet:charge
Attached
Detach File
Event Timeline