Multiple Aggregates / Repositories in one Transaction

后端 未结 4 1667
长发绾君心
长发绾君心 2020-11-29 01:36

I have a payment system as shown below. The payment can be made through multiple gift coupons. The gift coupons are issued along with a purchase. The customer can make use o

4条回答
  •  独厮守ぢ
    2020-11-29 01:40

    2 approaches:

    • Two separate transactions. If transaction 2 fails, then transaction 1 should be rolled-back.
    • Card is an account. Record transactions against that account. If calcuated balance (adding up all transactions) hits zero (or less, shouldn't happen) then card is 'used'- don't record 'used' in the DB though. Just derive it from the balance.

提交回复
热议问题