-- 插入生资保险测试数据

-- 插入牲畜类型测试数据
INSERT INTO livestock_types (name, code, description, unit_price_min, unit_price_max, premium_rate, status) VALUES
('奶牛', 'DAIRY_COW', '用于产奶的牛类', 10000.00, 20000.00, 0.0500, 'active'),
('肉牛', 'BEEF_COW', '用于肉类生产的牛类', 8000.00, 16000.00, 0.0400, 'active'),
('生猪', 'PIG', '用于肉类生产的猪类', 1500.00, 2500.00, 0.0600, 'active'),
('羊', 'SHEEP', '包括山羊和绵羊', 600.00, 1000.00, 0.0500, 'active');

-- 插入生资保单测试数据
INSERT INTO livestock_policies (
  policy_no, farmer_name, farmer_phone, farmer_id_card, livestock_type_id, 
  livestock_count, unit_value, total_value, premium_rate, premium_amount,
  start_date, end_date, farm_name, farm_address, farm_license,
  policy_status, payment_status, payment_date, notes, created_by, updated_by
) VALUES
(
  'LP2024001', '张三', '13800138001', '110101199001011234', 
  (SELECT id FROM livestock_types WHERE code = 'DAIRY_COW'),
  10, 15000.00, 150000.00, 0.0500, 7500.00,
  '2024-01-01', '2024-12-31', '张三奶牛养殖场', '北京市朝阳区某某村123号', 'BJ2024001',
  'active', 'paid', '2024-01-01', '优质奶牛保险', 1, 1
),
(
  'LP2024002', '李四', '13800138002', '110101199002021234',
  (SELECT id FROM livestock_types WHERE code = 'BEEF_COW'),
  20, 12000.00, 240000.00, 0.0400, 9600.00,
  '2024-02-01', '2025-01-31', '李四肉牛养殖场', '北京市海淀区某某村456号', 'BJ2024002',
  'active', 'paid', '2024-02-01', '肉牛养殖保险', 1, 1
),
(
  'LP2024003', '王五', '13800138003', '110101199003031234',
  (SELECT id FROM livestock_types WHERE code = 'PIG'),
  100, 2000.00, 200000.00, 0.0600, 12000.00,
  '2024-03-01', '2025-02-28', '王五生猪养殖场', '北京市昌平区某某村789号', 'BJ2024003',
  'active', 'unpaid', NULL, '生猪养殖保险', 1, 1
),
(
  'LP2024004', '赵六', '13800138004', '110101199004041234',
  (SELECT id FROM livestock_types WHERE code = 'SHEEP'),
  50, 800.00, 40000.00, 0.0500, 2000.00,
  '2024-04-01', '2025-03-31', '赵六羊群养殖场', '北京市房山区某某村101号', 'BJ2024004',
  'active', 'partial', '2024-04-01', '羊群保险', 1, 1
);

-- 插入生资理赔测试数据
INSERT INTO livestock_claims (
  claim_no, policy_id, claim_amount, incident_date, incident_description,
  claim_status, investigator_id, investigation_report, investigation_date,
  reviewer_id, review_notes, review_date, payment_date, payment_amount,
  supporting_documents, created_by, updated_by
) VALUES
(
  'LC2024001', 
  (SELECT id FROM livestock_policies WHERE policy_no = 'LP2024001'),
  30000.00, '2024-06-15', '奶牛因疾病死亡2头',
  'paid', 1, '经现场调查，确认奶牛因疫病死亡，符合保险条款', '2024-06-20',
  1, '经核实，符合理赔条件', '2024-06-25', '2024-07-01', 30000.00,
  '[{"type":"death_certificate","url":"/documents/death_cert_001.pdf"},{"type":"veterinary_report","url":"/documents/vet_report_001.pdf"}]',
  1, 1
),
(
  'LC2024002',
  (SELECT id FROM livestock_policies WHERE policy_no = 'LP2024002'),
  24000.00, '2024-07-20', '肉牛因自然灾害死亡2头',
  'investigating', 1, '正在进行现场调查', '2024-07-25',
  NULL, NULL, NULL, NULL, NULL,
  '[{"type":"incident_report","url":"/documents/incident_002.pdf"}]',
  1, 1
);

-- 查询插入结果
SELECT '牲畜类型数据:' as info;
SELECT id, name, code, unit_price_min, unit_price_max, premium_rate, status FROM livestock_types;

SELECT '生资保单数据:' as info;
SELECT id, policy_no, farmer_name, livestock_count, total_value, policy_status, payment_status FROM livestock_policies;

SELECT '理赔记录数据:' as info;
SELECT id, claim_no, claim_amount, incident_date, claim_status FROM livestock_claims;