承接 ashrafi/laravel-wallet 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ashrafi/laravel-wallet

Composer 安装命令:

composer require ashrafi/laravel-wallet

包简介

Laravel wallet manager.

关键字:

README 文档

README

Wallet Manager can manage user finance with multi accounts and wallets feature.

User can have multi accounts for any purpose of your application. For trading applications you can create a demo account, real account and etc. Each account can has multi wallets to handle your currencies.

Requirements

php: >=7.1

"laravel/framework": "^5.0|^6.0|^7.0|^8.0"

Installation

composer require ashrafi/laravel-wallet:^v0.1

if you want to publish config you can run:

php artisan vendor:publish --tag=wallet-manager-config

publish seeders

php artisan vendor:publish --tag=wallet-manager-seeder

Add seeders to DatabaseSeeder.php

(new CurrencySeeder())->run();
(new TransactionTypeSeeder())->run();

NOTICE: We use \App\User or \App\Models\User class to relate tables to the user and you can bind it to other class that implement iUser::class and bind it on AppServiceProvider

Next you need to run migrate and db:seed to create database tables and seeds:

php artisan migrate
php artisan db:seed

NOTICE: This package will autoload with laravel and you don't need to add \Ashrafi\WalletManager\ServiceProvider::class to your bootstrap.

Structure

  • Facades: This package use facade pattern for models and you can extend and customize themes. To extend models you need add below codes to your AppServiceProvider:

    use Ashrafi\WalletManager\Models\Wallet;
    
    //YOUR CODES
    
    public function register(){
        //YOUR CODES
        //Bind other User class if you don't use \App\User class for authentication
        $this->app->bind(iUser::class, function(){
            return new {YourExtendedClass};
        });
        
        $this->app->extend(Wallet::class, function(){
            return new {YourExtendedClass};
        });
    
    }
  • Commands: List of commands are located in src/Commands and you need to use this commands to work with this package features!

IMPORTANT Don't use WalletManager models directly and just use their facades: WalletModel, AccountModel, CurrencyModel,...

  • Events:

    The package have WalletEvent and AccountEvent to do anything you need to handle.

    • WalletCreating: triggered before create the wallet and after validate input.

    • WalletCreated: triggered after create the wallet.

    • AccountCreating: triggered before create the account and after validate input.

    • AccountCreated: triggered after create the account.

Usages

List of samples are located in samples folder, but you can follow them with this sort: 'transfer', etc).

  • Create Account This command will create an account with multi wallets for given user_id. Exp: You cann create a account for financial or scoring purpose!

  • Change wallet balance This command will charge/withdrawal a wallet. You can create TransactionAmount object which keep +/-amount, type and status.

  • Approve transaction This command will approve transaction and recalculate wallet(s) balance(s).

Value objects
  • TransactionAmount
    Attribute Type Default Description
    amount double 0 posetive amount for charge wallet and negative amount for withdraw
    type string cash Describe type of the transaction. This value should be find in transaction_types table.
    status string pending (pending or approved) If status is on pending value, you need to approve the transaction to unlock freeze amount and change wallet balance. If status is on approved value, you don't need to approve it in panel and this transaction will create with approved status and wallet balance will change automatically.
Adding new transaction type

Each transaction can has seperate table for store related transaction data and validate related data, if so:

  1. Add your new type to transaction_types table.
  2. create new model/class for it and implement iRelatedTransactionTypeValidate class to validate transaction data and implement iRelatedTransactionTypeCreateRecord to insert transaction data to your table.
  3. add new type to wallet_manager.transaction_types.types config file.

Important transaction types

  1. init: This type already is defined and used on create new wallet with init balance.
  2. transfer: This type already is defined and used on transfer a amount from a wallet to an other wallet.
  3. cash: This type already is defined and used on charge or withdraw a cash amount without any extra data. We suggest to you define a new type to handle charge/withdraw transaction to store related data

ashrafi/laravel-wallet 适用场景与选型建议

ashrafi/laravel-wallet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 91 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ui」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ashrafi/laravel-wallet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ashrafi/laravel-wallet 我们能提供哪些服务?
定制开发 / 二次开发

基于 ashrafi/laravel-wallet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 91
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-12