- 文档:升级至 v0.7,固化号主保底、主站提价利润分账(35/40/25)与分站加价溢价独享逻辑 - 定价:修正货架兑换比例调价方向为调减比例提价(site_ratio = base_ratio - delta) - 分账:分成基数剔除号主成本与分站加价,提价利润按规则切分,分站自主加价溢价 100% 归卖出方 - 前端:更新分销后台提价说明文案,提示调减比例提高售价且溢价归本站
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package listing
|
|
|
|
// CoinWan 将内部哈夫币数量转为万。
|
|
func CoinWan(hafCoinAmount int64) float64 {
|
|
return float64(hafCoinAmount) / 10000
|
|
}
|
|
|
|
// BaseExchangeRatio 是主站挂牌的「1 元兑换哈夫币」比例。
|
|
func BaseExchangeRatio(hafCoinAmount, priceCent int64) float64 {
|
|
if hafCoinAmount <= 0 || priceCent <= 0 {
|
|
return 0
|
|
}
|
|
return roundRatio(CoinWan(hafCoinAmount) / centToYuan(priceCent))
|
|
}
|
|
|
|
// ApplyShelfRatio 按分站加价比例重算售价。
|
|
// 在「1 元兑换多少万哈夫币」的比例机制下:比例越小,售价越高(提价);比例越大,售价越低(打折)。
|
|
// 分站货架自主提价应调小兑换比例(siteRatio = baseRatio - ratioDelta),使分站售价高于主站基准价。
|
|
func ApplyShelfRatio(hafCoinAmount, basePriceCent int64, ratioDelta float64) (priceCent int64, baseRatio, siteRatio float64) {
|
|
baseRatio = BaseExchangeRatio(hafCoinAmount, basePriceCent)
|
|
if ratioDelta < 0 {
|
|
ratioDelta = 0
|
|
}
|
|
if baseRatio <= 0 || ratioDelta == 0 {
|
|
return basePriceCent, baseRatio, baseRatio
|
|
}
|
|
siteRatio = roundRatio(baseRatio - ratioDelta)
|
|
if siteRatio <= 0.01 {
|
|
siteRatio = 0.01
|
|
}
|
|
priceCent = yuanToCent(CoinWan(hafCoinAmount) / siteRatio)
|
|
if priceCent < basePriceCent {
|
|
priceCent = basePriceCent
|
|
}
|
|
return priceCent, baseRatio, siteRatio
|
|
}
|