Skip to content

Commit

Permalink
bugfix reserve.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WSL0809 committed May 26, 2024
1 parent 54c6f3b commit de1ffd5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions api/check_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ def update_room_and_client(db, check_out_recv):
SELECT status FROM client WHERE id = (SELECT client_id FROM room WHERE room_number = :room_number)
"""
)
client_status = db.execute(get_client_status_sql, {"room_number": check_out_recv.room_number})
client_status = client_status.mappings().first()
client_status = client_status["status"].split("-")[0]
result = db.execute(get_client_status_sql, {"room_number": check_out_recv.room_number})
client_result = result.mappings().first()

if client_result is None:
raise ValueError("没有找到指定房间的客户信息。")

client_status = client_result["status"].split("-")[0]
# 把客户状态改为已离店,客户房间改为空
update_client_sql = text(
"""
Expand Down Expand Up @@ -106,9 +110,13 @@ def client_check_out(db, check_out_recv):
SELECT status FROM client WHERE id = (SELECT client_id FROM room WHERE room_number = :room_number)
"""
)
client_status = db.execute(get_client_status_sql, {"room_number": check_out_recv.room_number})
client_status = client_status.mappings().first()
client_status = client_status["status"].split("-")[0]
result = db.execute(get_client_status_sql, {"room_number": check_out_recv.room_number})
client_result = result.mappings().first()

if client_result is None:
raise ValueError("没有找到指定房间的客户信息。")

client_status = client_result["status"].split("-")[0]
# 把客户状态改为已离店,客户房间改为空
update_client_sql = text(
"""
Expand Down

0 comments on commit de1ffd5

Please sign in to comment.