DROP TABLE IF EXISTS `visit_appointment`;
CREATE TABLE `visit_appointment`  (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '预约ID',
  `order_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预约订单号',
  `org_id` int(10) UNSIGNED ZEROFILL NOT NULL COMMENT '养老机构名称',
  `org_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `elder_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '长者姓名',
  `elder_room` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '长者房间号',
  `visitor_open_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `visitor_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '预约人姓名',
  `visitor_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '预约人手机号',
  `relation` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '与长者关系',
  `accompany_num` tinyint(3) UNSIGNED NOT NULL DEFAULT 0 COMMENT '随行人数',
  `note` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '预约备注',
  `visit_date` date NOT NULL COMMENT '预约日期',
  `time_slot` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '预约时间段',
  `status` tinyint(4) NOT NULL DEFAULT 0 COMMENT '状态：0-待确认，1-已预约，2-已取消，3-已完成，4-已删除',
  `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `idx_visitor_open_id`(`visitor_open_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12172 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '探访预约记录表' ROW_FORMAT = DYNAMIC;
