PHPackages                             buer/asset - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. buer/asset

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

buer/asset
==========

Finance packagist

3.0.0(3mo ago)41.1k↓55%MITPHPPHP &gt;=5.6.0

Since Jun 20Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/buer2202/asset)[ Packagist](https://packagist.org/packages/buer/asset)[ RSS](/packages/buer-asset/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (15)Used By (0)

Laravel Asset 1.1
-----------------

[](#laravel-asset-11)

用户资金管理系统

框架要求
----

[](#框架要求)

Laravel &gt;= 5.1

安装
--

[](#安装)

```
composer require buer/asset

```

配置
--

[](#配置)

1.在 config/app.php 注册 ServiceProvider 和 Facade (Laravel 5.5 无需手动注册)

```
'providers' => [
    // ...
    Buer\Asset\AssetServiceProvider::class,
],
'aliases' => [
    // ...
    'Asset' => Buer\Asset\AssetFacade::class,
],

```

数据迁移
----

[](#数据迁移)

```
php artisan migrate

```

laravel5.4迁移时因编码问题会抛异常索引key过长。解决问题，2个办法：

1.升级MySql版本到5.5.3以上。

2.手动配置迁移命令migrate生成的默认字符串长度，在AppServiceProvider中调用Schema::defaultStringLength方法来实现配置：

```
use Illuminate\Support\Facades\Schema;

public function boot()
{
   Schema::defaultStringLength(191);
}

```

拷贝配置文件
------

[](#拷贝配置文件)

```
php artisan vendor:publish

```

若成功，则会生成文件config/asset.php, 其中：

type代表交易类型，禁止修改。

sub\_type是子类型，可以自定义。

程序调用
----

[](#程序调用)

使用Asset门面

```
use Asset;

#...

Asset::recharge(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 加款
Asset::freeze(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 冻结
Asset::withdraw(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 提现
Asset::unfreeze(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 解冻
Asset::consume(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 从余额扣款
Asset::consume(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象, 'frozen'); // 从冻结扣款
Asset::refund(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 退款
Asset::expend(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 从余额支出
Asset::expend(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象, 'frozen'); // 从冻结支出
Asset::income(金额, 子类型, '订单号', '备注', 用户ID, 管理员ID, 关联模型对象); // 收入
Asset::transfer('金额', 子类型, '订单号', '备注', '转出用户ID', '转入用户ID', '管理员ID', '关联模型对象'); // 转账

```

传关联模型对象参数时，需要在模型中使用此trait

```
use Buer\Asset\Models\Relations\AssetAmountMorphMany;

class YourModel extends Model
{
    use AssetAmountMorphMany;
}

```

日结
--

[](#日结)

每天需要执行一次日结命令，执行时间不限，默认结算前一天的数据:

```
php artisan daily-settlement:user-asset
php artisan daily-settlement:platform-asset

```

若漏做，可以使用日期参数补做，补做日期为结算当前日期:

```
php artisan daily-settlement:user-asset 20180620
php artisan daily-settlement:platform-asset 20180620

```

对账
--

[](#对账)

用户对账：

```
剩余金额 + 冻结金额 = 累计平台加款 + 累计平台退款 + 累计交易收入 - 累计平台提现 - 累计平台消费 - 累计交易支出

```

平台对账:

```
累计用户加款 - 累计用户提现 = 平台资金 + 托管资金 + 用户总余额 + 用户总冻结

```

字段都在数据库中。

异常
--

[](#异常)

异常默认会抛出AssetException，可以在配置asset.php中自定义exception\_class为你的异常类。

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance80

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~217 days

Recently: every ~515 days

Total

14

Last Release

103d ago

Major Versions

2.4.2 → 3.0.02026-03-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12657347?v=4)[Buer](/maintainers/buer2202)[@buer2202](https://github.com/buer2202)

---

Top Contributors

[![buer2202](https://avatars.githubusercontent.com/u/12657347?v=4)](https://github.com/buer2202 "buer2202 (52 commits)")

### Embed Badge

![Health badge](/badges/buer-asset/health.svg)

```
[![Health](https://phpackages.com/badges/buer-asset/health.svg)](https://phpackages.com/packages/buer-asset)
```

###  Alternatives

[rappasoft/laravel-patches

Run patches migration style in your Laravel applications.

5175.0k](/packages/rappasoft-laravel-patches)[kunstmaan/utilities-bundle

The KunstmaanUtilitiesBundle makes your life easier by providing a couple of small but usefull helper services you can use and re-use in your applications. We already implemented an easy to use cipher service and a shell helper service for you but feel free to send in a pull request with your additions. The shell helper allows you to run apps in the background, see if a process is running and has a method to kill a running process. The cipher service allow you to encode and decode strings using the Rijndael 256 cipher

12152.1k6](/packages/kunstmaan-utilities-bundle)[dusanbre/laravel-tolgee

Help with Laravel integration of Tolgee service

146.6k](/packages/dusanbre-laravel-tolgee)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
