tourze / product-collect-bundle
商品收藏模块 - 提供用户商品收藏功能
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/product-collect-bundle
Requires
- php: ^8.2
- doctrine/data-fixtures: ^2.0
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^4.1
- easycorp/easyadmin-bundle: ^4
- knplabs/knp-menu: ^3.7
- symfony/config: ^7.3
- symfony/dependency-injection: ^7.3
- symfony/doctrine-bridge: ^7.3
- symfony/form: ^7.3
- symfony/framework-bundle: ^7.3
- symfony/http-foundation: ^7.3
- symfony/http-kernel: ^7.3
- symfony/property-access: ^7.3
- symfony/security-core: ^7.3
- symfony/validator: ^7.3
- symfony/yaml: ^7.3
- tourze/bundle-dependency: 1.*
- tourze/doctrine-indexed-bundle: 1.0.*
- tourze/doctrine-snowflake-bundle: 1.1.*
- tourze/doctrine-timestamp-bundle: 1.1.*
- tourze/easy-admin-menu-bundle: 1.0.*
- tourze/enum-extra: 1.0.*
- tourze/product-core-bundle: 1.0.*
- tourze/symfony-dependency-service-loader: 1.0.*
- tourze/tag-manage-bundle: 1.0.*
Requires (Dev)
- doctrine/doctrine-fixtures-bundle: ^4.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
- symfony/test-pack: ^1.0
- tourze/phpunit-base: 1.*
- tourze/phpunit-doctrine-entity: 1.*
- tourze/phpunit-enum: 1.*
- tourze/phpunit-symfony-kernel-test: 1.0.*
- tourze/phpunit-symfony-unit-test: 1.*
- tourze/phpunit-symfony-web-test: 1.*
This package is auto-updated.
Last update: 2025-11-14 07:28:10 UTC
README
商品收藏模块 - 提供用户商品收藏功能
功能特性
- 🔖 商品收藏管理(添加、取消、恢复)
- 📁 收藏分组功能
- 📌 置顶收藏支持
- 🔢 自定义排序
- 📊 收藏统计分析
- 🚀 批量操作支持
- 💾 软删除机制
安装
composer require tourze/product-collect-bundle
使用示例
基本收藏操作
use Tourze\ProductCollectBundle\Service\ProductCollectService; // 添加收藏 $collect = $collectService->addToCollection($userId, $skuId, '我的收藏', '备注信息'); // 切换收藏状态 $result = $collectService->toggleCollection($userId, $skuId); // 检查是否已收藏 $isCollected = $collectService->isCollected($userId, $skuId); // 获取用户收藏列表 $collections = $collectService->getUserActiveCollections($userId);
分组管理
// 按分组获取收藏 $collections = $collectService->getUserCollectionsByGroup($userId, '我的最爱'); // 获取用户所有分组 $groups = $collectService->getUserCollectionGroups($userId); // 批量移动到分组 $results = $collectService->moveToGroup($userId, [$skuId1, $skuId2], '新分组');
高级功能
// 获取置顶收藏 $topCollections = $collectService->getTopCollections($userId, 10); // 获取最近收藏 $recentCollections = $collectService->getRecentCollections($userId, 20); // 获取热门商品 $popularSkus = $collectService->getPopularSkus(50); // 收藏统计 $stats = $collectService->getCollectionStatistics();
实体结构
ProductCollect
核心收藏实体,包含以下字段:
id: 雪花ID主键userId: 用户ID(字符串类型)sku: 关联的SKU实体status: 收藏状态(活跃/取消/隐藏)collectGroup: 收藏分组note: 收藏备注sortNumber: 排序权重isTop: 是否置顶metadata: 扩展元数据createdAt/updatedAt: 时间戳
CollectStatus 枚举
ACTIVE: 已收藏CANCELLED: 已取消HIDDEN: 已隐藏
数据库索引
系统自动创建以下索引以优化查询性能:
uniq_user_sku: 用户和SKU的唯一约束idx_user_status: 用户ID和状态索引idx_collect_group: 收藏分组索引idx_sort_top: 置顶和排序索引idx_created_at: 创建时间索引
许可证
MIT License