@@ -92,10 +92,7 @@ public function applyTransfers(array $objects): array
9292 $ deposit = $ transactions [$ object ->getDepositDto ()->getUuid ()] ?? null ;
9393 assert ($ deposit !== null );
9494
95- $ links [$ deposit ->getKey ()] = $ deposit ;
96- $ links [$ withdraw ->getKey ()] = $ withdraw ;
97-
98- $ transfers [] = $ this ->transferDtoAssembler ->create (
95+ $ transfer = $ this ->transferDtoAssembler ->create (
9996 $ deposit ->getKey (),
10097 $ withdraw ->getKey (),
10198 $ object ->getStatus (),
@@ -104,14 +101,17 @@ public function applyTransfers(array $objects): array
104101 $ object ->getDiscount (),
105102 $ object ->getFee ()
106103 );
104+
105+ $ transfers [] = $ transfer ;
106+ $ links [$ transfer ->getUuid ()] = [
107+ 'deposit ' => $ deposit ,
108+ 'withdraw ' => $ withdraw ,
109+ ];
107110 }
108111
109112 $ models = $ this ->atmService ->makeTransfers ($ transfers );
110113 foreach ($ models as $ model ) {
111- if (isset ($ links [$ model ->deposit_id ], $ links [$ model ->withdraw_id ])) {
112- $ model ->setRelation ('withdraw ' , $ links [$ model ->withdraw_id ]);
113- $ model ->setRelation ('deposit ' , $ links [$ model ->deposit_id ]);
114- }
114+ $ model ->setRelations ($ links [$ model ->uuid ] ?? []);
115115 }
116116
117117 return $ models ;
@@ -128,7 +128,7 @@ public function makeTransaction(
128128 Wallet $ wallet ,
129129 string $ type ,
130130 $ amount ,
131- array | null | ExtraDtoInterface $ meta ,
131+ ? array $ meta ,
132132 bool $ confirmed = true
133133 ): Transaction {
134134 assert (in_array ($ type , [Transaction::TYPE_DEPOSIT , Transaction::TYPE_WITHDRAW ], true ));
@@ -141,7 +141,7 @@ public function makeTransaction(
141141
142142 $ transactions = $ this ->applyTransactions ([
143143 $ dto ->getWalletId () => $ wallet ,
144- ], [$ dto ], );
144+ ], [$ dto ]);
145145
146146 return current ($ transactions );
147147 }
0 commit comments