feat(listing): 极品专区发布时增加比例加价

This commit is contained in:
yml2213
2026-11-04 20:54:11 +08:00
parent aeda6f4cd3
commit 5ac1afd573
11 changed files with 149 additions and 0 deletions
@@ -98,6 +98,28 @@ func applyMainSiteReceivePricing(req *CreateRequest, options systemconfig.Publis
buyerAnchorCoinBase = referenceSellerCoinBasePrice(coinWan, referenceRatio)
}
pricing := calculateExternalPlatformPricing(coinM, buyerAnchorRatio, buyerAnchorCoinBase, consumablePrice, config)
premiumRatioMarkup := 0.0
if req.IsPremium {
premiumRatioMarkup = NormalizePremiumReviewRatioMarkup(
options.RatioConfig.PremiumReviewRatioMarkup,
)
}
if premiumRatioMarkup > 0 && pricing.BuyerRatio > premiumRatioMarkup {
beforeRatio := pricing.BuyerRatio
afterRatio := roundRatio(beforeRatio - premiumRatioMarkup)
buyerCoinBasePrice := roundMoney(coinWan / afterRatio)
pricing = buildExternalPlatformPricing(
coinWan,
sellerTotalPrice,
consumablePrice,
buyerCoinBasePrice,
pricing.RuleType,
)
breakdown["premium_review_ratio_markup"] = premiumRatioMarkup
breakdown["premium_review_ratio_before"] = beforeRatio
breakdown["premium_review_ratio_after"] = pricing.BuyerRatio
breakdown["premium_review_ratio_markup_applied"] = true
}
breakdown["seller_reference_ratio"] = referenceRatio
breakdown["seller_ratio"] = sellerRatio
breakdown["seller_coin_base_price"] = sellerCoinBasePrice
@@ -170,6 +192,17 @@ func NormalizeQualityOwnerRatioDiscount(value float64) float64 {
return roundRatio(value)
}
// NormalizePremiumReviewRatioMarkup 限制极品专区发布时额外增加的比例加价点数,最大 10。
func NormalizePremiumReviewRatioMarkup(value float64) float64 {
if value < 0 || math.IsNaN(value) || math.IsInf(value, 0) {
return 0
}
if value > maxAcceleratedSaleRatioIncrement {
return maxAcceleratedSaleRatioIncrement
}
return roundRatio(value)
}
// referenceSellerCoinBasePrice 计算主站参考比例下的号主基础价,用作买家定价锚点。
func referenceSellerCoinBasePrice(coinWan, referenceRatio float64) float64 {
if referenceRatio <= 0 {