# 政府服务数据库设计文档

## 1. 数据库环境说明

- 数据库名称: xlxumu_government
- 字符集: utf8mb4
- 排序规则: utf8mb4_unicode_ci

## 2. 政策法规表(government_policies)

存储政府发布的政策法规信息。

```sql
CREATE TABLE government_policies (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  title VARCHAR(255) NOT NULL COMMENT '政策标题',
  content TEXT NOT NULL COMMENT '政策内容',
  category VARCHAR(100) NOT NULL COMMENT '政策分类(农业扶持/小微企业/科技创新等)',
  publish_date DATE NOT NULL COMMENT '发布日期',
  effective_date DATE COMMENT '生效日期',
  expiry_date DATE COMMENT '失效日期',
  issuing_authority VARCHAR(255) NOT NULL COMMENT '发布机构',
  policy_number VARCHAR(100) UNIQUE COMMENT '政策文号',
  status ENUM('DRAFT', 'PUBLISHED', 'EXPIRED') NOT NULL DEFAULT 'DRAFT' COMMENT '状态',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_category (category),
  INDEX idx_publish_date (publish_date),
  INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='政策法规表';
```

## 3. 补贴申请表(subsidy_applications)

存储农户或企业提交的政府补贴申请信息。

```sql
CREATE TABLE subsidy_applications (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  applicant_id BIGINT UNSIGNED NOT NULL COMMENT '申请人ID(关联user_center_service的用户ID)',
  applicant_type ENUM('FARMER', 'COMPANY') NOT NULL COMMENT '申请人类型',
  policy_id BIGINT UNSIGNED NOT NULL COMMENT '关联政策ID',
  application_number VARCHAR(50) UNIQUE NOT NULL COMMENT '申请编号',
  project_name VARCHAR(255) NOT NULL COMMENT '项目名称',
  project_description TEXT NOT NULL COMMENT '项目描述',
  applied_amount DECIMAL(15,2) NOT NULL COMMENT '申请金额',
  actual_amount DECIMAL(15,2) COMMENT '实际发放金额',
  application_date DATE NOT NULL COMMENT '申请日期',
  status ENUM('SUBMITTED', 'REVIEWING', 'APPROVED', 'REJECTED', 'DISBURSED') NOT NULL DEFAULT 'SUBMITTED' COMMENT '申请状态',
  reviewer_id BIGINT UNSIGNED COMMENT '审核人ID',
  review_notes TEXT COMMENT '审核备注',
  review_date TIMESTAMP NULL COMMENT '审核日期',
  disbursement_date DATE COMMENT '发放日期',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_applicant_id (applicant_id),
  INDEX idx_policy_id (policy_id),
  INDEX idx_status (status),
  INDEX idx_application_date (application_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='补贴申请表';
```

## 4. 补贴发放记录表(subsidy_disbursements)

记录补贴发放的具体信息。

```sql
CREATE TABLE subsidy_disbursements (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  application_id BIGINT UNSIGNED NOT NULL COMMENT '关联申请ID',
  disbursement_amount DECIMAL(15,2) NOT NULL COMMENT '发放金额',
  disbursement_date DATE NOT NULL COMMENT '发放日期',
  payment_method ENUM('BANK_TRANSFER', 'CASH', 'OTHER') NOT NULL COMMENT '发放方式',
  payment_reference VARCHAR(255) COMMENT '支付凭证号',
  recipient_account VARCHAR(255) COMMENT '收款账户',
  status ENUM('PENDING', 'SUCCESS', 'FAILED') NOT NULL DEFAULT 'PENDING' COMMENT '发放状态',
  failure_reason TEXT COMMENT '失败原因',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_application_id (application_id),
  INDEX idx_disbursement_date (disbursement_date),
  INDEX idx_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='补贴发放记录表';
```

## 5. 农业补贴标准表(agricultural_subsidy_standards)

存储各类农业补贴的发放标准。

```sql
CREATE TABLE agricultural_subsidy_standards (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  policy_id BIGINT UNSIGNED NOT NULL COMMENT '关联政策ID',
  crop_type VARCHAR(100) NOT NULL COMMENT '作物类型',
  subsidy_type ENUM('PER_AREA', 'PER_UNIT', 'FIXED_AMOUNT') NOT NULL COMMENT '补贴方式',
  subsidy_amount DECIMAL(10,2) NOT NULL COMMENT '补贴金额(元/亩或元/单位)',
  unit VARCHAR(50) COMMENT '单位(亩/头/只等)',
  effective_date DATE NOT NULL COMMENT '生效日期',
  expiry_date DATE COMMENT '失效日期',
  description TEXT COMMENT '标准描述',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_policy_id (policy_id),
  INDEX idx_crop_type (crop_type),
  INDEX idx_effective_date (effective_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='农业补贴标准表';
```

