tourze/coupon-wechat-mini-program-bundle

微信小程序优惠券配置管理系统

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Type:symfony-bundle

pkg:composer/tourze/coupon-wechat-mini-program-bundle

This package is auto-updated.

Last update: 2025-11-03 06:18:55 UTC


README

English | 中文

PHP Version Latest Version License Build Status Quality Score Code Coverage Total Downloads

A Symfony bundle for integrating WeChat Mini Program functionality with the coupon system.

Table of Contents

Features

  • WeChat Mini Program configuration management
  • Coupon integration with WeChat Mini Program
  • AppID and path configuration
  • Environment version support
  • Doctrine ORM integration
  • RESTful API support

Installation

composer require tourze/coupon-wechat-mini-program-bundle

Quick Start

1. Register the bundle

// config/bundles.php
return [
    // ...
    Tourze\CouponWechatMiniProgramBundle\CouponWechatMiniProgramBundle::class => ['all' => true],
];

2. Create and configure WeChat Mini Program

<?php

use Tourze\CouponWechatMiniProgramBundle\Entity\WechatMiniProgramConfig;
use Tourze\CouponCoreBundle\Entity\Coupon;

// Create configuration
$config = new WechatMiniProgramConfig();
$config->setAppId('your-wechat-app-id');
$config->setPath('pages/coupon/detail');
$config->setEnvVersion('release');
$config->setCoupon($coupon);

// Persist to database
$entityManager->persist($config);
$entityManager->flush();

3. Retrieve configuration

<?php

use Tourze\CouponWechatMiniProgramBundle\Repository\WechatMiniProgramConfigRepository;

// Get configuration by coupon
$config = $repository->findOneBy(['coupon' => $coupon]);

// Get API array representation
$apiData = $config->retrieveApiArray();

Configuration

The bundle provides the following configuration options:

  • appId: WeChat Mini Program App ID
  • path: Jump path within the mini program
  • envVersion: Mini program environment version (release/trial/develop)

API Integration

The WechatMiniProgramConfig entity implements ApiArrayInterface and provides serialization groups for RESTful APIs:

// Get API representation
$apiArray = $config->retrieveApiArray();
// Returns: ['id', 'createTime', 'updateTime', 'appId', 'envVersion', 'path']

Advanced Usage

Custom Repository Methods

<?php

use Tourze\CouponWechatMiniProgramBundle\Repository\WechatMiniProgramConfigRepository;

// Find configurations by App ID
$configs = $repository->findBy(['appId' => 'your-app-id']);

// Find configurations with specific environment
$configs = $repository->findBy(['envVersion' => 'release']);

Validation Constraints

The entity includes automatic validation:

  • AppID: Required, max 100 characters
  • Environment Version: Optional, max 20 characters
  • Path: Optional, max 255 characters

Database Schema

The bundle creates a coupon_wechat_mini_program_config table with the following fields:

  • id: Snowflake ID (primary key)
  • coupon_id: Foreign key to coupon table
  • app_id: WeChat Mini Program App ID
  • env_version: Environment version
  • path: Jump path
  • Timestamp fields (created_at, updated_at)
  • User tracking fields (created_by, updated_by)
  • IP tracking fields

Requirements

  • PHP 8.1+
  • Symfony 7.3+
  • Doctrine ORM 3.0+
  • Doctrine DBAL 4.0+

Testing

The bundle includes comprehensive test coverage:

  • Unit tests for entity functionality
  • Integration tests for repository operations
  • Isolated test environment to avoid external dependencies

Run tests with:

./vendor/bin/phpunit packages/coupon-wechat-mini-program-bundle/tests

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.