tourze / wechat-work-group-chat-bundle
企业微信客户群管理和同步功能包
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/wechat-work-group-chat-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- nesbot/carbon: ^2.72 || ^3
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/messenger: ^6.4
- symfony/property-access: ^6.4
- symfony/routing: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/async-contracts: 0.0.*
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/enum-extra: 0.1.*
- tourze/http-client-bundle: 0.1.*
- tourze/symfony-cron-job-bundle: 0.1.*
- tourze/wechat-work-bundle: 0.1.*
- tourze/wechat-work-contracts: 0.0.*
- tourze/wechat-work-external-contact-bundle: 0.0.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-01 19:33:17 UTC
README
[]
(https://packagist.org/packages/tourze/wechat-work-group-chat-bundle)
[
]
(https://packagist.org/packages/tourze/wechat-work-group-chat-bundle)
[
]
(https://packagist.org/packages/tourze/wechat-work-group-chat-bundle)
[
]
(https://github.com/tourze/monorepo/actions)
[
]
(https://codecov.io/gh/tourze/monorepo)
A Symfony bundle for managing WeChat Work group chats (customer groups). This bundle provides entities, repositories, and synchronization functionality for WeChat Work group chat data.
Table of Contents
- Features
- Requirements
- Installation
- Configuration
- Quick Start
- Usage
- Repositories
- Advanced Usage
- API Integration
- Development
- Contributing
- License
- Documentation
Features
- Group chat and member entity management
- Automatic synchronization of group chat data from WeChat Work API
- Support for group chat status tracking (normal, resigned, inheritance in progress, inheritance completed)
- Message queue integration for asynchronous processing
Requirements
- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM
- Symfony Messenger
Installation
composer require tourze/wechat-work-group-chat-bundle
Configuration
This bundle automatically configures itself when installed. No additional configuration is required for basic usage.
Quick Start
<?php use WechatWorkGroupChatBundle\Entity\GroupChat; use WechatWorkGroupChatBundle\Entity\GroupMember; use WechatWorkGroupChatBundle\Repository\GroupChatRepository; // Get all group chats $groupChats = $entityManager->getRepository(GroupChat::class)->findAll(); // Find group chat by specific criteria $groupChat = $entityManager->getRepository(GroupChat::class)->findOneBy(['chatId' => 'chat_id']); // Get group members $members = $entityManager->getRepository(GroupMember::class)->findBy(['groupChat' => $groupChat]); // Sync group chat data using console command // php bin/console wechat-work:sync-group-chat-list
Usage
Entities
GroupChat
Represents a WeChat Work customer group with the following properties:
- Chat ID
- Group name
- Status (normal, resigned, inheritance in progress, inheritance completed)
- Owner (user association)
- Admin list
- Member count
- Creation time
- Notice (group announcement)
GroupMember
Represents a member of a group chat with properties:
- Member type (internal/external)
- User ID
- Join scene (direct invitation, invitation link, QR code)
- Join time
- Invitor information
Console Commands
wechat-work:sync-group-chat-list
Synchronizes customer group data from WeChat Work to local database.
# Sync all group chats php bin/console wechat-work:sync-group-chat-list # The command is also configured as a cron job to run daily at 6:14 AM
Repositories
GroupChatRepository: Provides methods for querying group chatsGroupMemberRepository: Provides methods for querying group members
Advanced Usage
Custom Repository Methods
<?php // Custom query for active group chats $activeChats = $groupChatRepository->findBy(['status' => GroupChatStatus::NORMAL]); // Get groups with member count $groupsWithMembers = $groupChatRepository ->createQueryBuilder('g') ->select('g, COUNT(m.id) as memberCount') ->leftJoin('g.members', 'm') ->groupBy('g.id') ->getQuery() ->getResult();
Event Integration
The bundle dispatches events during synchronization that you can listen to:
<?php use Symfony\Component\EventDispatcher\EventSubscriberInterface; class GroupChatSyncSubscriber implements EventSubscriberInterface { public function onGroupChatSynced(GroupChatSyncedEvent $event): void { // Custom logic after group chat sync } public static function getSubscribedEvents(): array { return [ GroupChatSyncedEvent::class => 'onGroupChatSynced', ]; } }
Message Handlers
The bundle includes asynchronous message handlers for processing group chat synchronization:
SyncGroupChatDetailHandler: Processes individual group chat detail synchronization
Enumerations
GroupChatStatus
NORMAL(0): Following person is normalRESIGN(1): Following person has resignedINHERIT_DOING(2): Resignation inheritance in progressINHERIT_FINISHED(3): Resignation inheritance completed
API Integration
This bundle integrates with the WeChat Work API for:
- Getting group chat lists
- Getting group chat details
- Synchronizing member information
Development
Running Tests
# Run all tests ./vendor/bin/phpunit packages/wechat-work-group-chat-bundle/tests # Run PHPStan analysis php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/wechat-work-group-chat-bundle
Contributing
Please see CONTRIBUTING.md for details on how to contribute to this project.
- Submit bug reports and feature requests through GitHub issues
- Follow the coding standards and testing requirements
- Ensure all tests pass before submitting pull requests
License
The MIT License (MIT). Please see License File for more information.