feat: 拆分开奖与结算审核流程,新增手动结果录入、重开和派彩审批接口
This commit is contained in:
35
app/Services/Draw/DrawReopenService.php
Normal file
35
app/Services/Draw/DrawReopenService.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Draw;
|
||||
|
||||
use App\Models\Draw;
|
||||
use App\Models\AdminUser;
|
||||
use App\Lottery\DrawStatus;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class DrawReopenService
|
||||
{
|
||||
public function reopenCooldownDraw(Draw $draw, AdminUser $admin, ?string $reason = null): Draw
|
||||
{
|
||||
unset($admin, $reason);
|
||||
|
||||
return DB::transaction(function () use ($draw): Draw {
|
||||
/** @var Draw $locked */
|
||||
$locked = Draw::query()->whereKey($draw->id)->lockForUpdate()->firstOrFail();
|
||||
if ($locked->status !== DrawStatus::Cooldown->value) {
|
||||
throw new \RuntimeException('draw_not_in_cooldown');
|
||||
}
|
||||
if ((int) $locked->settle_version > 0) {
|
||||
throw new \RuntimeException('draw_already_settled');
|
||||
}
|
||||
|
||||
$locked->forceFill([
|
||||
'status' => DrawStatus::Closed->value,
|
||||
'cooling_end_time' => null,
|
||||
'is_reopened' => true,
|
||||
])->save();
|
||||
|
||||
return $locked->refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user