Files
shop-toy/openspec/changes/integrate-insurance-flow/design.md
2026-01-12 18:24:25 +08:00

475 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Design: 集成保险流程到贷款业务
## Context
本设计涉及银行端、保险端和政务端三个系统的协同,实现贷款业务中的保险购买、核保、理赔审核和不良贷款监管的完整流程。
**关键约束**
- 保险购买是银行端在贷款审核通过后的可选操作,与用户端无关
- 银行选择保险产品后,自动发送给对应的保险公司
- 银行端发起理赔申请并上传材料到保险公司
- 政务端可以看到银行端的所有贷款信息,包括不良贷款
**本次优化重点**
- 优化银行端审核详情页面的保险功能交互
- 实现投保和理赔的页面跳转
- 流程步骤条增加保险节点
- 快捷入口位置调整
## Goals / Non-Goals
**Goals**:
- 建立银行与保险公司之间的投保和核保流程
- 实现银行向保险公司提交理赔申请的功能
- 支持保险公司进行核保和理赔审核
- 为政务端提供完整的贷款业务流程视图,包括保险和审批信息
- 确保各端数据的一致性和可追溯性
- 优化银行端保险功能的用户体验
**Non-Goals**:
- 不涉及用户端直接购买保险
- 不涉及保险公司主动向银行推送产品
- 不涉及政务端对贷款的审批(仅查看)
- 不涉及保险产品的具体定价和费率计算
## Decisions
### 1. 数据模型设计
#### 1.1 保险相关数据实体
```typescript
// 保险公司
interface InsuranceCompany {
id: string;
name: string;
contactInfo: string;
status: 'active' | 'inactive';
}
// 保险产品
interface InsuranceProduct {
id: string;
companyId: string;
name: string;
type: 'housing_loan' | 'business_credit' | 'other';
description: string;
minAmount: number;
maxAmount: number;
status: 'active' | 'inactive';
}
// 投保申请
interface InsuranceApplication {
id: string;
loanId: string;
bankId: string;
companyId: string;
productId: string;
customerInfo: {
name: string;
idNumber: string;
creditScore: number;
loanAmount: number;
loanTerm: number;
};
insuranceAmount: number;
insuranceTerm: number;
status: 'pending' | 'approved' | 'rejected';
createdAt: Date;
reviewedAt?: Date;
reviewedBy?: string;
rejectionReason?: string;
}
// 保险单
interface InsurancePolicy {
id: string;
applicationId: string;
policyNumber: string;
companyId: string;
bankId: string;
loanId: string;
productId: string;
insuranceAmount: number;
insuranceTerm: number;
startDate: Date;
endDate: Date;
status: 'active' | 'expired' | 'cancelled';
issuedAt: Date;
}
// 理赔申请
interface ClaimApplication {
id: string;
policyId: string;
loanId: string;
bankId: string;
companyId: string;
claimAmount: number;
claimReason: string;
materials: string[]; // 文件URL列表
status: 'pending' | 'approved' | 'rejected';
submittedAt: Date;
reviewedAt?: Date;
reviewedBy?: string;
rejectionReason?: string;
payoutAmount?: number;
payoutDate?: Date;
}
```
#### 1.2 贷款与保险关联
```typescript
// 扩展现有贷款实体
interface Loan {
id: string;
// ... 现有字段
insuranceApplicationId?: string; // 可选
insurancePolicyId?: string; // 可选
claimApplicationIds: string[]; // 理赔申请列表
isBadLoan: boolean; // 是否为不良贷款
}
```
### 2. 业务流程设计
#### 2.1 保险购买流程
```mermaid
sequenceDiagram
participant Bank as 银行端
participant System as 系统后端
participant Insurance as 保险端
Bank->>System: 1. 贷款审核通过
Bank->>System: 2. 选择购买保险(可选)
Bank->>System: 3. 选择保险公司和产品
Bank->>System: 4. 确定保险金额和期限
System->>System: 5. 创建投保申请
System->>Insurance: 6. 自动发送投保申请
Insurance->>Insurance: 7. 核保人员审核
alt 核保通过
Insurance->>System: 8a. 返回核保通过
System->>System: 9a. 生成保险单
System->>Bank: 10a. 通知投保成功
else 核保拒绝
Insurance->>System: 8b. 返回拒绝原因
System->>Bank: 10b. 通知投保失败
end
```
#### 2.2 理赔申请流程
```mermaid
sequenceDiagram
participant Bank as 银行端
participant System as 系统后端
participant Insurance as 保险端
Bank->>System: 1. 发起理赔申请
Bank->>System: 2. 上传理赔材料
System->>System: 3. 创建理赔申请记录
System->>Insurance: 4. 发送理赔申请
Insurance->>Insurance: 5. 审核理赔材料
alt 审核通过
Insurance->>System: 6a. 返回审核通过
Insurance->>System: 7a. 执行赔付
System->>Bank: 8a. 通知理赔成功
else 审核拒绝
Insurance->>System: 6b. 返回拒绝原因
System->>Bank: 8b. 通知理赔失败
end
```
#### 2.3 政务端查看流程
```mermaid
sequenceDiagram
participant Government as 政务端
participant System as 系统后端
Government->>System: 1. 请求贷款列表
System->>Government: 2. 返回贷款信息(含保险信息)
Government->>System: 3. 请求贷款详情
System->>Government: 4. 返回完整信息:
- 用户信息
- 贷款信息
- 保险信息(投保申请、保险单)
- 理赔信息(理赔申请、审核结果)
- 审批流程记录
```
### 3. API 接口设计
#### 3.1 银行端接口
```typescript
// 获取合作保险公司列表
GET /api/bank/insurance/companies
// 获取保险产品列表
GET /api/bank/insurance/products?companyId={companyId}
// 创建投保申请
POST /api/bank/insurance/applications
{
loanId: string;
companyId: string;
productId: string;
insuranceAmount: number;
insuranceTerm: number;
}
// 获取投保申请状态
GET /api/bank/insurance/applications/{id}
// 创建理赔申请
POST /api/bank/insurance/claims
{
policyId: string;
loanId: string;
claimAmount: number;
claimReason: string;
materials: File[];
}
// 获取理赔申请状态
GET /api/bank/insurance/claims/{id}
```
#### 3.2 保险端接口
```typescript
// 获取待核保申请列表
GET /api/insurance/applications?status=pending
// 获取投保申请详情
GET /api/insurance/applications/{id}
// 核保审核
POST /api/insurance/applications/{id}/review
{
approved: boolean;
rejectionReason?: string;
}
// 获取待理赔审核列表
GET /api/insurance/claims?status=pending
// 获取理赔申请详情
GET /api/insurance/claims/{id}
// 理赔审核
POST /api/insurance/claims/{id}/review
{
approved: boolean;
rejectionReason?: string;
payoutAmount?: number;
}
```
#### 3.3 政务端接口
```typescript
// 获取贷款列表(含保险信息)
GET /api/government/loans?includeInsurance=true
// 获取贷款详情(含完整业务流程)
GET /api/government/loans/{id}?full=true
// 获取不良贷款列表
GET /api/government/loans/bad
```
### 4. 页面结构设计
#### 4.1 银行端页面
```
src/pagesBank/insurance/
├── application/
│ ├── create.vue # 创建投保申请
│ └── detail.vue # 投保申请详情
├── claim/
│ ├── create.vue # 创建理赔申请
│ └── list.vue # 理赔申请列表
└── policy/
└── detail.vue # 保险单详情
```
#### 4.2 保险端页面
```
src/pagesInsurance/underwriting/
├── list.vue # 待核保申请列表
└── detail.vue # 核保申请详情
src/pagesInsurance/claim-review/
├── list.vue # 待理赔审核列表
└── detail.vue # 理赔审核详情
```
#### 4.3 政务端页面
```
src/pagesGovernment/bank/
├── list.vue # 修改:显示保险信息标识
└── detail.vue # 修改:显示完整业务流程信息
```
### 5. 状态机设计
#### 5.1 投保申请状态机
```
pending → approved → policy_issued
pending → rejected
```
#### 5.2 理赔申请状态机
```
pending → approved → paid
pending → rejected
```
### 6. 权限控制
- **银行端**:只能查看和操作自己发起的投保和理赔申请
- **保险端**:只能查看和操作分配给自己的核保和理赔审核任务
- **政务端**:只读权限,可查看所有贷款信息
## UI/UX 优化设计
### 6.1 审核详情页面优化
#### 6.1.1 保险信息展示
根据贷款状态动态展示不同的保险信息:
- **未投保状态**status === 'DISBURSED' && !hasInsurance
- 显示"购买保险"按钮
- 不显示保单信息
- **已投保状态**hasInsurance
- 显示保单信息(保险公司、保单号、保险金额、保险期限)
- 显示"申请理赔"按钮
- **投保中状态**insuranceStatus === 'pending'
- 显示投保申请进度
- 不显示保单号(还未生成)
- **已理赔状态**hasClaim
- 显示保单信息
- 显示理赔记录
#### 6.1.2 投保申请跳转
```typescript
function handleBuyInsurance() {
const loanId = detail.value.id
const loanAmount = detail.value.amount
const loanTerm = detail.value.term * 12 // 转换为月
uni.navigateTo({
url: `/pagesBank/insurance/application/create?loanId=${loanId}&loanAmount=${loanAmount}&loanTerm=${loanTerm}`,
})
}
```
#### 6.1.3 理赔申请跳转
```typescript
function handleApplyClaim() {
const loanId = detail.value.id
const policyId = detail.value.insurancePolicy.id
const policyNumber = detail.value.insurancePolicy.policyNumber
uni.navigateTo({
url: `/pagesBank/insurance/claim/create?loanId=${loanId}&policyId=${policyId}&policyNumber=${policyNumber}`,
})
}
```
### 6.2 流程步骤条优化
#### 6.2.1 步骤定义
```typescript
const steps = [
{ key: 'SUBMITTED', label: '申请' },
{ key: 'ACCEPTED', label: '受理' },
{ key: 'INVESTIGATING', label: '调查' },
{ key: 'APPROVING', label: '审批' },
{ key: 'INSURANCE', label: '投保', condition: (detail) => detail.hasInsurance },
{ key: 'SIGNING', label: '签约' },
{ key: 'DISBURSED', label: '放款' },
]
```
#### 6.2.2 条件渲染
```vue
<view
v-for="(step, index) in visibleSteps"
:key="step.key"
class="step-item"
:class="{ active: index <= currentStepIndex, current: index === currentStepIndex }"
>
<!-- 步骤内容 -->
</view>
```
### 6.3 快捷入口迁移
#### 6.3.1 从审核列表移除
移除 `/pagesBank/audit/list.vue` 中的保险功能快捷入口代码块。
#### 6.3.2 添加到工作台首页
`/pagesBank/dashboard/index.vue``quickActions` 数组中添加:
```typescript
const quickActions = [
{ icon: 'i-carbon-task-approved', label: '待审核', path: '/pagesBank/audit/list' },
{ icon: 'i-carbon-group', label: '客户管理', path: '/pagesBank/customer/list' },
{ icon: 'i-carbon-calendar', label: '拜访计划', path: '/pagesBank/visit/list' },
{ icon: 'i-carbon-add', label: '创建拜访', path: '/pagesBank/visit/create' },
{ icon: 'i-carbon-document-download', label: '报表', path: '/pagesBank/report/list' },
{ icon: 'i-carbon-security', label: '投保管理', path: '/pagesBank/insurance/application/list' },
{ icon: 'i-carbon-money', label: '理赔管理', path: '/pagesBank/insurance/claim/list' },
{ icon: 'i-carbon-settings', label: '设置', path: '/pagesBank/me/index' },
]
```
## Risks / Trade-offs
| Risk | Mitigation |
|------|-----------|
| 保险公司核保时间过长影响贷款放款 | 设置核保超时机制,超时后允许银行取消投保 |
| 理赔材料审核标准不统一 | 在系统中提供审核标准文档和模板 |
| 跨系统数据同步延迟 | 使用消息队列确保数据最终一致性 |
| 政务端数据量过大影响性能 | 实现分页和懒加载,支持按条件筛选 |
## Migration Plan
1. **Phase 0**: 创建数据表和 API 接口
2. **Phase 2**: 实现银行端保险购买功能
3. **Phase 3**: 实现保险端核保功能
4. **Phase 4**: 实现银行端理赔申请功能
5. **Phase 5**: 实现保险端理赔审核功能
6. **Phase 6**: 扩展政务端查看功能
**Rollback**: 如果需要回滚,可以禁用保险相关功能,贷款流程将恢复到不包含保险的状态。
## Open Questions
1. 保险公司是否需要支持多家银行同时接入?
2. 理赔赔付金额的计算规则是什么?
3. 不良贷款的判定标准是什么(逾期天数、金额等)?
4. 是否需要支持保险单的转让或变更?
5. 投保节点是否需要在所有贷款流程中都显示?