将 000064-000078 合并为 064/065/066,默认规则改为收号 35%、卖出 40%、服务费 25%。 货架调价改为增加分站 1 元兑换哈夫币比例。sql-guard 仅保护 main 已发布迁移。
35 lines
1.1 KiB
Go
35 lines
1.1 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 按分站加价比例重算售价。delta=0 时保持原价,避免四舍五入漂移。
|
|
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 {
|
|
return basePriceCent, baseRatio, baseRatio
|
|
}
|
|
priceCent = yuanToCent(CoinWan(hafCoinAmount) / siteRatio)
|
|
if priceCent < 0 {
|
|
priceCent = 0
|
|
}
|
|
return priceCent, baseRatio, siteRatio
|
|
}
|