@@ 5-32 (lines=28) @@ | ||
2 | ||
3 | use C4tech\RayEmitter\Domain\Command; |
|
4 | ||
5 | final class DepositMoney extends Command |
|
6 | { |
|
7 | /** |
|
8 | * Constructor |
|
9 | * |
|
10 | * @param string $account_id Account identifier. |
|
11 | * @param array $data Payload data. |
|
12 | * @param int $sequence Expected version sequence. |
|
13 | */ |
|
14 | public function __construct($account_id, array $data, $sequence = 0) |
|
15 | { |
|
16 | $this->setupPayload(); |
|
17 | $this->target_id = $account_id; |
|
18 | $this->sequence = $sequence; |
|
19 | $this->payload->deposit = $data['deposit']; |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * Run |
|
24 | * |
|
25 | * Push the command into the Aggregate. |
|
26 | * @return void |
|
27 | */ |
|
28 | public function run() |
|
29 | { |
|
30 | Aggregate::handle($this); |
|
31 | } |
|
32 | } |
|
33 |
@@ 5-32 (lines=28) @@ | ||
2 | ||
3 | use C4tech\RayEmitter\Domain\Command; |
|
4 | ||
5 | final class WithdrawMoney extends Command |
|
6 | { |
|
7 | /** |
|
8 | * Constructor |
|
9 | * |
|
10 | * @param string $account_id Account identifier. |
|
11 | * @param array $data Payload data. |
|
12 | * @param int $sequence Expected version sequence. |
|
13 | */ |
|
14 | public function __construct($account_id, array $data, $sequence = 0) |
|
15 | { |
|
16 | $this->setupPayload(); |
|
17 | $this->target_id = $account_id; |
|
18 | $this->sequence = $sequence; |
|
19 | $this->payload->withdrawal = $data['withdrawal']; |
|
20 | } |
|
21 | ||
22 | /** |
|
23 | * Run |
|
24 | * |
|
25 | * Push the command into the Aggregate. |
|
26 | * @return void |
|
27 | */ |
|
28 | public function run() |
|
29 | { |
|
30 | Aggregate::handle($this); |
|
31 | } |
|
32 | } |
|
33 |