feat: 切换 schema dump 基线并增强返点结算与管理校验
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\AdminUser;
|
||||
use App\Models\TicketItem;
|
||||
use App\Lottery\DrawStatus;
|
||||
use App\Models\JackpotPool;
|
||||
use App\Models\OddsVersion;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Models\PlayerWallet;
|
||||
use App\Models\DrawResultItem;
|
||||
@@ -17,6 +18,7 @@ use App\Events\JackpotBurstBroadcast;
|
||||
use App\Services\Draw\DrawResultViewService;
|
||||
use App\Models\JackpotContribution;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use App\Lottery\ConfigVersionStatus;
|
||||
use Database\Seeders\CurrencySeeder;
|
||||
use Database\Seeders\PlayTypeSeeder;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
@@ -292,6 +294,62 @@ test('jackpot contribution respects switch and minimum bet threshold', function
|
||||
expect(JackpotContribution::query()->count())->toBe(0);
|
||||
});
|
||||
|
||||
test('jackpot contribution uses total bet amount instead of actual deduct amount', function (): void {
|
||||
jackpotUpsertPool([
|
||||
'currency_code' => 'NPR',
|
||||
'current_amount' => 0,
|
||||
'contribution_rate' => '0.1000',
|
||||
'trigger_threshold' => 1,
|
||||
'payout_rate' => '1.0000',
|
||||
'force_trigger_draw_gap' => 0,
|
||||
'min_bet_amount' => 10_000,
|
||||
'status' => 1,
|
||||
'last_trigger_draw_id' => null,
|
||||
]);
|
||||
|
||||
$player = jackpotTestPlayer('jprebate');
|
||||
$draw = jackpotOpenDraw('20260511-902A');
|
||||
|
||||
$oddsVersionId = OddsVersion::query()
|
||||
->where('status', ConfigVersionStatus::Active->value)
|
||||
->value('id');
|
||||
expect($oddsVersionId)->not->toBeNull();
|
||||
|
||||
DB::table('odds_items')
|
||||
->where('version_id', $oddsVersionId)
|
||||
->where('play_code', 'straight')
|
||||
->update(['rebate_rate' => 0.01]);
|
||||
|
||||
DB::table('player_rebate_profiles')->insert([
|
||||
'player_id' => $player->id,
|
||||
'game_type' => 'straight',
|
||||
'rebate_rate' => 0.005,
|
||||
'extra_rebate_rate' => 0.002,
|
||||
'inherit_from_agent' => false,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer dev:'.$player->id)
|
||||
->postJson('/api/v1/ticket/place', [
|
||||
'draw_id' => '20260511-902A',
|
||||
'currency_code' => 'NPR',
|
||||
'client_trace_id' => 'jp-rebate-base',
|
||||
'lines' => [['number' => '1234', 'play_code' => 'straight', 'amount' => 10_000]],
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('data.summary.total_actual_deduct', 9_830);
|
||||
|
||||
$contribution = JackpotContribution::query()->firstOrFail();
|
||||
$item = TicketItem::query()->firstOrFail();
|
||||
$pool = JackpotPool::query()->where('currency_code', 'NPR')->firstOrFail();
|
||||
|
||||
expect((int) $item->total_bet_amount)->toBe(10_000)
|
||||
->and((int) $item->actual_deduct_amount)->toBe(9_830)
|
||||
->and((int) $contribution->contribution_amount)->toBe(1_000)
|
||||
->and((int) $pool->current_amount)->toBe(1_000);
|
||||
});
|
||||
|
||||
test('jackpot bursts by configured play combination trigger before threshold', function (): void {
|
||||
Event::fake([JackpotBurstBroadcast::class]);
|
||||
config([
|
||||
|
||||
Reference in New Issue
Block a user