feat(publish): 推荐押金支持第二件折扣并放宽押金下限
- 推荐押金皮肤规则新增「第2件起计价」比例,组内首件按原价、后续件按比例计入 - 押金低于推荐押金允许发布,弹窗提示并禁用无忧租号保险 - 用户主动改低押金后不再被推荐值覆盖,点「使用推荐」恢复自动跟随
This commit is contained in:
@@ -309,6 +309,54 @@ func TestNormalizePublishOptionsValueDefaultsQualityOwnerRatioDiscount(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePublishOptionsValueKeepsDepositSkinGroupDiscount(t *testing.T) {
|
||||
raw := `{
|
||||
"schema_version": 3,
|
||||
"deposit_recommend_config": {
|
||||
"base_amount": 200,
|
||||
"skin_group_rules": [
|
||||
{"group_key": "melee", "label": "刀皮", "amount_per_item": 100, "discount_percent": 50},
|
||||
{"group_key": "weapon", "label": "武器皮肤", "amount_per_item": 200, "discount_percent": 120},
|
||||
{"group_key": "operatorRed", "label": "干员红皮", "amount_per_item": 150, "discount_percent": -10}
|
||||
]
|
||||
}
|
||||
}`
|
||||
|
||||
normalized, err := normalizePublishOptionsValue(raw)
|
||||
if err != nil {
|
||||
t.Fatalf("规范化失败: %v", err)
|
||||
}
|
||||
var got PublishOptionsDTO
|
||||
if err := json.Unmarshal([]byte(normalized), &got); err != nil {
|
||||
t.Fatalf("解析规范化结果失败: %v", err)
|
||||
}
|
||||
rules := got.DepositRecommend.SkinGroupRules
|
||||
if len(rules) != 3 {
|
||||
t.Fatalf("skin_group_rules = %#v, want 3 rules", rules)
|
||||
}
|
||||
if rules[0].DiscountPercent != 50 {
|
||||
t.Fatalf("折扣比例被覆盖: %#v", rules[0])
|
||||
}
|
||||
if rules[1].DiscountPercent != 100 {
|
||||
t.Fatalf("超范围折扣比例未收敛: %#v", rules[1])
|
||||
}
|
||||
if rules[2].DiscountPercent != 0 {
|
||||
t.Fatalf("负数折扣比例未收敛: %#v", rules[2])
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultPublishOptionsKeepsDepositSkinGroupDiscountDisabled(t *testing.T) {
|
||||
options := DefaultPublishOptions()
|
||||
if len(options.DepositRecommend.SkinGroupRules) != 4 {
|
||||
t.Fatalf("skin_group_rules = %#v, want 4 rules", options.DepositRecommend.SkinGroupRules)
|
||||
}
|
||||
for _, rule := range options.DepositRecommend.SkinGroupRules {
|
||||
if rule.DiscountPercent != 0 {
|
||||
t.Fatalf("默认不应开启第二件折扣: %#v", rule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizePublishOptionsValueDefaultsDepositTooltip(t *testing.T) {
|
||||
normalized, err := normalizePublishOptionsValue(`{"schema_version":2}`)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user