feat(publish): 推荐押金支持第二件折扣并放宽押金下限
- 推荐押金皮肤规则新增「第2件起计价」比例,组内首件按原价、后续件按比例计入 - 押金低于推荐押金允许发布,弹窗提示并禁用无忧租号保险 - 用户主动改低押金后不再被推荐值覆盖,点「使用推荐」恢复自动跟随
This commit is contained in:
@@ -271,6 +271,7 @@ func normalizePublishOptions(options *PublishOptionsDTO) {
|
||||
if len(options.DepositRecommend.SkinGroupRules) == 0 {
|
||||
options.DepositRecommend.SkinGroupRules = defaults.DepositRecommend.SkinGroupRules
|
||||
}
|
||||
normalizeDepositSkinGroupRules(options.DepositRecommend.SkinGroupRules)
|
||||
if len(options.RatioConfig.InsuranceBaseRatios) == 0 {
|
||||
options.RatioConfig.InsuranceBaseRatios = defaults.RatioConfig.InsuranceBaseRatios
|
||||
}
|
||||
@@ -375,6 +376,27 @@ func normalizeSignedRatioAdjustment(value float64) float64 {
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
// normalizeDepositSkinGroupRules 收敛押金皮肤规则的折扣比例。
|
||||
// 0 表示不开启折扣(每件按原价计入),上限 100 表示第 2 件起不再加价。
|
||||
func normalizeDepositSkinGroupRules(rules []PublishDepositSkinGroupRule) {
|
||||
for index := range rules {
|
||||
rules[index].DiscountPercent = normalizeDepositDiscountPercent(rules[index].DiscountPercent)
|
||||
}
|
||||
}
|
||||
|
||||
func normalizeDepositDiscountPercent(value float64) float64 {
|
||||
if math.IsNaN(value) || math.IsInf(value, 0) {
|
||||
return 0
|
||||
}
|
||||
if value <= 0 {
|
||||
return 0
|
||||
}
|
||||
if value >= 100 {
|
||||
return 100
|
||||
}
|
||||
return math.Round(value*10) / 10
|
||||
}
|
||||
|
||||
func normalizePremiumReviewRatioMarkup(value float64) float64 {
|
||||
if value < 0 || math.IsNaN(value) || math.IsInf(value, 0) {
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user