feat(risk): 支持按开注商隔离风险池并新增经营报表
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

This commit is contained in:
2026-07-10 10:23:30 +08:00
parent d4779660c8
commit 2ea3e810a0
31 changed files with 610 additions and 58 deletions

View File

@@ -58,6 +58,7 @@ final class RiskCapStreamService
foreach ($source->items()->orderBy('normalized_number')->get() as $row) {
RiskCapItem::query()->create([
'version_id' => $draft->id,
'provider_code' => $row->provider_code ?? 'GLOBAL',
'draw_id' => $row->draw_id,
'normalized_number' => $row->normalized_number,
'cap_amount' => $row->cap_amount,
@@ -67,6 +68,7 @@ final class RiskCapStreamService
} else {
RiskCapItem::query()->create([
'version_id' => $draft->id,
'provider_code' => 'GLOBAL',
'draw_id' => null,
'normalized_number' => '0000',
'cap_amount' => 50_000_000_000,
@@ -89,6 +91,7 @@ final class RiskCapStreamService
foreach ($items as $row) {
RiskCapItem::query()->create([
'version_id' => $draft->id,
'provider_code' => strtoupper((string) ($row['provider_code'] ?? 'GLOBAL')),
'draw_id' => isset($row['draw_id']) ? (int) $row['draw_id'] : null,
'normalized_number' => (string) $row['normalized_number'],
'cap_amount' => (int) $row['cap_amount'],
@@ -192,9 +195,10 @@ final class RiskCapStreamService
$capAmount = (int) $row->cap_amount;
$drawId = $row->draw_id === null ? '__null__' : (string) $row->draw_id;
$capType = (string) $row->cap_type;
$providerCode = strtoupper((string) ($row->provider_code ?? 'GLOBAL'));
$key = $capType === 'default'
? 'default|'.$drawId
: $drawId.'|'.$normalizedNumber;
? 'default|'.$providerCode.'|'.$drawId
: $providerCode.'|'.$drawId.'|'.$normalizedNumber;
if (! preg_match('/^[0-9]{4}$/', $normalizedNumber)) {
$errors["items.$index.normalized_number"][] = '号码必须是 4 位数字';
@@ -204,6 +208,10 @@ final class RiskCapStreamService
$errors["items.$index.cap_amount"][] = '封顶金额必须大于 0';
}
if (! preg_match('/^[A-Z0-9_-]{2,32}$/', $providerCode)) {
$errors["items.$index.provider_code"][] = '开注商编码格式不正确';
}
if ($capType === 'default' && $row->draw_id !== null) {
$errors["items.$index.cap_type"][] = '默认封顶不能绑定具体期号';
}