fix: 修复梯度佣金档位字段缺失,补全授权接口响应字段及强充有效状态
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s
- OneTimeCommissionTierDTO 补充 operator 字段映射 - GrantCommissionTierItem 补充 dimension/stat_scope 字段(从全局配置合并) - 系列授权列表/详情补充强充锁定状态和强充金额的有效值计算 - 同步 OpenSpec 主规范并归档变更文档
This commit is contained in:
@@ -4,6 +4,7 @@ package dto
|
||||
type OneTimeCommissionTierDTO struct {
|
||||
Dimension string `json:"dimension" validate:"required,oneof=sales_count sales_amount" required:"true" description:"统计维度 (sales_count:销量, sales_amount:销售额)"`
|
||||
StatScope string `json:"stat_scope" validate:"omitempty,oneof=self self_and_sub" description:"统计范围 (self:仅自己, self_and_sub:自己+下级)"`
|
||||
Operator string `json:"operator,omitempty" validate:"omitempty,oneof=> >= < <=" description:"阈值比较运算符(>、>=、<、<=),空值时计算引擎默认 >="`
|
||||
Threshold int64 `json:"threshold" validate:"required,min=0" required:"true" minimum:"0" description:"达标阈值"`
|
||||
Amount int64 `json:"amount" validate:"required,min=0" required:"true" minimum:"0" description:"佣金金额(分)"`
|
||||
}
|
||||
|
||||
@@ -17,9 +17,11 @@ type ShopSeriesGrantPackageItem struct {
|
||||
Status int `json:"status" description:"分配状态 1-启用 2-禁用"`
|
||||
}
|
||||
|
||||
// GrantCommissionTierItem 梯度佣金档位(operator 仅出现在响应中,来自 PackageSeries 全局配置)
|
||||
// GrantCommissionTierItem 梯度佣金档位(operator/dimension/stat_scope 仅出现在响应中,来自 PackageSeries 全局配置)
|
||||
type GrantCommissionTierItem struct {
|
||||
Operator string `json:"operator,omitempty" description:"比较运算符(>、>=、<、<=),响应中从 PackageSeries 合并,请求中不传"`
|
||||
Dimension string `json:"dimension,omitempty" description:"统计维度(sales_count:销售量, sales_amount:销售额),来自 PackageSeries 全局配置,响应中只读"`
|
||||
StatScope string `json:"stat_scope,omitempty" description:"统计范围(self:仅自己, self_and_sub:自己+下级),来自 PackageSeries 全局配置,响应中只读"`
|
||||
Threshold int64 `json:"threshold" description:"阈值(与 PackageSeries 全局配置对应)"`
|
||||
Amount int64 `json:"amount" description:"该代理在此档位的佣金金额(分)"`
|
||||
}
|
||||
@@ -90,6 +92,8 @@ type ShopSeriesGrantListItem struct {
|
||||
CommissionType string `json:"commission_type" description:"佣金类型"`
|
||||
OneTimeCommissionAmount int64 `json:"one_time_commission_amount" description:"固定模式佣金金额(分)"`
|
||||
ForceRechargeEnabled bool `json:"force_recharge_enabled" description:"是否启用强充"`
|
||||
ForceRechargeLocked bool `json:"force_recharge_locked" description:"强充是否被套餐系列锁定(true 时代理不可修改)"`
|
||||
ForceRechargeAmount int64 `json:"force_recharge_amount" description:"强充金额(分)"`
|
||||
AllocatorShopID uint `json:"allocator_shop_id" description:"分配者店铺ID"`
|
||||
AllocatorShopName string `json:"allocator_shop_name" description:"分配者店铺名称"`
|
||||
PackageCount int `json:"package_count" description:"已授权套餐数量"`
|
||||
|
||||
@@ -263,6 +263,7 @@ func (s *Service) dtoToModelConfig(dtoConfig *dto.SeriesOneTimeCommissionConfigD
|
||||
tiers = make([]model.OneTimeCommissionTier, len(dtoConfig.Tiers))
|
||||
for i, tier := range dtoConfig.Tiers {
|
||||
tiers[i] = model.OneTimeCommissionTier{
|
||||
Operator: tier.Operator,
|
||||
Dimension: tier.Dimension,
|
||||
StatScope: tier.StatScope,
|
||||
Threshold: tier.Threshold,
|
||||
@@ -296,6 +297,7 @@ func (s *Service) modelToDTO(config *model.OneTimeCommissionConfig) *dto.SeriesO
|
||||
tiers = make([]dto.OneTimeCommissionTierDTO, len(config.Tiers))
|
||||
for i, tier := range config.Tiers {
|
||||
tiers[i] = dto.OneTimeCommissionTierDTO{
|
||||
Operator: tier.Operator,
|
||||
Dimension: tier.Dimension,
|
||||
StatScope: tier.StatScope,
|
||||
Threshold: tier.Threshold,
|
||||
|
||||
@@ -128,11 +128,17 @@ func (s *Service) buildGrantResponse(ctx context.Context, allocation *model.Shop
|
||||
resp.AllocatorShopName = "平台"
|
||||
}
|
||||
|
||||
// 强充状态:first_recharge 或平台已启用 accumulated_recharge 强充时,锁定不可改
|
||||
// 强充有效状态:first_recharge 或平台已启用 accumulated_recharge 强充时,锁定不可改
|
||||
forceRechargeLocked := config.TriggerType == model.OneTimeCommissionTriggerFirstRecharge || config.EnableForceRecharge
|
||||
resp.ForceRechargeLocked = forceRechargeLocked
|
||||
resp.ForceRechargeEnabled = allocation.EnableForceRecharge
|
||||
resp.ForceRechargeAmount = allocation.ForceRechargeAmount
|
||||
if forceRechargeLocked {
|
||||
// 锁定时强充实际生效,金额取套餐系列配置值(allocation 字段为 0 不能使用)
|
||||
resp.ForceRechargeEnabled = true
|
||||
resp.ForceRechargeAmount = config.ForceAmount
|
||||
} else {
|
||||
resp.ForceRechargeEnabled = allocation.EnableForceRecharge
|
||||
resp.ForceRechargeAmount = allocation.ForceRechargeAmount
|
||||
}
|
||||
|
||||
// 固定模式
|
||||
if config.CommissionType == "fixed" {
|
||||
@@ -153,11 +159,13 @@ func (s *Service) buildGrantResponse(ctx context.Context, allocation *model.Shop
|
||||
// 合并全局 operator 和代理 amount
|
||||
tiers := make([]dto.GrantCommissionTierItem, 0, len(config.Tiers))
|
||||
for _, globalTier := range config.Tiers {
|
||||
tiers = append(tiers, dto.GrantCommissionTierItem{
|
||||
Operator: globalTier.Operator,
|
||||
Threshold: globalTier.Threshold,
|
||||
Amount: agentAmountMap[globalTier.Threshold],
|
||||
})
|
||||
tiers = append(tiers, dto.GrantCommissionTierItem{
|
||||
Operator: globalTier.Operator,
|
||||
Dimension: globalTier.Dimension,
|
||||
StatScope: globalTier.StatScope,
|
||||
Threshold: globalTier.Threshold,
|
||||
Amount: agentAmountMap[globalTier.Threshold],
|
||||
})
|
||||
}
|
||||
resp.CommissionTiers = tiers
|
||||
}
|
||||
@@ -452,9 +460,11 @@ func (s *Service) List(ctx context.Context, req *dto.ShopSeriesGrantListRequest)
|
||||
SeriesID: a.SeriesID,
|
||||
AllocatorShopID: a.AllocatorShopID,
|
||||
OneTimeCommissionAmount: a.OneTimeCommissionAmount,
|
||||
ForceRechargeEnabled: a.EnableForceRecharge,
|
||||
Status: a.Status,
|
||||
CreatedAt: a.CreatedAt.Format(time.DateTime),
|
||||
// 强充有效状态在 seriesMap 分支中计算,此处先设默认值
|
||||
ForceRechargeEnabled: a.EnableForceRecharge,
|
||||
ForceRechargeAmount: a.ForceRechargeAmount,
|
||||
Status: a.Status,
|
||||
CreatedAt: a.CreatedAt.Format(time.DateTime),
|
||||
}
|
||||
if a.AllocatorShopID > 0 {
|
||||
item.AllocatorShopName = shopMap[a.AllocatorShopID]
|
||||
@@ -466,6 +476,16 @@ func (s *Service) List(ctx context.Context, req *dto.ShopSeriesGrantListRequest)
|
||||
config, _ := sr.GetOneTimeCommissionConfig()
|
||||
if config != nil {
|
||||
item.CommissionType = config.CommissionType
|
||||
// 计算强充有效状态:first_recharge 或平台已启用 accumulated_recharge 强充时锁定
|
||||
forceRechargeLocked := config.TriggerType == model.OneTimeCommissionTriggerFirstRecharge || config.EnableForceRecharge
|
||||
item.ForceRechargeLocked = forceRechargeLocked
|
||||
if forceRechargeLocked {
|
||||
item.ForceRechargeEnabled = true
|
||||
item.ForceRechargeAmount = config.ForceAmount
|
||||
} else {
|
||||
item.ForceRechargeEnabled = a.EnableForceRecharge
|
||||
item.ForceRechargeAmount = a.ForceRechargeAmount
|
||||
}
|
||||
}
|
||||
}
|
||||
// 统计套餐数量
|
||||
|
||||
Reference in New Issue
Block a user