A
A
Alexey Sklyarov2017-08-21 22:51:10
PHP
Alexey Sklyarov, 2017-08-21 22:51:10

How to organize the sale of tickets?

There is a website for the event. I plan to organize the ability for users to choose a seat in a row and order a ticket, after which the purchase is recorded in AmoCRM and so on. The work algorithm came up with the following:
All tickets will be in the database. Each ticket will have a status: purchased. Those tickets that are purchased, we display active checkbox, those that are not - inactive. Formed a block with a choice of tickets.

  1. A person chooses the tickets he needs, just clicks on the squares.
  2. An AJAX request is sent to the server. We check whether the tickets that the user is trying to order have been purchased, if so, we display an error message. I do this so that there is no problem if a person gets a page with only tickets and while he was scrolling through, if someone bought tickets during this time, he found out about it.
  3. If the tickets are not purchased, we send all the data on the order to AMOcrm.
  4. All applications appear in the status: New application.
  5. With each user request (when the application is sent), a script will be executed that will select all SUCCESSFUL applications from AMOcrm, pull out the data and, based on this data, already mark our tickets in the database as purchased

Now I return to the essence of the issue, there are even several of them:
1. How to 100% close the problem when two people simultaneously send a request to the server with the purchase of the SAME and SAME tickets. What to do in this case?
2. Is it possible to somehow optimize the update of purchased tickets in the database? It turns out that every time an application occurs, first tickets in the database will be updated from AMOcrm (based on applications), then it will be checked whether a person is trying to buy a ticket that is no longer there, after which an application will be sent to the crm system and e-mail.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2017-08-21
@0example

"Book" time tickets in one click:

  1. Show all available tickets, where neither "purchased" nor "booked".
  2. By clicking on the ticket with AJAX, mark it as booked for this user: write it in the user's id field. In another field - the time of installation of the armor. The status of the reservation is removed automatically in an hour or two or three.
  3. So the user will see the selected tickets, which are guaranteed not to be bought yet.
  4. Pay or don't pay.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question