Incentive (E1): Gleichstand nach "zuerst erreicht", Neupartner zaehlen im Monat der Zahlung
- Rangliste: bei gleichen Punkten bestaetigte Teilnahme vor anonym, danach wer den Stand zuerst erreicht hat (letzter zaehlender Neupartner bzw. Neuabo laut Tracking-Tabellen), zuletzt die Teilnehmer-ID. Vorher entschied bei Gleichstand die Datenbankreihenfolge (Teilnahmebedingungen Recruiting-Challenge, Punkt 6). - Neupartner zaehlen fuer Incentives ab ihrer ersten Kontozahlung (users.partner_paid_at), wie in der Statistik (Kundenentscheid 16.09.2026), nicht ab dem Bestelldatum: Live-Tracking, naechtliche Reparatur und Neuaufbau nutzen dieselbe Regel (IncentiveTracker::newPartnerCountedAt). Wer am 29.09. bestellt und am 01.10. zahlt, zaehlt in der Challenge. Montenegro ist abgeschlossen; gegen die Live-Kopie tauschen dort nur Plaetze ab 81, und der naechtliche Lauf entfernt keine bestehenden Trackings. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a50be6fd51
commit
1885402a6c
5 changed files with 207 additions and 29 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Incentive;
|
||||
use App\Models\IncentiveNewPartner;
|
||||
use App\Models\IncentiveParticipant;
|
||||
use App\Services\Incentive\IncentiveTracker;
|
||||
use App\User;
|
||||
|
|
@ -132,3 +133,84 @@ it('stimmt mit der Leaderboard-Anzeigereihenfolge ueberein', function () use ($m
|
|||
|
||||
expect($displayOrder)->toBe([1, 2, 3, 4]);
|
||||
});
|
||||
|
||||
describe('Gleichstand: wer den Stand zuerst erreicht hat (Recruiting-Challenge, Punkt 6)', function () use ($makeIncentiveRankingUser) {
|
||||
$challengeWithTie = function () use ($makeIncentiveRankingUser): array {
|
||||
$incentive = Incentive::factory()->create([
|
||||
'points_partner_onetime' => 1,
|
||||
'points_abo_onetime' => 0,
|
||||
'min_direct_partners' => 0,
|
||||
'min_customer_abos' => 0,
|
||||
]);
|
||||
|
||||
$participant = function (array $registrations) use ($incentive, $makeIncentiveRankingUser): IncentiveParticipant {
|
||||
$participant = IncentiveParticipant::factory()->qualified()->create([
|
||||
'incentive_id' => $incentive->id,
|
||||
'user_id' => $makeIncentiveRankingUser()->id,
|
||||
'accepted_terms_at' => now(),
|
||||
'total_points' => count($registrations),
|
||||
]);
|
||||
foreach ($registrations as $registeredAt) {
|
||||
IncentiveNewPartner::create([
|
||||
'participant_id' => $participant->id,
|
||||
'user_id' => $makeIncentiveRankingUser()->id,
|
||||
'registered_at' => $registeredAt,
|
||||
]);
|
||||
}
|
||||
|
||||
return $participant;
|
||||
};
|
||||
|
||||
return [$incentive, $participant];
|
||||
};
|
||||
|
||||
it('setzt bei gleicher Anzahl den vor, dessen letzter Neupartner frueher kam', function () use ($challengeWithTie) {
|
||||
[$incentive, $participant] = $challengeWithTie();
|
||||
|
||||
// Beide haben 2 Neupartner; der spaeter angelegte hat die Anzahl frueher erreicht.
|
||||
$reachedLater = $participant(['2026-10-02 10:00:00', '2026-11-20 09:00:00']);
|
||||
$reachedEarlier = $participant(['2026-10-05 10:00:00', '2026-10-30 18:00:00']);
|
||||
|
||||
IncentiveTracker::updateRanking($incentive);
|
||||
|
||||
expect($reachedEarlier->refresh()->rank)->toBe(1)
|
||||
->and($reachedLater->refresh()->rank)->toBe(2);
|
||||
});
|
||||
|
||||
it('laesst die Anzahl vor dem Zeitpunkt entscheiden', function () use ($challengeWithTie) {
|
||||
[$incentive, $participant] = $challengeWithTie();
|
||||
|
||||
$fewerButEarly = $participant(['2026-10-01 08:00:00']);
|
||||
$moreButLate = $participant(['2026-12-01 08:00:00', '2027-01-30 08:00:00']);
|
||||
|
||||
IncentiveTracker::updateRanking($incentive);
|
||||
|
||||
expect($moreButLate->refresh()->rank)->toBe(1)
|
||||
->and($fewerButEarly->refresh()->rank)->toBe(2);
|
||||
});
|
||||
|
||||
it('haelt bestaetigte Teilnahme weiterhin vor dem Zeitpunkt', function () use ($challengeWithTie) {
|
||||
[$incentive, $participant] = $challengeWithTie();
|
||||
|
||||
$anonymousEarly = $participant(['2026-10-01 08:00:00']);
|
||||
$anonymousEarly->update(['accepted_terms_at' => null]);
|
||||
$confirmedLate = $participant(['2026-12-01 08:00:00']);
|
||||
|
||||
IncentiveTracker::updateRanking($incentive);
|
||||
|
||||
expect($confirmedLate->refresh()->rank)->toBe(1)
|
||||
->and($anonymousEarly->refresh()->rank)->toBe(2);
|
||||
});
|
||||
|
||||
it('vergibt bei vollstaendigem Gleichstand stabil nach Teilnehmer-ID', function () use ($challengeWithTie) {
|
||||
[$incentive, $participant] = $challengeWithTie();
|
||||
|
||||
$first = $participant(['2026-10-10 10:00:00']);
|
||||
$second = $participant(['2026-10-10 10:00:00']);
|
||||
|
||||
IncentiveTracker::updateRanking($incentive);
|
||||
|
||||
expect($first->refresh()->rank)->toBe(1)
|
||||
->and($second->refresh()->rank)->toBe(2);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue