feat(draw): 支持多玩法provider及本地化结算时区功能
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

- Draw相关控制器添加provider_code和provider_name字段支持
- 允许手动录入开奖批次时指定provider_code
- RNG开奖批次生成支持多provider,分别生成对应批次数据
- DrawPublishService和DrawManualResultService中支持基于provider_code管理开奖版本和发布流程
- DrawResultViewService调整,支持按provider汇总及筛选开奖结果
- Settlement处理逻辑调整,按provider区分待结算票据及批次,分开结算
- 结算期间管理相关服务支持使用站点本地结算时区计算开账建议和日期处理
- 增加AdminSite的settlement_timezone字段及相关请求验证和数据存取支持
- 优化AdminSettlementPeriod相关代码,防止存在未结清票据时关账
- Ticket明细返回接口添加结算时区信息,提升用户时间体验
- 多处查询排序和版本号处理改进,保证多provider数据正确顺序与一致性
This commit is contained in:
2026-07-09 15:48:21 +08:00
parent c6c10f1397
commit d4779660c8
38 changed files with 1121 additions and 271 deletions

View File

@@ -190,8 +190,116 @@ test('settlement period open hints does not suggest range overlapping occupied p
$this->withHeader('Authorization', 'Bearer '.$token)
->getJson('/api/v1/admin/settlement-periods/open-hints?admin_site_id='.$siteId)
->assertOk()
->assertJsonPath('data.suggested_start', '')
->assertJsonPath('data.suggested_end', '')
->assertJsonPath('data.suggested_start', '2026-07-01')
->assertJsonPath('data.suggested_end', '2026-07-08')
->assertJsonFragment(['2026-06-01'])
->assertJsonFragment(['2026-06-30']);
});
test('settlement period open hints uses site timezone for orphan activity dates', function (): void {
$siteId = (int) DB::table('admin_sites')->where('is_default', true)->value('id');
$siteCode = (string) DB::table('admin_sites')->where('id', $siteId)->value('code');
$rootId = (int) DB::table('agent_nodes')->where('admin_site_id', $siteId)->where('depth', 0)->value('id');
DB::table('admin_sites')->where('id', $siteId)->update([
'settlement_timezone' => 'Asia/Kathmandu',
]);
DB::table('settlement_periods')->insert([
'admin_site_id' => $siteId,
'period_start' => '2026-07-08 18:15:00',
'period_end' => '2026-07-09 18:14:59',
'status' => 'closed',
'created_at' => now(),
'updated_at' => now(),
]);
$player = Player::query()->create([
'site_code' => $siteCode,
'agent_node_id' => $rootId,
'site_player_id' => 'hints-orphan-player',
'username' => 'hints_orphan_player',
'nickname' => null,
'default_currency' => 'NPR',
'status' => 0,
]);
$draw = Draw::query()->create([
'draw_no' => 'DRAW-HINTS-ORPHAN',
'business_date' => '2026-07-09',
'sequence_no' => 1,
'status' => DrawStatus::Open->value,
'current_result_version' => 0,
'settle_version' => 0,
'is_reopened' => false,
]);
$orderId = (int) DB::table('ticket_orders')->insertGetId([
'order_no' => 'ORD-HINTS-ORPHAN',
'player_id' => $player->id,
'draw_id' => $draw->id,
'currency_code' => 'NPR',
'total_bet_amount' => 100,
'total_rebate_amount' => 0,
'total_actual_deduct' => 100,
'total_estimated_payout' => 0,
'status' => 'confirmed',
'submit_source' => 'h5',
'client_trace_id' => null,
'created_at' => now(),
'updated_at' => now(),
]);
$itemId = (int) DB::table('ticket_items')->insertGetId([
'ticket_no' => 'T-HINTS-ORPHAN',
'order_id' => $orderId,
'player_id' => $player->id,
'draw_id' => $draw->id,
'original_number' => null,
'normalized_number' => '1234',
'play_code' => 'big',
'dimension' => 2,
'digit_slot' => null,
'bet_mode' => null,
'unit_bet_amount' => 100,
'total_bet_amount' => 100,
'rebate_rate_snapshot' => 0,
'commission_rate_snapshot' => 0,
'actual_deduct_amount' => 100,
'odds_snapshot_json' => null,
'rule_snapshot_json' => null,
'combination_count' => 1,
'estimated_max_payout' => 0,
'risk_locked_amount' => 0,
'status' => 'settled_lose',
'win_amount' => 0,
'jackpot_win_amount' => 0,
'settled_at' => null,
'created_at' => now(),
'updated_at' => now(),
]);
DB::table('share_ledger')->insert([
'ticket_item_id' => $itemId,
'player_id' => $player->id,
'agent_node_id' => $rootId,
'agent_path' => json_encode([$rootId]),
'share_snapshot' => json_encode(['total_shares' => [$siteCode => 100]]),
'game_win_loss' => 100,
'basic_rebate' => 0,
'shared_net_win_loss' => 100,
'allocations_json' => json_encode([]),
'settled_at' => '2026-07-09 18:00:00',
'settlement_period_id' => null,
'created_at' => '2026-07-09 18:00:00',
'updated_at' => '2026-07-09 18:00:00',
]);
$hints = app(\App\Services\AgentSettlement\SettlementPeriodOpenHintsService::class)->hints($siteId);
expect($hints['settlement_timezone'])->toBe('Asia/Kathmandu')
->and($hints['occupied_period_dates'])->toContain('2026-07-09')
->and($hints['occupied_period_dates'])->not->toContain('2026-07-08')
->and($hints['pending_activity_dates'])->toContain('2026-07-09')
->and($hints['orphan_activity_dates'])->toContain('2026-07-09');
});