Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F16221714
D4971.id14232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D4971.id14232.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,18 @@
}
$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)')
+ ->where('users.status', '=', '51')
+ ->cursor();
} else {
// Get all wallets, excluding deleted accounts
$wallets = \App\Wallet::select('wallets.id')
@@ -51,7 +63,15 @@
}
foreach ($wallets as $wallet) {
- \App\Jobs\WalletCheck::dispatch($wallet->id);
+ if ($this->option('dry')) {
+ \Log::debug("Dispatching job for wallet {$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
Sat, Oct 19, 12:21 PM (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9886029
Default Alt Text
D4971.id14232.diff (2 KB)
Attached To
Mode
D4971: --topup mode for wallet:charge
Attached
Detach File
Event Timeline
Log In to Comment