## 6. 合规检查记录表(compliance_inspection_records)

记录对农户或企业进行的合规检查信息。

```sql
CREATE TABLE compliance_inspection_records (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  inspected_entity_id BIGINT UNSIGNED NOT NULL COMMENT '被检查实体ID(关联user_center_service的用户ID)',
  entity_type ENUM('FARMER', 'COMPANY') NOT NULL COMMENT '实体类型',
  inspector_id BIGINT UNSIGNED NOT NULL COMMENT '检查员ID',
  inspection_date DATE NOT NULL COMMENT '检查日期',
  inspection_type VARCHAR(100) NOT NULL COMMENT '检查类型(环保检查/质量检查/安全检查等)',
  inspection_result ENUM('PASS', 'FAIL', 'PENDING') NOT NULL DEFAULT 'PENDING' COMMENT '检查结果',
  findings TEXT COMMENT '检查发现',
  corrective_actions TEXT COMMENT '整改措施',
  follow_up_date DATE COMMENT '跟进日期',
  status ENUM('COMPLETED', 'FOLLOW_UP_REQUIRED', 'CLOSED') NOT NULL DEFAULT 'COMPLETED' COMMENT '状态',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_entity_id (inspected_entity_id),
  INDEX idx_inspector_id (inspector_id),
  INDEX idx_inspection_date (inspection_date),
  INDEX idx_result (inspection_result)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='合规检查记录表';
```

## 7. 土地流转信息表(land_transfer_info)

记录农村土地流转的相关信息。

```sql
CREATE TABLE land_transfer_info (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  land_owner_id BIGINT UNSIGNED NOT NULL COMMENT '土地所有者ID(关联user_center_service的用户ID)',
  transferee_id BIGINT UNSIGNED NOT NULL COMMENT '受让方ID(关联user_center_service的用户ID)',
  land_location VARCHAR(255) NOT NULL COMMENT '土地位置',
  land_area DECIMAL(10,2) NOT NULL COMMENT '土地面积(亩)',
  transfer_type ENUM('LEASE', 'SALE', 'CONTRACT') NOT NULL COMMENT '流转类型',
  transfer_term INT NOT NULL COMMENT '流转期限(年)',
  annual_rent DECIMAL(10,2) COMMENT '年租金(元/亩)',
  total_amount DECIMAL(15,2) COMMENT '总金额',
  start_date DATE NOT NULL COMMENT '开始日期',
  end_date DATE NOT NULL COMMENT '结束日期',
  contract_number VARCHAR(100) UNIQUE COMMENT '合同编号',
  status ENUM('ACTIVE', 'EXPIRED', 'TERMINATED') NOT NULL DEFAULT 'ACTIVE' COMMENT '状态',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_land_owner_id (land_owner_id),
  INDEX idx_transferee_id (transferee_id),
  INDEX idx_status (status),
  INDEX idx_start_date (start_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='土地流转信息表';
```

## 8. 农产品质量认证表(agricultural_product_certifications)

记录农产品的质量认证信息。

```sql
CREATE TABLE agricultural_product_certifications (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  producer_id BIGINT UNSIGNED NOT NULL COMMENT '生产者ID(关联user_center_service的用户ID)',
  product_name VARCHAR(255) NOT NULL COMMENT '产品名称',
  certification_type VARCHAR(100) NOT NULL COMMENT '认证类型(绿色食品/有机产品/地理标志等)',
  certification_number VARCHAR(100) UNIQUE COMMENT '认证编号',
  issuing_authority VARCHAR(255) NOT NULL COMMENT '发证机构',
  issue_date DATE NOT NULL COMMENT '发证日期',
  expiry_date DATE NOT NULL COMMENT '有效期至',
  certification_status ENUM('VALID', 'EXPIRED', 'REVOKED') NOT NULL DEFAULT 'VALID' COMMENT '认证状态',
  inspection_report TEXT COMMENT '检验报告',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (id),
  INDEX idx_producer_id (producer_id),
  INDEX idx_certification_type (certification_type),
  INDEX idx_expiry_date (expiry_date),
  INDEX idx_status (certification_status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='农产品质量认证表';
```