-- 预约表
CREATE TABLE IF NOT EXISTS `reservations` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL COMMENT '用户ID',
  `service_id` int(11) NOT NULL COMMENT '服务ID',
  `technician_id` int(11) DEFAULT NULL COMMENT '技师ID',
  `address_id` int(11) NOT NULL COMMENT '地址ID',
  `reservation_date` date NOT NULL COMMENT '预约日期',
  `reservation_time` varchar(10) NOT NULL COMMENT '预约时间',
  `notes` text COMMENT '备注信息',
  `service_fee` decimal(10,2) NOT NULL COMMENT '服务费用',
  `visit_fee` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '上门费',
  `discount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '优惠金额',
  `total_price` decimal(10,2) NOT NULL COMMENT '总价',
  `status` enum('pending','confirmed','completed','cancelled') NOT NULL DEFAULT 'pending' 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`),
  KEY `user_id` (`user_id`),
  KEY `service_id` (`service_id`),
  KEY `technician_id` (`technician_id`),
  KEY `address_id` (`address_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预约表';

-- 用户地址表
CREATE TABLE IF NOT EXISTS `addresses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL COMMENT '用户ID',
  `name` varchar(50) NOT NULL COMMENT '地址名称',
  `full_address` varchar(255) NOT NULL COMMENT '详细地址',
  `phone` varchar(20) NOT NULL COMMENT '联系电话',
  `is_default` tinyint(1) NOT NULL DEFAULT '0' 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`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户地址表';