Online hotel reservation system, simultaneous booking?

I ask you to create an online reservation system with online payment, and I’m wondering what to do if 2 customers have booked the same room at the same time.

For instance:
In the same time:

Customer1 and Customer2 are booked for a standard room that has only 1 room. (The availability of the number will show that there is still 1 number). And then they simultaneously press the "confirm" button.

+4
source share
3 answers

Use a lock construct (probably at the database level in this case) to ensure that only one acknowledgment passes immediately. You should always do this if it is possible to have such a race condition. This way you will always know who was the first, and you can tell the other user that they confirm too slowly.

Another thing you can add is the time limit for payment. In many systems, when you confirm something, you will have a certain amount of time to pay. If you do not pay during this time, the confirmation will expire and the room will be available again.

+4
source

There are several ways to deal with this.

  • If the user selects a room, temporarily delete it as accessible from your web interface. Then any subsequent visitors will not be able to select this room for booking. If the first user does not complete the transaction, the room becomes available again.
  • Put the lock in the database as described above, so only one record can be recorded at any time
0
source

Use a “preliminary” system that designates a reservation as temporary, for example, 10 minutes. These slots then become unavailable for subsequent requests. If the reservation is not completed within the time limit, the slot will be released again. If you take all the customer details before you reserve a slot, then the dropout rate should remain low.

You must tell the time frame and its "preliminary status" for the accountant. If you have further steps at which the visitor can stop, a simple JS timer, which counts the time, will help, as well as push the accountant to the process.

Alternatively, enable double booking until the last “pay” button is pressed, when it becomes the first. The second method will convert better, the first method is more "correct".

0
source

Source: https://habr.com/ru/post/1382985/


All Articles