PHPackages                             tourze/wechat-mini-program-express-bundle - 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. tourze/wechat-mini-program-express-bundle

ActiveSymfony-bundle

tourze/wechat-mini-program-express-bundle
=========================================

微信小程序同城配送服务，提供即时配送功能及其相关API接口

0.1.0(4mo ago)00MITPHPCI passing

Since Nov 10Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/wechat-mini-program-express-bundle)[ Packagist](https://packagist.org/packages/tourze/wechat-mini-program-express-bundle)[ RSS](/packages/tourze-wechat-mini-program-express-bundle/feed)WikiDiscussions master Synced 1mo ago

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

WechatMiniProgramExpressBundle
==============================

[](#wechatminiprogramexpressbundle)

[![PHP Version](https://camo.githubusercontent.com/6518db1335bf20fdff07253dc6d6d0cec955b5fb6a8ef1382ac6d73687ecc07f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c7565)](https://www.php.net)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](../../LICENSE)[![Build Status](https://camo.githubusercontent.com/b0c6c6845a74cb65a7f0a32bdcfd8fbf80eeb40026c4029af424ab371c94b8bd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e)](#)[![Code Coverage](https://camo.githubusercontent.com/32855e94577df9d0a30995653b17d33a5fbfdf644518f96ea0374313397d19b7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e)](#)

[English](README.md) | [中文](README.zh-CN.md)

微信小程序即时配送API集成组件，提供与微信小程序即时配送平台交互的能力，支持美团、闪送等多家配送服务提供商。

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Advanced Usage](#advanced-usage)
- [Architecture](#architecture)
- [Commands](#commands)
- [API Reference](#api-reference)
- [Security](#security)
- [Dependencies](#dependencies)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **配送公司管理**: 同步和管理支持的配送服务提供商
- **账号绑定**: 管理小程序与配送公司的绑定关系
- **订单操作**: 支持完整的订单生命周期管理
- **查询功能**: 实时查询订单状态和配送信息
- **测试支持**: 提供模拟环境用于开发测试
- **命令行工具**: 提供便捷的数据同步命令

Installation
------------

[](#installation)

```
composer require tourze/wechat-mini-program-express-bundle
```

如果使用Symfony Flex，Bundle会自动注册。否则，手动添加到 `config/bundles.php`：

```
return [
    // ... other bundles
    WechatMiniProgramExpressBundle\WechatMiniProgramExpressBundle::class => ['all' => true],
];
```

Configuration
-------------

[](#configuration)

Bundle无需额外配置，依赖于 `WechatMiniProgramBundle` 的配置。确保已正确配置微信小程序账号信息。

示例配置文件 `config/packages/wechat_mini_program.yaml`：

```
wechat_mini_program:
    default_account: 'your_default_account'
    accounts:
        your_account:
            app_id: 'your_app_id'
            secret: 'your_secret'
```

Usage
-----

[](#usage)

### 基本用法

[](#基本用法)

#### 1. 同步配送公司信息

[](#1-同步配送公司信息)

```
# 同步所有配送公司信息
bin/console wechat-express:sync-delivery-companies

# 同步指定账号的配送公司信息
bin/console wechat-express:sync-delivery-companies --account-id=1
```

### 2. 同步绑定账号

[](#2-同步绑定账号)

```
# 同步所有绑定账号
bin/console wechat-express:sync-bind-accounts

# 同步指定账号的绑定信息
bin/console wechat-express:sync-bind-accounts --account-id=1
```

### 3. 下单流程

[](#3-下单流程)

```
use WechatMiniProgramExpressBundle\Service\DeliveryOrderService;
use WechatMiniProgramExpressBundle\Request\PreAddOrderRequest;
use WechatMiniProgramExpressBundle\Request\AddOrderRequest;

// 获取服务
$deliveryOrderService = $this->container->get(DeliveryOrderService::class);

// 预下单获取配送费
$preOrderRequest = new PreAddOrderRequest();
$preOrderRequest->setAccount($account);
$preOrderRequest->setDeliveryId('delivery_company_id');
$preOrderRequest->setShopId('shop_id');
// ... 设置其他参数

$preOrderResponse = $deliveryOrderService->preAddOrder($preOrderRequest);

// 正式下单
$orderRequest = new AddOrderRequest();
$orderRequest->setAccount($account);
// ... 设置订单参数

$orderResponse = $deliveryOrderService->addOrder($orderRequest);
```

#### 4. 查询订单

[](#4-查询订单)

```
use WechatMiniProgramExpressBundle\Service\OrderQueryService;
use WechatMiniProgramExpressBundle\Request\GetOrderRequest;

$orderQueryService = $this->container->get(OrderQueryService::class);

$queryRequest = new GetOrderRequest();
$queryRequest->setAccount($account);
$queryRequest->setShopOrderId('your_order_id');

$orderInfo = $orderQueryService->getOrder($queryRequest);
```

Advanced Usage
--------------

[](#advanced-usage)

### 自定义订单实体

[](#自定义订单实体)

```
use WechatMiniProgramExpressBundle\Entity\Order;
use WechatMiniProgramExpressBundle\Entity\Embed\SenderInfo;
use WechatMiniProgramExpressBundle\Entity\Embed\ReceiverInfo;

// 创建订单
$order = new Order();

// 设置发送方信息
$senderInfo = new SenderInfo();
$senderInfo->setName('发送方姓名');
$senderInfo->setCity('北京市');
$senderInfo->setAddress('详细地址');
$senderInfo->setPhone('联系电话');
$order->setSenderInfo($senderInfo);

// 设置接收方信息
$receiverInfo = new ReceiverInfo();
$receiverInfo->setName('接收方姓名');
$receiverInfo->setCity('上海市');
$receiverInfo->setAddress('详细地址');
$receiverInfo->setPhone('联系电话');
$order->setReceiverInfo($receiverInfo);

// 转换为请求参数
$requestParams = $order->toRequestArray();
```

### 事件监听

[](#事件监听)

```
// 监听订单创建事件
class OrderCreatedListener
{
    public function onOrderCreated(OrderCreatedEvent $event): void
    {
        $order = $event->getOrder();
        // 处理订单创建后的业务逻辑
    }
}
```

Architecture
------------

[](#architecture)

Bundle采用分层架构和服务职责分离原则：

```
graph TD
    A[WechatMiniProgramExpressBundle] --> B[DeliveryConfigService]
    A --> C[DeliveryOrderService]
    A --> D[OrderQueryService]
    A --> E[MockOrderService]

    B --> F[配送公司与绑定账号管理]
    C --> G[订单创建与修改]
    D --> H[订单查询与异常处理]
    E --> I[订单状态模拟更新]

    B -.依赖.-> J[WechatMiniProgramBundle]
    C -.依赖.-> J
    D -.依赖.-> J
    E -.依赖.-> J

```

### 核心服务

[](#核心服务)

1. **DeliveryConfigService**: 配置管理服务

- 配送公司数据同步与管理
- 商户绑定账号信息维护

2. **DeliveryOrderService**: 订单操作服务

- 预下单、正式下单
- 订单取消、重新下单

3. **OrderQueryService**: 查询服务

- 订单状态查询
- 异常处理

4. **MockOrderService**: 测试服务（仅测试环境）

- 模拟订单状态更新

Commands
--------

[](#commands)

### 同步配送公司列表

[](#同步配送公司列表)

```
bin/console wechat-express:sync-delivery-companies [--account-id=]
```

同步支持的配送公司信息到本地数据库。

**参数:**

- `--account-id`: 可选，指定同步特定账号的配送公司信息

### 同步绑定账号信息

[](#同步绑定账号信息)

```
bin/console wechat-express:sync-bind-accounts [--account-id=]
```

同步已绑定的配送账号信息。

**参数:**

- `--account-id`: 可选，指定同步特定账号的绑定信息

API Reference
-------------

[](#api-reference)

本Bundle集成以下微信小程序即时配送API：

- [获取配送公司列表](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/getAllImmeDelivery.html)
- [拉取已绑定账号](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/getBindAccount.html)
- [预下配送单](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/preAddOrder.html)
- [下配送单](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/addOrder.html)
- [查询配送单信息](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/getOrder.html)
- [取消配送单](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/cancelOrder.html)
- [重新下单](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/reOrder.html)
- [增加小费](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/addTips.html)
- [异常件退回确认](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/immediate-delivery/deliver-by-business/abnormalConfirm.html)

Security
--------

[](#security)

在使用本Bundle时，请注意以下安全事项：

1. **API密钥保护**: 确保微信小程序的AppSecret等敏感信息安全存储，不要硬编码在代码中
2. **数据传输安全**: 所有与微信API的通信都通过HTTPS进行
3. **订单数据保护**: 订单中可能包含用户隐私信息，请确保符合数据保护法规
4. **访问控制**: 实施适当的权限控制，确保只有授权用户可以操作配送订单

Dependencies
------------

[](#dependencies)

- `tourze/wechat-mini-program-bundle`: 微信小程序基础包
- `symfony/framework-bundle`: Symfony框架核心
- `doctrine/orm`: Doctrine ORM

Contributing
------------

[](#contributing)

欢迎贡献代码！请确保：

1. 遵循项目的编码规范
2. 编写相应的测试用例
3. 更新相关文档
4. 提交前运行测试确保通过

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](../../LICENSE) file for details.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance74

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity27

Early-stage or recently created project

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

Total

3

Last Release

141d ago

### Community

Maintainers

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

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-mini-program-express-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-wechat-mini-program-express-bundle/health.svg)](https://phpackages.com/packages/tourze-wechat-mini-program-express-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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