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
96 lines
7.2 KiB
Go
96 lines
7.2 KiB
Go
package bootstrap
|
|
|
|
import (
|
|
accountSvc "github.com/break/junhong_cmp_fiber/internal/service/account"
|
|
assetAllocationRecordSvc "github.com/break/junhong_cmp_fiber/internal/service/asset_allocation_record"
|
|
authSvc "github.com/break/junhong_cmp_fiber/internal/service/auth"
|
|
carrierSvc "github.com/break/junhong_cmp_fiber/internal/service/carrier"
|
|
commissionStatsSvc "github.com/break/junhong_cmp_fiber/internal/service/commission_stats"
|
|
commissionWithdrawalSvc "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal"
|
|
commissionWithdrawalSettingSvc "github.com/break/junhong_cmp_fiber/internal/service/commission_withdrawal_setting"
|
|
customerAccountSvc "github.com/break/junhong_cmp_fiber/internal/service/customer_account"
|
|
deviceSvc "github.com/break/junhong_cmp_fiber/internal/service/device"
|
|
deviceImportSvc "github.com/break/junhong_cmp_fiber/internal/service/device_import"
|
|
enterpriseSvc "github.com/break/junhong_cmp_fiber/internal/service/enterprise"
|
|
enterpriseCardSvc "github.com/break/junhong_cmp_fiber/internal/service/enterprise_card"
|
|
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"
|
|
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"
|
|
personalCustomerSvc "github.com/break/junhong_cmp_fiber/internal/service/personal_customer"
|
|
roleSvc "github.com/break/junhong_cmp_fiber/internal/service/role"
|
|
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"
|
|
shopPackageBatchAllocationSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_package_batch_allocation"
|
|
shopPackageBatchPricingSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_package_batch_pricing"
|
|
shopSeriesAllocationSvc "github.com/break/junhong_cmp_fiber/internal/service/shop_series_allocation"
|
|
)
|
|
|
|
type services struct {
|
|
Account *accountSvc.Service
|
|
Role *roleSvc.Service
|
|
Permission *permissionSvc.Service
|
|
PersonalCustomer *personalCustomerSvc.Service
|
|
Shop *shopSvc.Service
|
|
ShopAccount *shopAccountSvc.Service
|
|
Auth *authSvc.Service
|
|
ShopCommission *shopCommissionSvc.Service
|
|
CommissionWithdrawal *commissionWithdrawalSvc.Service
|
|
CommissionWithdrawalSetting *commissionWithdrawalSettingSvc.Service
|
|
Enterprise *enterpriseSvc.Service
|
|
EnterpriseCard *enterpriseCardSvc.Service
|
|
Authorization *enterpriseCardSvc.AuthorizationService
|
|
CustomerAccount *customerAccountSvc.Service
|
|
MyCommission *myCommissionSvc.Service
|
|
IotCard *iotCardSvc.Service
|
|
IotCardImport *iotCardImportSvc.Service
|
|
Device *deviceSvc.Service
|
|
DeviceImport *deviceImportSvc.Service
|
|
AssetAllocationRecord *assetAllocationRecordSvc.Service
|
|
Carrier *carrierSvc.Service
|
|
PackageSeries *packageSeriesSvc.Service
|
|
Package *packageSvc.Service
|
|
ShopSeriesAllocation *shopSeriesAllocationSvc.Service
|
|
ShopPackageAllocation *shopPackageAllocationSvc.Service
|
|
ShopPackageBatchAllocation *shopPackageBatchAllocationSvc.Service
|
|
ShopPackageBatchPricing *shopPackageBatchPricingSvc.Service
|
|
CommissionStats *commissionStatsSvc.Service
|
|
}
|
|
|
|
func initServices(s *stores, deps *Dependencies) *services {
|
|
return &services{
|
|
Account: accountSvc.New(s.Account, s.Role, s.AccountRole),
|
|
Role: roleSvc.New(s.Role, s.Permission, s.RolePermission),
|
|
Permission: permissionSvc.New(s.Permission, s.AccountRole, s.RolePermission, deps.Redis),
|
|
PersonalCustomer: personalCustomerSvc.NewService(s.PersonalCustomer, s.PersonalCustomerPhone, deps.VerificationService, deps.JWTManager, deps.Logger),
|
|
Shop: shopSvc.New(s.Shop, s.Account),
|
|
ShopAccount: shopAccountSvc.New(s.Account, s.Shop),
|
|
Auth: authSvc.New(s.Account, s.AccountRole, s.RolePermission, s.Permission, deps.TokenManager, deps.Logger),
|
|
ShopCommission: shopCommissionSvc.New(s.Shop, s.Account, s.Wallet, s.CommissionWithdrawalRequest, s.CommissionRecord),
|
|
CommissionWithdrawal: commissionWithdrawalSvc.New(deps.DB, s.Shop, s.Account, s.Wallet, s.WalletTransaction, s.CommissionWithdrawalRequest),
|
|
CommissionWithdrawalSetting: commissionWithdrawalSettingSvc.New(deps.DB, s.Account, s.CommissionWithdrawalSetting),
|
|
Enterprise: enterpriseSvc.New(deps.DB, s.Enterprise, s.Shop, s.Account),
|
|
EnterpriseCard: enterpriseCardSvc.New(deps.DB, s.Enterprise, s.EnterpriseCardAuthorization),
|
|
Authorization: enterpriseCardSvc.NewAuthorizationService(s.Enterprise, s.IotCard, s.EnterpriseCardAuthorization, deps.Logger),
|
|
CustomerAccount: customerAccountSvc.New(deps.DB, s.Account, s.Shop, s.Enterprise),
|
|
MyCommission: myCommissionSvc.New(deps.DB, s.Shop, s.Wallet, s.CommissionWithdrawalRequest, s.CommissionWithdrawalSetting, s.CommissionRecord, s.WalletTransaction),
|
|
IotCard: iotCardSvc.New(deps.DB, s.IotCard, s.Shop, s.AssetAllocationRecord),
|
|
IotCardImport: iotCardImportSvc.New(deps.DB, s.IotCardImportTask, deps.QueueClient),
|
|
Device: deviceSvc.New(deps.DB, s.Device, s.DeviceSimBinding, s.IotCard, s.Shop, s.AssetAllocationRecord),
|
|
DeviceImport: deviceImportSvc.New(deps.DB, s.DeviceImportTask, deps.QueueClient),
|
|
AssetAllocationRecord: assetAllocationRecordSvc.New(deps.DB, s.AssetAllocationRecord, s.Shop, s.Account),
|
|
Carrier: carrierSvc.New(s.Carrier),
|
|
PackageSeries: packageSeriesSvc.New(s.PackageSeries),
|
|
Package: packageSvc.New(s.Package, s.PackageSeries, s.ShopPackageAllocation, s.ShopSeriesAllocation, s.ShopSeriesCommissionTier),
|
|
ShopSeriesAllocation: shopSeriesAllocationSvc.New(s.ShopSeriesAllocation, s.ShopSeriesCommissionTier, s.ShopSeriesAllocationConfig, s.Shop, s.PackageSeries, s.Package),
|
|
ShopPackageAllocation: shopPackageAllocationSvc.New(s.ShopPackageAllocation, s.ShopSeriesAllocation, s.ShopPackageAllocationPriceHistory, s.Shop, s.Package),
|
|
ShopPackageBatchAllocation: shopPackageBatchAllocationSvc.New(deps.DB, s.Package, s.ShopSeriesAllocation, s.ShopPackageAllocation, s.ShopSeriesAllocationConfig, s.ShopSeriesCommissionTier, s.ShopSeriesCommissionStats, s.Shop),
|
|
ShopPackageBatchPricing: shopPackageBatchPricingSvc.New(deps.DB, s.ShopPackageAllocation, s.ShopPackageAllocationPriceHistory, s.Shop),
|
|
CommissionStats: commissionStatsSvc.New(s.ShopSeriesCommissionStats),
|
|
}
|
|
}
|