PHPackages                             z-perfe/common-service - 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. z-perfe/common-service

ActiveLibrary

z-perfe/common-service
======================

CommonService

1.1.3(3y ago)020PHPPHP &gt;=7.4

Since Jan 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/z-perfe/common-service)[ Packagist](https://packagist.org/packages/z-perfe/common-service)[ RSS](/packages/z-perfe-common-service/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (7)Used By (0)

common-service
==============

[](#common-service)

### 安装

[](#安装)

> 适用于 laravel PHP 7.4+

> composer require z-perfe/common-service

### 发布配置文件

[](#发布配置文件)

> php artisan vendor:publish --tag=common\_service

> config/common\_service.php文件中,配置APP\_ID等参数

短信服务
----

[](#短信服务)

```
use Zperfe\Common\Service\Sms;

$sms = new Sms();

// 发送短信
$sms->send(string $action, string $mobile, array $params = []);

// 获得可用的动作列表
$sms->getAction();

```

`$sms->send 参数说明`

参数名类型必传说明actionstring是短信的动作名称mobilestring是手机号码paramsarray否动作所需替换的参数---

支付服务
----

[](#支付服务)

```
use Zperfe\Common\Service\OrderPay;

$pay = new OrderPay();

// 订单支付
$pay->pay(int|string $channel_id, string $app_trade_no, string $description, int $amount_total, array $params = [], string $amount_currency = 'THB', array $attach = []);

// 获得可用的支付渠道
$pay->getChannels();

```

`$pay->pay 参数说明`

参数名类型必传说明channel\_idstring or int是使用的渠道代码或IDapp\_trade\_nostring是订单号码, 请保持唯一descriptionstring是订单的商品名称amount\_totalint是订单的金额,单位为最小单位分,需一个正整数paramsarray否部分渠道支付创建时需要的其他参数amount\_currencystring否支付币种,默认THBattacharray否订单附带的其他参数,会随支付结果下发至应用---

```
成功的响应
{
    "status": 1,
    "message": "SUCCESS",
    "data": []
}

```

```
失败的响应
{
    "status": 400,
    "message": "错误的params, 缺乏必须的键：code",
    "code": "BadRequest"
}

```

```
支付结果下发通知
{
	"result_code": "SUCCESS",
	"ordersn": "",
	"app_trade_no": "",
	"notify_type": "PAY",
	"amount_total": '',
	"timestamp": '',
	"sign": ""
}

```

`支付结果下发通知的参数说明`

参数名类型说明result\_codestring支付结果, SUCCESS为成功, FAIL为支付失败ordersnstringCommonService平台产生的订单号码app\_trade\_nostring应用的订单号码amount\_totalint订单的金额,单位为最小单位分,是一个正整数notify\_typestring通知类型, PAY为支付结果通知,REFUND为退款结果通知timestampstring下发结果的时间戳signstring签名, 请一定对支付结果通知进行签名校验---

支付通知的校验方法
---------

[](#支付通知的校验方法)

```
use Zperfe\Common\Service\OrderPay;

$input = $request->all();
$pay = new OrderPay();

// 校验签名
if ($pay->verifySign($input)) {
    // 签名通过
    if ($input['timestamp'] - time() > 60 * 60 * 24) {
        // 可以对下发的时间戳进行判断...
    }
}

```

文件服务
----

[](#文件服务)

### 文件会重新命名

[](#文件会重新命名)

```
use Zperfe\Common\Service\UploadFile;

$upload = new UploadFile();

$file = $request->file('file');
$response = $upload->putFile($file, $path='');

```

`$upload->putFile 参数说明`

参数名类型必传说明fileobject是Illuminate\\Http\\UploadedFile 实例pathstring否路径名称,如此文件已存在,则此参数会忽略---

```
成功的响应
{
    "status": 1,
    "message": "SUCCESS",
    "data": {
        "file": "20230116154453_41591.jpg",
        "full_file": "https://img1.ortmg.com/20230116154453_41591.jpg"
    }
}

```

###  Health Score

23

—

LowBetter than 30% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~2 days

Total

6

Last Release

1161d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/677da7673224f449571ac7c46e8a283d7cb693d1b70f829777bcc583e5af61d1?d=identicon)[zhpefe](/maintainers/zhpefe)

---

Top Contributors

[![z-perfe](https://avatars.githubusercontent.com/u/24883811?v=4)](https://github.com/z-perfe "z-perfe (12 commits)")

### Embed Badge

![Health badge](/badges/z-perfe-common-service/health.svg)

```
[![Health](https://phpackages.com/badges/z-perfe-common-service/health.svg)](https://phpackages.com/packages/z-perfe-common-service)
```

PHPackages © 2026

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