feat: 实现门店套餐分配功能并统一测试基础设施
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m30s

新增功能:
- 门店套餐分配管理(shop_package_allocation):支持门店套餐库存管理
- 门店套餐系列分配管理(shop_series_allocation):支持套餐系列分配和佣金层级设置
- 我的套餐查询(my_package):支持门店查询自己的套餐分配情况

测试改进:
- 统一集成测试基础设施,新增 testutils.NewIntegrationTestEnv
- 重构所有集成测试使用新的测试环境设置
- 移除旧的测试辅助函数和冗余测试文件
- 新增 test_helpers_test.go 统一任务测试辅助

技术细节:
- 新增数据库迁移 000025_create_shop_allocation_tables
- 新增 3 个 Handler、Service、Store 和对应的单元测试
- 更新 OpenAPI 文档和文档生成器
- 测试覆盖率:Service 层 > 90%

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-28 10:45:16 +08:00
parent 5fefe9d0cb
commit 23eb0307bb
73 changed files with 8716 additions and 4558 deletions

View File

@@ -36,5 +36,8 @@ func initHandlers(svc *services, deps *Dependencies) *Handlers {
Carrier: admin.NewCarrierHandler(svc.Carrier),
PackageSeries: admin.NewPackageSeriesHandler(svc.PackageSeries),
Package: admin.NewPackageHandler(svc.Package),
ShopSeriesAllocation: admin.NewShopSeriesAllocationHandler(svc.ShopSeriesAllocation),
ShopPackageAllocation: admin.NewShopPackageAllocationHandler(svc.ShopPackageAllocation),
MyPackage: admin.NewMyPackageHandler(svc.MyPackage),
}
}

View File

@@ -15,6 +15,7 @@ import (
iotCardSvc "github.com/break/junhong_cmp_fiber/internal/service/iot_card"
iotCardImportSvc "github.com/break/junhong_cmp_fiber/internal/service/iot_card_import"
myCommissionSvc "github.com/break/junhong_cmp_fiber/internal/service/my_commission"
myPackageSvc "github.com/break/junhong_cmp_fiber/internal/service/my_package"
packageSvc "github.com/break/junhong_cmp_fiber/internal/service/package"
packageSeriesSvc "github.com/break/junhong_cmp_fiber/internal/service/package_series"
permissionSvc "github.com/break/junhong_cmp_fiber/internal/service/permission"
@@ -23,6 +24,8 @@ import (
shopSvc "github.com/break/junhong_cmp_fiber/internal/service/shop"
shopAccountSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_account"
shopCommissionSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_commission"
shopPackageAllocationSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_package_allocation"
shopSeriesAllocationSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_series_allocation"
)
type services struct {
@@ -49,6 +52,9 @@ type services struct {
Carrier *carrierSvc.Service
PackageSeries *packageSeriesSvc.Service
Package *packageSvc.Service
ShopSeriesAllocation *shopSeriesAllocationSvc.Service
ShopPackageAllocation *shopPackageAllocationSvc.Service
MyPackage *myPackageSvc.Service
}
func initServices(s *stores, deps *Dependencies) *services {
@@ -76,5 +82,8 @@ func initServices(s *stores, deps *Dependencies) *services {
Carrier: carrierSvc.New(s.Carrier),
PackageSeries: packageSeriesSvc.New(s.PackageSeries),
Package: packageSvc.New(s.Package, s.PackageSeries),
ShopSeriesAllocation: shopSeriesAllocationSvc.New(s.ShopSeriesAllocation, s.ShopSeriesCommissionTier, s.Shop, s.PackageSeries, s.Package),
ShopPackageAllocation: shopPackageAllocationSvc.New(s.ShopPackageAllocation, s.ShopSeriesAllocation, s.Shop, s.Package),
MyPackage: myPackageSvc.New(s.ShopSeriesAllocation, s.ShopPackageAllocation, s.PackageSeries, s.Package, s.Shop),
}
}

View File

@@ -29,6 +29,9 @@ type stores struct {
Carrier *postgres.CarrierStore
PackageSeries *postgres.PackageSeriesStore
Package *postgres.PackageStore
ShopSeriesAllocation *postgres.ShopSeriesAllocationStore
ShopSeriesCommissionTier *postgres.ShopSeriesCommissionTierStore
ShopPackageAllocation *postgres.ShopPackageAllocationStore
}
func initStores(deps *Dependencies) *stores {
@@ -57,5 +60,8 @@ func initStores(deps *Dependencies) *stores {
Carrier: postgres.NewCarrierStore(deps.DB),
PackageSeries: postgres.NewPackageSeriesStore(deps.DB),
Package: postgres.NewPackageStore(deps.DB),
ShopSeriesAllocation: postgres.NewShopSeriesAllocationStore(deps.DB),
ShopSeriesCommissionTier: postgres.NewShopSeriesCommissionTierStore(deps.DB),
ShopPackageAllocation: postgres.NewShopPackageAllocationStore(deps.DB),
}
}

View File

@@ -34,6 +34,9 @@ type Handlers struct {
Carrier *admin.CarrierHandler
PackageSeries *admin.PackageSeriesHandler
Package *admin.PackageHandler
ShopSeriesAllocation *admin.ShopSeriesAllocationHandler
ShopPackageAllocation *admin.ShopPackageAllocationHandler
MyPackage *admin.MyPackageHandler
}
// Middlewares 封装所有中间件