updates
This commit is contained in:
parent
5efb04aac0
commit
0883842750
|
|
@ -19,16 +19,19 @@ class ReferralEarning
|
|||
|
||||
public string $referral_start_date = ''; // The date this referral was registered.
|
||||
|
||||
public string $qualifies_after = ''; // The date the payout qualifies after (5 months / 1 year)
|
||||
|
||||
public string $period_ending = ''; // The Date this set relates to. ie 2024-07-31 = July 2024
|
||||
|
||||
public string $account_key = '';
|
||||
|
||||
public string $payout_status = ''; //pending //qualified //paidout
|
||||
public string $payout_status = 'pending'; //pending //qualified //paidout //invalid
|
||||
|
||||
public float $gross_amount = 0;
|
||||
|
||||
public float $commission_amount = 0;
|
||||
|
||||
public string $notes = '';
|
||||
/**
|
||||
* __construct
|
||||
*
|
||||
|
|
|
|||
|
|
@ -131,8 +131,8 @@ class CreateAccount
|
|||
|
||||
(new \Modules\Admin\Jobs\Account\NinjaUser([], $sp035a66))->handle();
|
||||
|
||||
if($sp794f3f->referral_code && Ninja::isHosted())
|
||||
\Modules\Admin\Jobs\Account\NewReferredAccount::dispatch($sp794f3f->key);
|
||||
// if($sp794f3f->referral_code && Ninja::isHosted()) //2024-11-29 - pausing on this.
|
||||
// \Modules\Admin\Jobs\Account\NewReferredAccount::dispatch($sp794f3f->key);
|
||||
}
|
||||
|
||||
VersionCheck::dispatch();
|
||||
|
|
|
|||
|
|
@ -716,6 +716,36 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
|
||||
}
|
||||
|
||||
public function findLatestReferral(string $account_key)
|
||||
{
|
||||
|
||||
return = collect($this->referral_earning)
|
||||
->filter(function ($earning) use ($account_key) {
|
||||
return $earning->account_key === $account_key;
|
||||
})
|
||||
->sortByDesc('period_ending')
|
||||
->first();
|
||||
|
||||
}
|
||||
|
||||
public function updateReferral(ReferralEarning $entity)
|
||||
{
|
||||
|
||||
$earnings = collect($this->referral_earnings);
|
||||
|
||||
$updated_earnings = $earnings->map(function ($earning) use ($entity) {
|
||||
if ($earning->account_key === $entity->account_key &&
|
||||
$earning->period_ending === $entity->period_ending) {
|
||||
return $entity;
|
||||
}
|
||||
|
||||
return $earning;
|
||||
})->toArray();
|
||||
|
||||
$this->referral_earnings = $updated_earnings;
|
||||
|
||||
$this->save();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue