-- =============================================
-- 车辆租赁业务流程表结构增量变更
-- 对应前端新增字段
-- =============================================

-- 1. 备车记录表 - 新增字段
ALTER TABLE `asset_vehicle_prepare`
  ADD COLUMN `vehicle_type` VARCHAR(50) COMMENT '车辆类型' AFTER `model`,
  ADD COLUMN `parking_lot` VARCHAR(100) COMMENT '停车场' AFTER `vehicle_type`,
  ADD COLUMN `preparation_type` VARCHAR(50) COMMENT '整备类型' AFTER `contract_code`,
  ADD COLUMN `mileage` INT COMMENT '里程(km)' AFTER `preparation_type`,
  ADD COLUMN `hydrogen_remaining` DECIMAL(10,2) COMMENT '剩余氢量' AFTER `mileage`,
  ADD COLUMN `hydrogen_unit` VARCHAR(10) DEFAULT '%' COMMENT '氢量单位(%/MPa/kg)' AFTER `hydrogen_remaining`,
  ADD COLUMN `battery_remaining` DECIMAL(10,2) COMMENT '剩余电量(%)' AFTER `hydrogen_unit`,
  ADD COLUMN `enlarged_text_photo` VARCHAR(1000) COMMENT '放大字照片（JSON数组）' AFTER `body_ad_photos`,
  ADD COLUMN `spare_tire_depth` DECIMAL(10,2) COMMENT '备胎胎纹深度(mm)' AFTER `has_tail_lift`,
  ADD COLUMN `spare_tire_photo` VARCHAR(1000) COMMENT '备胎照片（JSON数组）' AFTER `spare_tire_depth`,
  ADD COLUMN `remark` VARCHAR(500) COMMENT '备注' AFTER `check_list`,
  ADD COLUMN `complete_time` DATETIME COMMENT '完成时间' AFTER `status`;

-- 2. 交车单表 - 新增司机信息、交检清单、费用信息
ALTER TABLE `asset_delivery_order`
  ADD COLUMN `driver_name` VARCHAR(64) COMMENT '司机姓名' AFTER `delivery_photos`,
  ADD COLUMN `driver_id_card` VARCHAR(18) COMMENT '司机身份证' AFTER `driver_name`,
  ADD COLUMN `driver_phone` VARCHAR(20) COMMENT '司机手机号' AFTER `driver_id_card`,
  ADD COLUMN `inspection_data` TEXT COMMENT '交检清单（JSON）' AFTER `driver_phone`,
  ADD COLUMN `cost_list` TEXT COMMENT '费用信息（JSON）' AFTER `inspection_data`;

-- 3. 交车单车辆表 - 新增电量
ALTER TABLE `asset_delivery_order_vehicle`
  ADD COLUMN `battery_level` DECIMAL(10,2) COMMENT '交车时电量(%)' AFTER `hydrogen_level`;

-- 4. 还车车辆表 - 新增违章费用
ALTER TABLE `asset_return_order_vehicle`
  ADD COLUMN `violation_fee` DECIMAL(10,2) DEFAULT 0 COMMENT '违章费用' AFTER `unpaid_repair_fee`;
