PHPackages                             tourze/hotel-agent-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/hotel-agent-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/hotel-agent-bundle
=========================

酒店代理管理系统，提供代理商管理、订单处理和佣金计算功能

0.0.2(11mo ago)0161MITPHPPHP ^8.1CI passing

Since May 24Pushed 4mo agoCompare

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

READMEChangelog (2)Dependencies (32)Versions (3)Used By (1)

hotel-agent-bundle
==================

[](#hotel-agent-bundle)

[![PHP Version Require](https://camo.githubusercontent.com/c9f64f714c636ba27a3bba6dfd52f98426832db1262747efa54b212d16943651/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d626c7565)](https://packagist.org/packages/tourze/hotel-agent-bundle)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![Build Status](https://camo.githubusercontent.com/07c5a0015c097e0dfbb44d4220df0eed6a623d83eceb02ac299fe96b8e4e1a73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f63692e796d6c3f6272616e63683d6d6173746572)](https://github.com/tourze/php-monorepo/actions)[!\[Coverage Status\](https://img.shields.io/codecov/c/github/ tourze/php-monorepo)](https://codecov.io/gh/tourze/php-monorepo)

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

Hotel agent management module for handling hotel distribution, agent accounts, orders, and billing.

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

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Dependencies](#dependencies)
- [Usage](#usage)
    - [Managing Agents](#managing-agents)
    - [Working with Orders](#working-with-orders)
- [Commands](#commands)
    - [Agent Commands](#agent-commands)
    - [Bill Commands](#bill-commands)
- [Configuration](#configuration)
- [Advanced Usage](#advanced-usage)
    - [Custom Agent Code Generation](#custom-agent-code-generation)
    - [Bill Audit Workflow Customization](#bill-audit-workflow-customization)
    - [Order Import with Custom Validation](#order-import-with-custom-validation)
- [Entities](#entities)
- [Enums](#enums)
- [Services](#services)
- [Events](#events)
- [Admin Interface](#admin-interface)
- [Testing](#testing)
- [License](#license)

Features
--------

[](#features)

- Agent account management (creation, status management, commission rates)
- Hotel-agent mapping configuration
- Order management and processing
- Payment tracking and reconciliation
- Monthly billing generation and audit
- Comprehensive reporting and export capabilities
- EasyAdmin integration for backend management

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

[](#installation)

```
composer require tourze/hotel-agent-bundle
```

Quick Start
-----------

[](#quick-start)

1. Install the bundle:

    ```
    composer require tourze/hotel-agent-bundle
    ```
2. Register the bundle in your Symfony application:

    ```
    // config/bundles.php
    return [
        // ... other bundles
        Tourze\HotelAgentBundle\HotelAgentBundle::class => ['all' => true],
    ];
    ```
3. Update your database schema:

    ```
    php bin/console doctrine:migrations:migrate
    ```
4. Create your first agent:

    ```
    php bin/console doctrine:fixtures:load --group=agent-demo
    ```

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

[](#dependencies)

This bundle requires the following packages:

- **PHP 8.2+**: Modern PHP features and performance
- **Symfony 7.3+**: Framework foundation
- **Doctrine ORM 3.0+**: Database abstraction and ORM
- **EasyAdmin 4+**: Admin interface
- **PHPOffice/PhpSpreadsheet**: Excel import/export functionality

Internal dependencies:

- `tourze/hotel-profile-bundle`: Hotel and room type management
- `tourze/hotel-contract-bundle`: Inventory and pricing contracts
- `tourze/doctrine-timestamp-bundle`: Automatic timestamp handling
- `tourze/easy-admin-menu-bundle`: Admin menu integration

Usage
-----

[](#usage)

### Managing Agents

[](#managing-agents)

```
use Tourze\HotelAgentBundle\Service\AgentBillService;
use Tourze\HotelAgentBundle\Service\OrderCreationService;

// Inject services via constructor
class YourController
{
    public function __construct(
        private AgentBillService $agentBillService,
        private OrderCreationService $orderCreationService
    ) {}

    public function createOrder(Agent $agent, array $orderData): Order
    {
        return $this->orderCreationService->createFromArray($orderData, $agent);
    }

    public function generateAgentBill(Agent $agent, string $month): AgentBill
    {
        return $this->agentBillService->generateMonthlyBill($agent, $month);
    }
}
```

### Working with Orders

[](#working-with-orders)

```
// Create an order with validation
$order = $orderCreationService->createFromArray([
    'hotelId' => 1,
    'roomTypeId' => 2,
    'checkInDate' => '2024-01-15',
    'checkOutDate' => '2024-01-17',
    'roomCount' => 2,
    'guestName' => 'John Doe',
    'guestPhone' => '+1234567890'
], $agent);

// Update order status
$orderStatusService->updateStatus($order, OrderStatusEnum::CONFIRMED);
```

Commands
--------

[](#commands)

The bundle provides several console commands for agent and billing management.

Agent Commands
--------------

[](#agent-commands)

### agent:check-expired

[](#agentcheck-expired)

Check and update expired agent account statuses.

```
# Check expired agents and update their status
php bin/console agent:check-expired

# Dry run mode - only show what would be updated
php bin/console agent:check-expired --dry-run

# Check agents expiring within 30 days
php bin/console agent:check-expired --days=30
```

Options:

- `--dry-run`: Show what would be updated without making changes
- `--days`: Number of days to check for upcoming expirations (default: 7)

Bill Commands
-------------

[](#bill-commands)

### app:generate-monthly-bills

[](#appgenerate-monthly-bills)

Automatically generate monthly settlement bills for agents.

```
# Generate bills for the previous month
php bin/console app:generate-monthly-bills

# Generate bills for a specific month
php bin/console app:generate-monthly-bills 2024-01

# Force regenerate existing bills
php bin/console app:generate-monthly-bills --force

# Dry run mode - preview what would be generated
php bin/console app:generate-monthly-bills --dry-run
```

Arguments:

- `billMonth`: Bill month in YYYY-MM format (optional, defaults to previous month)

Options:

- `--force, -f`: Force regenerate existing bills
- `--dry-run`: Preview mode without creating actual bills

Recommended cron setup (run on the 1st of each month):

```
0 2 1 * * php /path/to/bin/console app:generate-monthly-bills
```

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

[](#configuration)

The bundle automatically registers its services and entities. No additional configuration is required for basic usage.

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

[](#advanced-usage)

### Custom Agent Code Generation

[](#custom-agent-code-generation)

```
use Tourze\HotelAgentBundle\Service\AgentCodeGenerator;

class CustomAgentCodeGenerator extends AgentCodeGenerator
{
    public function generateCode(): string
    {
        // Custom logic for agent code generation
        return 'AGT' . date('Y') . sprintf('%04d', rand(1, 9999));
    }
}
```

### Bill Audit Workflow Customization

[](#bill-audit-workflow-customization)

```
use Tourze\HotelAgentBundle\Service\BillAuditService;
use Tourze\HotelAgentBundle\Entity\AgentBill;

class CustomBillAuditService extends BillAuditService
{
    public function audit(AgentBill $bill, string $decision, string $comment = ''): bool
    {
        // Custom audit logic
        if ($this->performCustomValidation($bill)) {
            return parent::audit($bill, $decision, $comment);
        }

        return false;
    }

    private function performCustomValidation(AgentBill $bill): bool
    {
        // Your custom validation logic
        return true;
    }
}
```

### Order Import with Custom Validation

[](#order-import-with-custom-validation)

```
use Tourze\HotelAgentBundle\Service\OrderImportService;

class CustomOrderImportService extends OrderImportService
{
    protected function validateRowData(array $rowData): bool
    {
        // Add custom validation rules
        if (!parent::validateRowData($rowData)) {
            return false;
        }

        // Additional custom checks
        return $this->performBusinessRuleValidation($rowData);
    }
}
```

Entities
--------

[](#entities)

- **Agent**: Represents hotel distribution agents with commission rates and status
- **AgentBill**: Monthly settlement bills for agents
- **AgentHotelMapping**: Maps agents to hotels they can sell
- **Order**: Hotel booking orders placed by agents
- **OrderItem**: Individual room bookings within an order
- **Payment**: Payment records for orders
- **BillAuditLog**: Audit trail for bill approvals and rejections

Enums
-----

[](#enums)

- **AgentStatusEnum**: ACTIVE, FROZEN, DISABLED, EXPIRED
- **AgentLevelEnum**: BRONZE, SILVER, GOLD, PLATINUM, DIAMOND
- **BillStatusEnum**: DRAFT, PENDING\_AUDIT, AUDITED, REJECTED, PAID
- **OrderStatusEnum**: PENDING, CONFIRMED, CANCELLED, COMPLETED, CLOSED
- **PaymentStatusEnum**: PENDING, PROCESSING, SUCCESS, FAILED, REFUNDED

Services
--------

[](#services)

- **AgentBillService**: Handles monthly bill generation and calculations
- **BillAuditService**: Manages bill approval workflow
- **OrderCreationService**: Creates orders with validation
- **OrderStatusService**: Manages order state transitions
- **PaymentService**: Processes payments and refunds
- **OrderImportService**: Imports orders from Excel files
- **AgentCodeGenerator**: Generates unique agent codes

Events
------

[](#events)

- Agent code auto-generation on creation
- Order item inventory synchronization
- Bill status change tracking

Admin Interface
---------------

[](#admin-interface)

The bundle provides EasyAdmin CRUD controllers for:

- Agent management
- Order management with bulk operations
- Payment tracking
- Bill approval workflow
- Comprehensive reporting dashboards
- Data export functionality

Testing
-------

[](#testing)

```
# Run all tests
./vendor/bin/phpunit packages/hotel-agent-bundle/tests

# Run specific test categories
./vendor/bin/phpunit packages/hotel-agent-bundle/tests/Entity
./vendor/bin/phpunit packages/hotel-agent-bundle/tests/Service
./vendor/bin/phpunit packages/hotel-agent-bundle/tests/Controller

# Run with coverage
./vendor/bin/phpunit packages/hotel-agent-bundle/tests --coverage-html=coverage

# Run quality checks
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/hotel-agent-bundle
```

License
-------

[](#license)

MIT

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance68

Regular maintenance activity

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

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

Total

2

Last Release

349d 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 (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-hotel-agent-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-hotel-agent-bundle/health.svg)](https://phpackages.com/packages/tourze-hotel-agent-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M647](/packages/sylius-sylius)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[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)[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)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

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