feat: 支持开奖设置走系统配置并补充相关测试
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\DrawResultBatch;
|
||||
use App\Models\SettlementBatch;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use App\Services\LotterySettings;
|
||||
use App\Events\DrawCountdownBroadcast;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use App\Services\Draw\DrawTickService;
|
||||
@@ -225,6 +226,7 @@ test('draw tick moves open draw to closing when close_time passed before draw_ti
|
||||
|
||||
test('draw tick rng publishes result when manual review disabled', function (): void {
|
||||
config(['lottery.draw.require_manual_review' => false]);
|
||||
LotterySettings::put('draw.require_manual_review', false, 'draw', 'RNG 开奖后是否必须进入人工审核');
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 14:05:00', 'UTC'));
|
||||
|
||||
$drawTime = now()->copy()->subMinute();
|
||||
@@ -261,6 +263,7 @@ test('draw tick rng publishes result when manual review disabled', function ():
|
||||
|
||||
test('draw tick rng awaits manual publish when review enabled', function (): void {
|
||||
config(['lottery.draw.require_manual_review' => true]);
|
||||
LotterySettings::put('draw.require_manual_review', true, 'draw', 'RNG 开奖后是否必须进入人工审核');
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 14:06:00', 'UTC'));
|
||||
|
||||
$drawTime = now()->copy()->subMinute();
|
||||
@@ -513,6 +516,8 @@ test('cooldown expiry tick moves draw to settling', function (): void {
|
||||
'lottery.draw.require_manual_review' => false,
|
||||
'lottery.draw.cooldown_minutes' => 15,
|
||||
]);
|
||||
LotterySettings::put('draw.require_manual_review', false, 'draw', 'RNG 开奖后是否必须进入人工审核');
|
||||
LotterySettings::put('draw.cooldown_minutes', 15, 'draw', '开奖结果发布后的冷静期分钟数');
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 14:07:00', 'UTC'));
|
||||
|
||||
$drawTime = now()->copy()->subMinute();
|
||||
@@ -549,6 +554,45 @@ test('cooldown expiry tick moves draw to settling', function (): void {
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
test('draw tick uses lottery settings to bypass manual review and cooldown', function (): void {
|
||||
config([
|
||||
'lottery.draw.require_manual_review' => true,
|
||||
'lottery.draw.cooldown_minutes' => 15,
|
||||
]);
|
||||
LotterySettings::put('draw.require_manual_review', false, 'draw', 'RNG 开奖后是否必须进入人工审核');
|
||||
LotterySettings::put('draw.cooldown_minutes', 0, 'draw', '开奖结果发布后的冷静期分钟数');
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 14:08:00', 'UTC'));
|
||||
|
||||
$drawTime = now()->copy()->subMinute();
|
||||
$closeTime = $drawTime->copy()->subSeconds(30);
|
||||
|
||||
Draw::query()->create([
|
||||
'draw_no' => '20260509-778',
|
||||
'business_date' => '2026-05-09',
|
||||
'sequence_no' => 778,
|
||||
'status' => DrawStatus::Open->value,
|
||||
'start_time' => $closeTime->copy()->subMinutes(10),
|
||||
'close_time' => $closeTime,
|
||||
'draw_time' => $drawTime,
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => null,
|
||||
'current_result_version' => 0,
|
||||
'settle_version' => 0,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
app(DrawTickService::class)->tick(now()->utc());
|
||||
|
||||
$draw = Draw::query()->where('draw_no', '20260509-778')->firstOrFail();
|
||||
expect($draw->status)->toBe(DrawStatus::Settling->value);
|
||||
expect($draw->cooling_end_time)->toBeNull();
|
||||
|
||||
$batch = DrawResultBatch::query()->where('draw_id', $draw->id)->firstOrFail();
|
||||
expect($batch->status)->toBe(DrawResultBatchStatus::Published->value);
|
||||
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
test('GET draw current returns open draw with seconds to close', function (): void {
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 15:00:00', 'UTC'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user