def settle_order(items: list[dict], discount_rate: float = 1.0, coupon_min_spend: float = 0.0, coupon_off: float = 0.0) -> float:
    """计算订单最终实付金额。
    items: [{"name": str, "price": float, "qty": int}, ...]
    """
    # Bug 1: 对每件商品单独做了四舍五入，造成累计分位误差
    discounted_subtotal = sum(round(item["price"] * item["qty"] * discount_rate, 2) for item in items)
    raw_subtotal = sum(item["price"] * item["qty"] for item in items)

    # Bug 2: 错误地用打折前的原价去判断满减门槛
    if coupon_off > 0 and raw_subtotal >= coupon_min_spend:
        total = discounted_subtotal - coupon_off
    else:
        total = discounted_subtotal

    return round(max(total, 0.0), 2)
