am developing an app that has list of products where each product can be rented by users.
each product has :
1- stock
2- availability
am using firebase as backend , here is the use case:
let's say product X has a stock of 3 .
and a user named (A) wanted to rent it for 3 days from 1/1/2021 - 2/1/2021 - 3/1/2021
the user (A) has set that he wanted a quantity of 1 .
so logically the stock will be reduced to become 2 for the dates he chose but remain 3 in the remaining dates . so when a customer called (B) selects the same dates he should be able to see that the product is available but only a stock of 2.
but if customer (A) booked all the stock (3) on those dates and a new customer (B) selected the same dates then the product should not be available but if customer (B) selected other dates then it should show the Stock as (3) and the product available.
am using flutter for the mobile app and firebase as backend with cloud functions.
how to achieve this please.
thanks
question from:
https://stackoverflow.com/questions/65890254/what-is-product-renting-firebase-best-approach 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…