byjg / account-statements
这是一个用于管理PHP中账户报表的简单组件
4.9.2
2024-06-05 01:55 UTC
Requires
- ext-openssl: *
- ext-pdo: *
- byjg/micro-orm: 4.9.*
Requires (Dev)
- byjg/migration: 4.9.*
- phpunit/phpunit: 5.7.*|7.4.*|^9.5
README
这是一个简单的PHP应用程序,允许您创建和管理账户报表。它包含一系列类,允许控制和管理任何账户的报表。
它支持以下功能
- 每个用户可以有多个账户;
- 每个账户可以有多个货币;
- 交易历史记录以避免余额变化;
如何使用
基本用法
use ByJG\AccountStatements\Bll\AccountBLL; use ByJG\AccountStatements\Bll\AccountTypeBLL; use ByJG\AccountStatements\Bll\StatementBLL; use ByJG\AccountStatements\Entity\AccountTypeEntity; use ByJG\AccountStatements\Repository\AccountRepository; use ByJG\AccountStatements\Repository\AccountTypeRepository; use ByJG\AccountStatements\Repository\StatementRepository; use ByJG\AccountStatements\DTO\StatementDTO; // Initiate Repositories $accountTypeRepo = new AccountTypeRepository($this->dbDriver); $statementRepo = new StatementRepository($this->dbDriver); $accountRepo = new AccountRepository($this->dbDriver); // Initiate BLLs $accountTypeBLL = new AccountTypeBLL($accountTypeRepo); $statementBLL = new StatementBLL($statementRepo, $accountRepo); $accountBLL = new AccountBLL($accountRepo, $accountTypeBLL, $statementBLL); // Create a new Account Type $accountType = new AccountTypeEntity(); $accountType->setAccountTypeId('USD'); $accountType->setName('Dollar Account'); $accountTypeBLL = new AccountTypeBLL($accountTypeRepo); $accountTypeBLL->update($accountType); // Create a new Account $accountRepo = new AccountRepository($this->dbDriver); $accountId = $accountBLL->createAccount($accountType->getAccountTypeId(), '34', 0); // Add 200 USD to the account $statement = new StatementDTO($accountId, 200); $statementBLL->addFunds($statement); // Withdraw 100 USD from the account $statement = new StatementDTO($accountId, 100); $statementBLL->withdrawFunds($statement); // Add 50 USD hold to the account $statement = new StatementDTO($accountId, 50); $statementId = $statementBLL->reserveFundsForDeposit($statement); // Accept the hold $statementBLL->acceptFundsById($statementId);
安装
composer require byjg/account-statements
测试
docker run --name mysql-container --rm -e MYSQL_ROOT_PASSWORD=password -p 3306:3306 -d mysql:8.0 ./vendor/bin/phpunit
依赖项
@todo 文档 @todo Rest