We started improving from the moment the order was assigned: we calculated the distance that the courier needs to overcome relative to his current position to the restaurant and from the restaurant to the client. To do this, we use an Open Source service that can build routes and calculate time and distance using the transmitted coordinates. Thus, we get two segments:
from the current position of the courier to the restaurant (in logistics it is commonly called the first mile);
and from the restaurant to the client (last mile).
Now we need to calculate the forecast for each participant in the order - the courier, the restaurant, and the customer. This can be done using the formulas:
atVendor (time to arrive at the restaurant) = acceptOrderTime + firstMileTime
pickupTime (time to pick up order from restaurant) = atVendor + cookingTime
atClient (time to be at the client) = pickupTime + lastMileTime
After the calculation, we give forecasts to each participant in the order. Here we can set various coefficients and additional stages of delivery: parking at the restaurant or the client, if the courier is in a car, or the duration of the courier's delay at the client, which depends on the type of payment for the order (cash or card).