PHPackages                             tourze/product-auto-up-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/product-auto-up-bundle

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

tourze/product-auto-up-bundle
=============================

商品自动上架功能

0.0.1(6mo ago)00MITPHPCI failing

Since Nov 13Pushed 4mo agoCompare

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

READMEChangelog (1)Dependencies (44)Versions (2)Used By (0)

ProductAutoUpBundle
===================

[](#productautoupbundle)

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

商品自动上架功能模块，提供商品定时上架的功能。

功能特性
----

[](#功能特性)

- **自动上架调度**：支持设置商品的自动上架时间
- **日志记录**：完整记录自动上架的执行过程和结果
- **异常处理**：妥善处理各种异常情况，确保系统稳定性
- **管理界面**：提供EasyAdmin管理界面进行配置和日志查看

安装配置
----

[](#安装配置)

### 1. Bundle 注册

[](#1-bundle-注册)

在 `config/bundles.php` 中添加：

```
return [
    // ...
    Tourze\ProductAutoUpBundle\ProductAutoUpBundle::class => ['all' => true],
];
```

### 2. 数据库迁移

[](#2-数据库迁移)

```
php bin/console doctrine:migrations:migrate
```

### 3. 配置定时任务

[](#3-配置定时任务)

在系统 crontab 中添加自动上架任务：

```
# 每分钟执行一次自动上架检查
* * * * * cd /path/to/project && php bin/console product:auto-release-spu
```

命令行工具
-----

[](#命令行工具)

### product:auto-release-spu

[](#productauto-release-spu)

执行自动上架任务，检查并处理所有到期的商品上架配置。

**语法**：

```
php bin/console product:auto-release-spu [options]
```

**选项**：

- `--dry-run`: 仅显示将要执行的操作，不实际执行
- `--verbose`: 显示详细执行信息

**示例**：

```
# 执行自动上架任务
php bin/console product:auto-release-spu

# 预览执行结果（不实际执行）
php bin/console product:auto-release-spu --dry-run

# 显示详细执行过程
php bin/console product:auto-release-spu --verbose
```

**工作原理**：

1. 查找所有到期的自动上架配置
2. 对每个配置执行上架操作
3. 记录执行结果到日志
4. 清理已完成的配置

API 使用
------

[](#api-使用)

### AutoUpService

[](#autoupservice)

主要服务类，提供自动上架的核心功能：

```
use Tourze\ProductAutoUpBundle\Service\AutoUpService;

// 设置商品自动上架时间
$config = $autoUpService->setAutoReleaseTime($spuId, $autoReleaseTime);

// 取消商品自动上架
$result = $autoUpService->cancelAutoRelease($spuId);

// 执行自动上架任务
$executedCount = $autoUpService->executeAutoRelease();

// 获取待执行配置数量
$pendingCount = $autoUpService->countPendingConfigs();
```

### AutoUpLogService

[](#autouplogservice)

日志服务类，用于记录自动上架操作：

```
use Tourze\ProductAutoUpBundle\Service\AutoUpLogService;

// 记录安排日志
$logService->logScheduled($config, '设置自动上架时间');

// 记录执行日志
$logService->logExecuted($config, '成功执行上架');

// 记录取消日志
$logService->logCanceled($config, '取消自动上架');

// 记录错误日志
$logService->logError($config, '执行失败', ['error' => 'details']);
```

数据模型
----

[](#数据模型)

### AutoUpTimeConfig

[](#autouptimeconfig)

自动上架时间配置实体：

- `id`: 主键
- `spu`: 关联的商品（SPU）
- `autoReleaseTime`: 自动上架时间
- `createTime`: 创建时间
- `updateTime`: 更新时间

### AutoUpLog

[](#autouplog)

自动上架操作日志实体：

- `id`: 主键
- `spuId`: 商品ID
- `action`: 操作类型（scheduled/executed/canceled/error）
- `description`: 操作描述
- `context`: 额外上下文信息（JSON格式）
- `createTime`: 创建时间

### AutoUpLogAction

[](#autouplogaction)

操作类型枚举：

- `SCHEDULED`: 已安排
- `EXECUTED`: 已执行
- `CANCELED`: 已取消
- `ERROR`: 执行出错

异常处理
----

[](#异常处理)

### AutoUpException

[](#autoupexception)

自动上架通用异常类，用于处理业务逻辑异常。

### SpuNotFoundException

[](#spunotfoundexception)

商品不存在异常，当指定的SPU不存在时抛出。

管理界面
----

[](#管理界面)

通过EasyAdmin提供的管理界面：

- **自动上架配置管理**：查看和管理商品的自动上架时间设置
- **操作日志查看**：查看所有自动上架操作的历史记录
- **过滤和搜索**：支持按商品ID、操作类型等条件过滤

访问路径：`/admin` -&gt; Auto Up Management

开发指南
----

[](#开发指南)

### 测试

[](#测试)

```
# 运行所有测试
./vendor/bin/phpunit packages/product-auto-up-bundle/tests

# 运行指定测试
./vendor/bin/phpunit packages/product-auto-up-bundle/tests/Service/AutoUpServiceTest.php
```

### 代码质量检查

[](#代码质量检查)

```
# PHPStan 静态分析
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/product-auto-up-bundle

# 代码格式检查
./vendor/bin/php-cs-fixer fix packages/product-auto-up-bundle
```

依赖关系
----

[](#依赖关系)

- PHP 8.1+
- Symfony 6.0+
- Doctrine ORM
- ProductCoreBundle（商品核心模块）

许可证
---

[](#许可证)

MIT License

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance72

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

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

Unknown

Total

1

Last Release

180d 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-product-auto-up-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[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)
