77use Bavix \Wallet \Internal \Exceptions \LockProviderNotFoundException ;
88use Bavix \Wallet \Internal \Exceptions \RecordNotFoundException ;
99use Bavix \Wallet \Internal \Service \LockServiceInterface ;
10+ use Bavix \Wallet \Internal \Service \MathServiceInterface ;
1011use Bavix \Wallet \Internal \Service \StateServiceInterface ;
1112use Bavix \Wallet \Internal \Service \StorageServiceInterface ;
1213
@@ -15,7 +16,8 @@ final class StorageServiceLockDecorator implements StorageServiceInterface
1516 public function __construct (
1617 private StorageServiceInterface $ storageService ,
1718 private StateServiceInterface $ stateService ,
18- private LockServiceInterface $ lockService
19+ private LockServiceInterface $ lockService ,
20+ private MathServiceInterface $ mathService
1921 ) {
2022 }
2123
@@ -45,6 +47,11 @@ public function sync(string $uuid, float|int|string $value): bool
4547 */
4648 public function increase (string $ uuid , float |int |string $ value ): string
4749 {
48- return $ this ->lockService ->block ($ uuid , fn () => $ this ->storageService ->increase ($ uuid , $ value ));
50+ return $ this ->lockService ->block ($ uuid , function () use ($ uuid , $ value ): string {
51+ $ result = $ this ->mathService ->add ($ this ->get ($ uuid ), $ value );
52+ $ this ->sync ($ uuid , $ result );
53+
54+ return $ this ->mathService ->round ($ result );
55+ });
4956 }
5057}
0 commit comments