feat: 更新玩法配置管理,简化字段并增强功能
- 将玩法相关的显示名称字段统一为 `display_name`,移除多语言字段。 - 在 `PlayTypePatchController` 中新增即时切换玩法开关的功能,并推送大厅更新。 - 优化多个控制器和服务中的权限检查与数据处理逻辑,提升代码可读性与维护性。
This commit is contained in:
@@ -21,7 +21,17 @@ final class SettlementBatchWorkflowService
|
||||
|
||||
public function approve(SettlementBatch $batch, AdminUser $admin, ?string $remark = null): SettlementBatch
|
||||
{
|
||||
return DB::transaction(function () use ($batch, $admin, $remark): SettlementBatch {
|
||||
return $this->approveInternal($batch, $admin->id, $remark);
|
||||
}
|
||||
|
||||
public function approveBySystem(SettlementBatch $batch, ?string $remark = null): SettlementBatch
|
||||
{
|
||||
return $this->approveInternal($batch, null, $remark);
|
||||
}
|
||||
|
||||
private function approveInternal(SettlementBatch $batch, ?int $reviewedBy, ?string $remark): SettlementBatch
|
||||
{
|
||||
return DB::transaction(function () use ($batch, $reviewedBy, $remark): SettlementBatch {
|
||||
/** @var SettlementBatch $locked */
|
||||
$locked = SettlementBatch::query()->whereKey($batch->id)->lockForUpdate()->firstOrFail();
|
||||
if ($locked->status !== SettlementBatchStatus::PendingReview->value) {
|
||||
@@ -31,7 +41,7 @@ final class SettlementBatchWorkflowService
|
||||
$locked->forceFill([
|
||||
'status' => SettlementBatchStatus::Approved->value,
|
||||
'review_status' => 'approved',
|
||||
'reviewed_by' => $admin->id,
|
||||
'reviewed_by' => $reviewedBy,
|
||||
'reviewed_at' => now(),
|
||||
'review_remark' => $remark,
|
||||
])->save();
|
||||
|
||||
@@ -13,6 +13,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use App\Lottery\SettlementBatchStatus;
|
||||
use App\Models\TicketSettlementDetail;
|
||||
use App\Services\Draw\DrawHallSnapshotBuilder;
|
||||
use App\Services\Draw\LotteryHallRealtimeBroadcaster;
|
||||
use App\Services\Ticket\RiskPoolService;
|
||||
use App\Services\Jackpot\JackpotBurstAllocator;
|
||||
@@ -30,6 +31,7 @@ final class SettlementOrchestrator
|
||||
private readonly JackpotBurstAllocator $jackpotBurst,
|
||||
private readonly RiskPoolService $riskPool,
|
||||
private readonly LotteryHallRealtimeBroadcaster $hallRealtime,
|
||||
private readonly DrawHallSnapshotBuilder $hallSnapshot,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -214,6 +216,7 @@ final class SettlementOrchestrator
|
||||
$jackpotTrigger,
|
||||
(int) $jackpotPoolAfter,
|
||||
);
|
||||
$this->hallRealtime->notifyStatusChange($this->hallSnapshot->build());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
65
app/Services/Settlement/SettlementTickFinalizer.php
Normal file
65
app/Services/Settlement/SettlementTickFinalizer.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Settlement;
|
||||
|
||||
use App\Models\SettlementBatch;
|
||||
use App\Lottery\SettlementBatchStatus;
|
||||
use App\Services\AuditLogger;
|
||||
use App\Services\LotterySettings;
|
||||
|
||||
/**
|
||||
* draw tick 在自动结算后,按系统设置自动审核并派彩入账。
|
||||
*/
|
||||
final class SettlementTickFinalizer
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SettlementBatchWorkflowService $workflow,
|
||||
) {}
|
||||
|
||||
/** @return array{approved: int, paid: int} */
|
||||
public function finalizePendingBatches(): array
|
||||
{
|
||||
$approved = 0;
|
||||
$paid = 0;
|
||||
|
||||
if (! (bool) LotterySettings::get('settlement.auto_approve_on_tick', true)) {
|
||||
return ['approved' => 0, 'paid' => 0];
|
||||
}
|
||||
|
||||
$pending = SettlementBatch::query()
|
||||
->where('status', SettlementBatchStatus::PendingReview->value)
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
foreach ($pending as $batch) {
|
||||
try {
|
||||
$this->workflow->approveBySystem($batch, 'auto approve on draw tick');
|
||||
$approved++;
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! (bool) LotterySettings::get('settlement.auto_payout_on_tick', true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->workflow->payout($batch->fresh());
|
||||
$paid++;
|
||||
AuditLogger::recordForSystem(
|
||||
moduleCode: 'settlement',
|
||||
actionCode: 'auto_payout',
|
||||
targetType: 'settlement_batch',
|
||||
targetId: (string) $batch->id,
|
||||
afterJson: ['draw_id' => (int) $batch->draw_id],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
report($e);
|
||||
}
|
||||
}
|
||||
|
||||
return ['approved' => $approved, 'paid' => $paid];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user