Page MenuHomePhorge

D5427.1775348837.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D5427.1775348837.diff

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
@@ -7,7 +7,9 @@
use App\Jobs\Wallet\CheckJob;
use App\User;
use App\Wallet;
+use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JoinClause;
+use Illuminate\Support\Facades\DB;
class ChargeCommand extends Command
{
@@ -60,10 +62,20 @@
->whereNot('users.status', '&', User::STATUS_DEGRADED | User::STATUS_SUSPENDED)
->cursor();
} else {
- // Get all wallets, excluding deleted accounts
+ // Get all wallets...
$wallets = Wallet::select('wallets.id')
->join('users', 'users.id', '=', 'wallets.user_id')
+ // exclude deleted accounts
->whereNull('users.deleted_at')
+ // exclude wallets w/o entitlements (but not wallets with a negative balance)
+ ->where(static function ($query) {
+ $query->where('balance', '<', 0)
+ ->orWhereExists(static function (Builder $query) {
+ $query->select(DB::raw(1))
+ ->from('entitlements')
+ ->whereColumn('entitlements.wallet_id', 'wallets.id');
+ });
+ })
->cursor();
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 5, 12:27 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18831703
Default Alt Text
D5427.1775348837.diff (1 KB)

Event Timeline