简体   繁体   中英

Online Hotel Booking System, Simultaneous Booking?

I'm asked to create an online booking system with online payment and I'm wondering what to do in the case when 2 customers booked for the same room(s) at the same time.

For Example:
At the same time:

Customer1 and Customer2 booked for a standard room which only has 1 room available. (The Room availability will display that there is still 1 room available). And then they hit the 'confirm' button at the same time.

Use a locking construct (probably on the database level in this case) to ensure that only one confirmation will go through at once. You should always do this if it's possible to have a race condition like this. That way you will always know who was first, and you can tell the other user that they were too slow to confirm.

Another thing you might want to add is a payment time limit. In many systems, when you confirm something, you will have a certain amount of time to make a payment to get the reservation. If you don't pay within that time, the confirmation will expire and the room will once again be available.

There's a couple of ways to combat this.

  1. If I user selects a room, temporarily remove it as available from your web front-end. Then any subsequent visitors will not be able to select that room for booking. If the first user doesn't complete the transaction, then the room becomes available again.
  2. Put a lock on the database as mentioned above so only one record can be written at any time

Use a "provisional" system that marks the booking as provisional for, say 10 minutes. These slots then become unavailable to subsequent requests. If the booking is not completed within the time frame the slot is released again. If you grab all the customer detail before they book the slot then the drop-out rate should stay low.

You must communicate the time-frame and it's "provisional status" to the booker. If you have subsequent stages where the visitor could stop then a simple JS timer counting down the time would help and also push the booker along the process.

Alternatively, allow double booking until such time as the final "pay" button is pressed when it becomes first comes first. The second method would convert better, the first method is more "correct".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM