PHPackages                             maxsihong/wd-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. maxsihong/wd-service

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

maxsihong/wd-service
====================

微店服务商扩展

v1.0.1(2y ago)331MITPHPPHP &gt;=7.3

Since May 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/MaxSihong/wd-service)[ Packagist](https://packagist.org/packages/maxsihong/wd-service)[ RSS](/packages/maxsihong-wd-service/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

[微店服务商扩展](https://github.com/MaxSihong/wd-service)
==================================================

[](#微店服务商扩展)

📦 微店服务商扩展是一个基于PHP的扩展，用于在微店平台上开发服务商应用。

[![GitHub code size in bytes](https://camo.githubusercontent.com/ea6e8d04d841d068f694a6e33e5dff26a5d288b05f06e37124b71dd2b7579a67/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f4d61785369686f6e672f77642d73657276696365)](https://camo.githubusercontent.com/ea6e8d04d841d068f694a6e33e5dff26a5d288b05f06e37124b71dd2b7579a67/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f4d61785369686f6e672f77642d73657276696365)[![Latest Stable Version](https://camo.githubusercontent.com/f6eb0ed1865766ed7eb4441758e87e33e42c3c594a4df3375f7a79da1bf1cb13/68747470733a2f2f706f7365722e707567782e6f72672f4d61785369686f6e672f77642d736572766963652f762f737461626c652e737667)](https://packagist.org/packages/MaxSihong/wd-servicet)[![Latest Unstable Version](https://camo.githubusercontent.com/1bc3d6d507d1ac1ba0252ac1a4aac956476d43543d2ddcf51319125e7e74aafb/68747470733a2f2f706f7365722e707567782e6f72672f4d61785369686f6e672f77642d736572766963652f762f756e737461626c652e737667)](https://packagist.org/packages/MaxSihong/wd-service)[![Total Downloads](https://camo.githubusercontent.com/69354b1493c33438fdff0835524575e3a18c919d7f6373610b071ba939d5a242/68747470733a2f2f706f7365722e707567782e6f72672f4d61785369686f6e672f77642d736572766963652f646f776e6c6f616473)](https://packagist.org/packages/MaxSihong/wd-service)[![License](https://camo.githubusercontent.com/3c76550e0f1c50554751d0a422d789a427fc21331fc2c68d7e93c812d05569fe/68747470733a2f2f706f7365722e707567782e6f72672f4d61785369686f6e672f77642d736572766963652f6c6963656e7365)](https://packagist.org/packages/MaxSihong/wd-service)

[![Security Status](https://camo.githubusercontent.com/6314246cdc4a62dd5a95c3699ecc2d1f76dedb5bdc4a942ee21f41f6d763e198/68747470733a2f2f7777772e6d75727068797365632e636f6d2f706c6174666f726d332f7633312f62616467652f313637353831343832373939323034373631362e737667)](https://www.murphysec.com/console/report/1659398248208613376/1675814827992047616)

📑 目录
----

[](#-目录)

- [进度](#-%E8%BF%9B%E5%BA%A6)
- [环境需求](#-%E7%8E%AF%E5%A2%83%E9%9C%80%E6%B1%82)
- [注意事项](#-%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9)
- [安装](#-%E5%AE%89%E8%A3%85)
- [使用示例](#-%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B)
- [Laravel 使用示例](#-laravel-%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B)
- [相关文档](#-%E7%9B%B8%E5%85%B3%E6%96%87%E6%A1%A3)
- [License](#-license)

🚧 进度
----

[](#-进度)

> 目前只打算把订单、商品模块整体封装，剩余模块后续看情况添加吧。如果需要其他模块使用可以自行 Fork 并提交合并，或者联系我协助添加。

- 项目搭建、容器封装、基础接口封装
- 【订单管理】接口封装
- 【商品管理】接口封装 (57%)

⚠ 注意事项
------

[](#-注意事项)

> 项目如需接收微店的消息推送，则需要添加个每天执行的定时任务，主动刷新用户的 `access_token`。 因为微店要求如果 `access_token`无效的话，则不会主动推送消息通知。 定时任务：`Maxsihong\WdService\Commands\WdRefreshAccessToken`

🏃 环境需求
------

[](#-环境需求)

- PHP &gt;= 7.3.0

🚀 安装
----

[](#-安装)

```
composer require maxsihong/wd-service
```

🙂 使用示例
------

[](#-使用示例)

实例化:

```
// 配置
$config = [
    'app_id' => '1xxxxxx', // 服务商appid
    'app_secret' => 'axxxxxx', // 服务商secret
    'domain' => 'https://api.vdian.com/api', // 微店api地址
    'redirect_uri' => 'https://xxx.com/callback', // 注意 xxx.com 为你服务商授权的推送域名，微店有白名单限制；后面的 callback 可自定义,改地址是回调接收微店返回的code和state，后续进行调用获取token操作
    // redis
    'cache' => [
        "host" => "127.0.0.1",
        "port" => 6379,
        "database" => 0, // 选择redis库,0~15 共16个库
        "password" => "", // 密码
        'prefix' => 'wdcache_', // 前缀
    ],
];
// 相关用户和店铺（可不传），但后面记得需要初始化这两个值
$init_param = ['uid' => 1, 'openid' => '1xxxx'];

$app = new \Maxsihong\WdService\Entrance($config, $init_param);

/**
 * 注意 后面的参数可不传是不影响创建容器的，默认是uid-0；但后面记得需要初始化这两个值(`reSetUidAndOpenidAndCacheKey`)，因为缓存都是基于这两个值存储的
 * 可以理解为uid是用户，而openid则是店铺，一个用户有多个店铺，这样的关系；
 * 所以后续存储缓存，包括access_token都是基于uid和openid为base_key做缓存的
 */
```

使用

```
// 加密数据
$str = $app::wdCommon()->encrypt('123456789');
```

🙂 Laravel 使用示例
--------------

[](#-laravel-使用示例)

注册服务

```
// 在 `App\Providers\AppServiceProvider` 类
public function register()
{
    // 注册 微店 服务容器
    $this->app->bind("onlineretailers.wd", function ($app, $init_param) {
        /**
        * 初始化用户uid，这个判断可根据自己业务来判断是否需要
        * 不加的话则直接初始化即可：$init_param['uid'] = $init_param['uid'] ?? 0;
         */
        if (empty($init_param) || !isset($init_param['uid'])) {
            throw new \Maxsihong\WdService\Kernel\Exception\ApiException('必须要初始化用户uid');
        }

        $init_param['openid'] = $init_param['openid'] ?? '';

        // $config 可放如config内，使用config('xx')获取
        return new \Maxsihong\WdService\Entrance($config, $init_param);
    });
}
```

使用

```
// 获取容器
// 想要idea更好的提示，可增加下面 @var 的注释
/** @var \Maxsihong\WdService\Entrance $app */
$app = app('onlineretailers.wd', ['uid' => 1, 'openid' => '1xxxx']);
// 加密数据
$str = $app::wdCommon()->encrypt('123456789');
```

📝 相关文档
------

[](#-相关文档)

- [微店开放平台](https://open.weidian.com/#/index)
- [微店开放平台 - 接入指南](https://open.weidian.com/#/guide/150)
- [微店开放平台 - 消息推送](https://open.weidian.com/#/guide/147)

🤝 License
---------

[](#-license)

MIT

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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

Total

4

Last Release

1040d ago

Major Versions

v0.0.6 → v1.0.02023-05-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce84bdd211a50368701bd4de92ec3e24d25b177c667c5dda82f79ab83e495022?d=identicon)[MaxSihong](/maintainers/MaxSihong)

---

Top Contributors

[![MaxSihong](https://avatars.githubusercontent.com/u/29353447?v=4)](https://github.com/MaxSihong "MaxSihong (6 commits)")

---

Tags

sdkwdweidianwd-sdkweidian-sdk

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maxsihong-wd-service/health.svg)

```
[![Health](https://phpackages.com/badges/maxsihong-wd-service/health.svg)](https://phpackages.com/packages/maxsihong-wd-service)
```

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

416300.1M4](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

409.5M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29016.1k1](/packages/ennnnny-tbk)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)

PHPackages © 2026

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