From 2ca33b7172e8e0e164038fa6cfa6ab9c5f5aeb7e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 4 Mar 2026 11:36:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=BA=E5=85=85=E9=A2=84=E6=A3=80?= =?UTF-8?q?=E6=8C=89=E5=B9=B3=E5=8F=B0/=E4=BB=A3=E7=90=86=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E5=88=A4=E6=96=AD=EF=BC=8C=E4=BB=A3=E7=90=86=E8=87=AA?= =?UTF-8?q?=E8=AE=BE=E5=BC=BA=E5=85=85=E5=9C=A8=E5=B9=B3=E5=8F=B0=E6=9C=AA?= =?UTF-8?q?=E8=AE=BE=E6=97=B6=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- internal/service/order/service.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/internal/service/order/service.go b/internal/service/order/service.go index 28ff23e..1d45fd6 100644 --- a/internal/service/order/service.go +++ b/internal/service/order/service.go @@ -2123,20 +2123,27 @@ type ForceRechargeRequirement struct { func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *purchase_validation.PurchaseValidationResult) *ForceRechargeRequirement { defaultResult := &ForceRechargeRequirement{NeedForceRecharge: false} - // 1. 获取 seriesID + // 1. 获取 seriesID 和卖家店铺 ID var seriesID *uint var firstCommissionPaid bool + var sellerShopID uint if result.Card != nil { seriesID = result.Card.SeriesID if seriesID != nil { firstCommissionPaid = result.Card.IsFirstRechargeTriggeredBySeries(*seriesID) } + if result.Card.ShopID != nil { + sellerShopID = *result.Card.ShopID + } } else if result.Device != nil { seriesID = result.Device.SeriesID if seriesID != nil { firstCommissionPaid = result.Device.IsFirstRechargeTriggeredBySeries(*seriesID) } + if result.Device.ShopID != nil { + sellerShopID = *result.Device.ShopID + } } if seriesID == nil { @@ -2169,7 +2176,7 @@ func (s *Service) checkForceRechargeRequirement(ctx context.Context, result *pur } } - // 5. 累计充值模式,检查是否启用强充 + // 5. 累计充值模式,检查平台是否启用强充 if config.EnableForceRecharge { forceAmount := config.ForceAmount 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 }