重构: 店铺套餐分配系统从加价模式改为返佣模式
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m18s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 5m18s
主要变更: - 重构分配模型:从加价模式(pricing_mode/pricing_value)改为返佣模式(base_commission + tier_commission) - 删除独立的 my_package 接口,统一到 /api/admin/packages(通过数据权限自动过滤) - 新增批量分配和批量调价功能,支持事务和性能优化 - 新增配置版本管理,订单创建时锁定返佣配置 - 新增成本价历史记录,支持审计和纠纷处理 - 新增统计缓存系统(Redis + 异步任务),优化梯度返佣计算性能 - 删除冗余的梯度佣金独立 CRUD 接口(合并到分配配置中) - 归档 3 个已完成的 OpenSpec changes 并同步 8 个新 capabilities 到 main specs 技术细节: - 数据库迁移:000026_refactor_shop_package_allocation - 新增 Store:AllocationConfigStore, PriceHistoryStore, CommissionStatsStore - 新增 Service:BatchAllocationService, BatchPricingService, CommissionStatsService - 新增异步任务:统计更新、定时同步、周期归档 - 测试覆盖:批量操作集成测试、梯度佣金 CRUD 清理验证 影响: - API 变更:删除 4 个梯度 CRUD 接口(POST/GET/PUT/DELETE /:id/tiers) - API 新增:批量分配、批量调价接口 - 数据模型:重构 shop_series_allocation 表结构 - 性能优化:批量操作使用 CreateInBatches,统计使用 Redis 缓存 相关文档: - openspec/changes/archive/2026-01-28-refactor-shop-package-allocation/ - openspec/specs/agent-available-packages/ - openspec/specs/allocation-config-versioning/ - 等 8 个新 capability specs
This commit is contained in:
@@ -82,8 +82,11 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.ShopPackageAllocation != nil {
|
||||
registerShopPackageAllocationRoutes(authGroup, handlers.ShopPackageAllocation, doc, basePath)
|
||||
}
|
||||
if handlers.MyPackage != nil {
|
||||
registerMyPackageRoutes(authGroup, handlers.MyPackage, doc, basePath)
|
||||
if handlers.ShopPackageBatchAllocation != nil {
|
||||
registerShopPackageBatchAllocationRoutes(authGroup, handlers.ShopPackageBatchAllocation, doc, basePath)
|
||||
}
|
||||
if handlers.ShopPackageBatchPricing != nil {
|
||||
registerShopPackageBatchPricingRoutes(authGroup, handlers.ShopPackageBatchPricing, doc, basePath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerMyPackageRoutes(router fiber.Router, handler *admin.MyPackageHandler, doc *openapi.Generator, basePath string) {
|
||||
Register(router, doc, basePath, "GET", "/my-packages", handler.ListMyPackages, RouteSpec{
|
||||
Summary: "我的可售套餐列表",
|
||||
Tags: []string{"代理可售套餐"},
|
||||
Input: new(dto.MyPackageListRequest),
|
||||
Output: new(dto.MyPackagePageResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(router, doc, basePath, "GET", "/my-packages/:id", handler.GetMyPackage, RouteSpec{
|
||||
Summary: "获取可售套餐详情",
|
||||
Tags: []string{"代理可售套餐"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.MyPackageDetailResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(router, doc, basePath, "GET", "/my-series-allocations", handler.ListMySeriesAllocations, RouteSpec{
|
||||
Summary: "我的被分配系列列表",
|
||||
Tags: []string{"代理可售套餐"},
|
||||
Input: new(dto.MySeriesAllocationListRequest),
|
||||
Output: new(dto.MySeriesAllocationPageResult),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
@@ -59,4 +59,12 @@ func registerShopPackageAllocationRoutes(router fiber.Router, handler *admin.Sho
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(allocations, doc, groupPath, "PUT", "/:id/cost-price", handler.UpdateCostPrice, RouteSpec{
|
||||
Summary: "更新单套餐分配成本价",
|
||||
Tags: []string{"单套餐分配"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.ShopPackageAllocationResponse),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
22
internal/routes/shop_package_batch_allocation.go
Normal file
22
internal/routes/shop_package_batch_allocation.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerShopPackageBatchAllocationRoutes(router fiber.Router, handler *admin.ShopPackageBatchAllocationHandler, doc *openapi.Generator, basePath string) {
|
||||
batchAllocations := router.Group("/shop-package-batch-allocations")
|
||||
groupPath := basePath + "/shop-package-batch-allocations"
|
||||
|
||||
Register(batchAllocations, doc, groupPath, "POST", "", handler.BatchAllocate, RouteSpec{
|
||||
Summary: "批量分配套餐",
|
||||
Tags: []string{"批量套餐分配"},
|
||||
Input: new(dto.BatchAllocatePackagesRequest),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
22
internal/routes/shop_package_batch_pricing.go
Normal file
22
internal/routes/shop_package_batch_pricing.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
func registerShopPackageBatchPricingRoutes(router fiber.Router, handler *admin.ShopPackageBatchPricingHandler, doc *openapi.Generator, basePath string) {
|
||||
batchPricing := router.Group("/shop-package-batch-pricing")
|
||||
groupPath := basePath + "/shop-package-batch-pricing"
|
||||
|
||||
Register(batchPricing, doc, groupPath, "POST", "", handler.BatchUpdatePricing, RouteSpec{
|
||||
Summary: "批量调价",
|
||||
Tags: []string{"批量套餐调价"},
|
||||
Input: new(dto.BatchUpdateCostPriceRequest),
|
||||
Output: new(dto.BatchUpdateCostPriceResponse),
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
@@ -60,36 +60,4 @@ func registerShopSeriesAllocationRoutes(router fiber.Router, handler *admin.Shop
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(allocations, doc, groupPath, "GET", "/:id/tiers", handler.ListTiers, RouteSpec{
|
||||
Summary: "获取梯度佣金列表",
|
||||
Tags: []string{"套餐系列分配"},
|
||||
Input: new(dto.IDReq),
|
||||
Output: new(dto.CommissionTierListResult),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(allocations, doc, groupPath, "POST", "/:id/tiers", handler.AddTier, RouteSpec{
|
||||
Summary: "添加梯度佣金配置",
|
||||
Tags: []string{"套餐系列分配"},
|
||||
Input: new(dto.CreateCommissionTierParams),
|
||||
Output: new(dto.CommissionTierResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(allocations, doc, groupPath, "PUT", "/:id/tiers/:tier_id", handler.UpdateTier, RouteSpec{
|
||||
Summary: "更新梯度佣金配置",
|
||||
Tags: []string{"套餐系列分配"},
|
||||
Input: new(dto.UpdateCommissionTierParams),
|
||||
Output: new(dto.CommissionTierResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(allocations, doc, groupPath, "DELETE", "/:id/tiers/:tier_id", handler.DeleteTier, RouteSpec{
|
||||
Summary: "删除梯度佣金配置",
|
||||
Tags: []string{"套餐系列分配"},
|
||||
Input: new(dto.TierIDParams),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user