fix: 强充预检按平台/代理层级判断,代理自设强充在平台未设时生效
checkForceRechargeRequirement() 新增层级逻辑:平台(PackageSeries)的强充配置具有最高优先级;平台未设强充时,读取 order.SellerShopID 对应的 ShopSeriesAllocation 强充配置;两者均未设时返回 need_force_recharge=false(降级处理)。GetPurchaseCheck 复用同一函数,无需额外修改。 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -2123,20 +2123,27 @@ type ForceRechargeRequirement struct {
|
|||||||
func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *purchase_validation.PurchaseValidationResult) *ForceRechargeRequirement {
|
func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *purchase_validation.PurchaseValidationResult) *ForceRechargeRequirement {
|
||||||
defaultResult := &ForceRechargeRequirement{NeedForceRecharge: false}
|
defaultResult := &ForceRechargeRequirement{NeedForceRecharge: false}
|
||||||
|
|
||||||
// 1. 获取 seriesID
|
// 1. 获取 seriesID 和卖家店铺 ID
|
||||||
var seriesID *uint
|
var seriesID *uint
|
||||||
var firstCommissionPaid bool
|
var firstCommissionPaid bool
|
||||||
|
var sellerShopID uint
|
||||||
|
|
||||||
if result.Card != nil {
|
if result.Card != nil {
|
||||||
seriesID = result.Card.SeriesID
|
seriesID = result.Card.SeriesID
|
||||||
if seriesID != nil {
|
if seriesID != nil {
|
||||||
firstCommissionPaid = result.Card.IsFirstRechargeTriggeredBySeries(*seriesID)
|
firstCommissionPaid = result.Card.IsFirstRechargeTriggeredBySeries(*seriesID)
|
||||||
}
|
}
|
||||||
|
if result.Card.ShopID != nil {
|
||||||
|
sellerShopID = *result.Card.ShopID
|
||||||
|
}
|
||||||
} else if result.Device != nil {
|
} else if result.Device != nil {
|
||||||
seriesID = result.Device.SeriesID
|
seriesID = result.Device.SeriesID
|
||||||
if seriesID != nil {
|
if seriesID != nil {
|
||||||
firstCommissionPaid = result.Device.IsFirstRechargeTriggeredBySeries(*seriesID)
|
firstCommissionPaid = result.Device.IsFirstRechargeTriggeredBySeries(*seriesID)
|
||||||
}
|
}
|
||||||
|
if result.Device.ShopID != nil {
|
||||||
|
sellerShopID = *result.Device.ShopID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if seriesID == nil {
|
if seriesID == nil {
|
||||||
@@ -2169,7 +2176,7 @@ func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *pur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. 累计充值模式,检查是否启用强充
|
// 5. 累计充值模式,检查平台是否启用强充
|
||||||
if config.EnableForceRecharge {
|
if config.EnableForceRecharge {
|
||||||
forceAmount := config.ForceAmount
|
forceAmount := config.ForceAmount
|
||||||
if forceAmount == 0 {
|
if forceAmount == 0 {
|
||||||
@@ -2182,6 +2189,23 @@ func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *pur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 6. 平台未设强充,查询卖家代理的 ShopSeriesAllocation,判断代理是否自设强充
|
||||||
|
// 仅在累计充值模式且平台未启用时,代理强充配置才生效
|
||||||
|
if sellerShopID > 0 {
|
||||||
|
agentAllocation, allocErr := s.shopSeriesAllocationStore.GetByShopAndSeries(ctx, sellerShopID, *seriesID)
|
||||||
|
if allocErr == nil && agentAllocation.EnableForceRecharge {
|
||||||
|
agentForceAmount := agentAllocation.ForceRechargeAmount
|
||||||
|
if agentForceAmount == 0 {
|
||||||
|
agentForceAmount = config.Threshold
|
||||||
|
}
|
||||||
|
return &ForceRechargeRequirement{
|
||||||
|
NeedForceRecharge: true,
|
||||||
|
ForceRechargeAmount: agentForceAmount,
|
||||||
|
TriggerType: model.OneTimeCommissionTriggerAccumulatedRecharge,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return defaultResult
|
return defaultResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user