php - Microservice withdrawal problem
PHP中文网
PHP中文网 2017-05-16 13:03:02
0
1
648

There are two existing microservices:

  1. User services.

    User data fields

    uid

    allow_withdraw (1: Withdrawal is allowed, 0: Withdrawal is prohibited)

  2. Financial Services

    Financial system data fields

    account (corresponding to user.uid)
    amount (balance)


Now for the withdrawal function, you need to determine allow_withdraw first, and then determine whether the balance is sufficient.

Add a node /users/withdraw

in users-service

When executing,
will first determine the allow_withdraw status,
and then request /finance/amount in finance-service through HTTP to obtain the balance
Check again whether the balance is sufficient (The problem is here, the judgment here cannot be guaranteed)

What are some good implementation ideas?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
给我你的怀抱

Whether the balance is sufficient should not be judged based on the amount the user withdraws or sets a fixed withdrawal amount? Why can't it be guaranteed? As long as the background comparison amount is inconsistent or exceeds, it will fail.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template