I have a financial system and I have to design a module for save, update and control limitation. You can know each customer has a UserID and each UserID has a maximum amount of credit per day. For example, UserID = 12 has MaxAmountPerDay = 10$ and CurrentAmountPerDay.
At first, I wanted to design a simple module and define a table as follows:
User ID | MaxAmountPerDay | CurrentAmountPerDay
-------------------------------------------------
12 | 10 | 0
25 | 100 | 84
Now you can imagine when the customer with UserID = 12 has done a transaction I have to control if the transaction amount + current amount > max amount then throw an exception else I have to do the transaction and update current amount and when an exception happened after updating I have to rollback the update operation.(update and rollback are in different database transactions so the rollback is the same update with new amount)
Before I do this design I decided to look up for a better solution or even an open source framework for doing that because I guess my customer's requirements will change in future, for example maybe they will need to MaxAmountPerMonth, or some more requirements which I don't know now.
Aucun commentaire:
Enregistrer un commentaire