def METHOD_NAME(appoint_id: int):
    '''
    结束预约
    - 接受单个预约id
    - 可以处理任何状态的预约
    - 对于非终止状态，判断人数是否合格，并转化为终止状态
    要注意的是，由于定时任务可能执行多次，第二次的时候可能已经终止
    '''
    try:
        appoint: Appoint = Appoint.objects.get(Aid=appoint_id)
    except:
        return logger.exception(f"预约{appoint_id}意外消失")
    # 如果处于非终止状态，只需检查人数判断是否合格
    if appoint.Astatus in Appoint.Status.Terminals():
        return _teminate_handler(appoint)
    # 希望接受的非终止状态只有进行中，但其他状态也同样判定是否合格
    if appoint.Astatus != Appoint.Status.PROCESSING:
        get_user_logger(appoint).error(
            f"预约{appoint_id}结束时状态为{appoint.get_status()}：照常检查是否合格")
    # 摄像头出现超时问题，直接通过
    if datetime.now() - appoint.Room.Rlatest_time > timedelta(minutes=15):
        appoint.Astatus = Appoint.Status.CONFIRMED  # waiting
        appoint.save()
        get_user_logger(appoint).info(f"预约{appoint_id}的状态已确认: 顺利完成")
        return
    # 检查人数是否足够
    adjusted_rate = _adjusted_rate(CONFIG.camera_qualify_rate, appoint)
    need_num = appoint.Acamera_check_num * adjusted_rate - 0.01
    check_failed = appoint.Acamera_ok_num < need_num
    if check_failed:
        # 迟到的预约通知在这里处理。如果迟到不扣分，删掉这个if的内容即可
        # 让下面那个camera check的if判断是否违规。
        if appoint.Areason == Appoint.Reason.R_LATE:
            reason = Appoint.Reason.R_LATE
        else:
            reason = Appoint.Reason.R_TOOLITTLE
        if appoint_violate(appoint, reason):
            appoint.refresh_from_db()
            notify_appoint(appoint, MessageType.VIOLATED, appoint.get_status(),
                            students_id=[appoint.get_major_id()])
    else:   # 通过
        appoint.Astatus = Appoint.Status.CONFIRMED
        appoint.save()
        logger.info(f"预约{appoint_id}人数合格，已通过")