feat(listing): 增加赔付方案说明配置

This commit is contained in:
yml2213
2026-11-05 12:14:25 +08:00
parent 16f87d4123
commit 88beae4c96
11 changed files with 53 additions and 2 deletions
@@ -167,6 +167,7 @@ type PublishPriceConfig struct {
DepositPlaceholder string `json:"deposit_placeholder"`
DepositHint string `json:"deposit_hint"`
DepositTooltip string `json:"deposit_tooltip"`
CompensationNote string `json:"compensation_note"`
PricePlaceholder string `json:"price_placeholder"`
RatioDescription string `json:"ratio_description"`
}
@@ -234,6 +234,9 @@ func normalizePublishOptions(options *PublishOptionsDTO) {
if options.PriceConfig.DepositTooltip == "" {
options.PriceConfig.DepositTooltip = defaults.PriceConfig.DepositTooltip
}
if options.PriceConfig.CompensationNote == "" {
options.PriceConfig.CompensationNote = defaults.PriceConfig.CompensationNote
}
if options.PriceConfig.PricePlaceholder == "" {
options.PriceConfig.PricePlaceholder = defaults.PriceConfig.PricePlaceholder
}
@@ -115,6 +115,7 @@ func DefaultPublishOptions() PublishOptionsDTO {
4. 额外保障选项
若您在设置足额押金后仍感不放心,可选择购买平台提供的《全额包赔服务》。一旦发生封号损失,将获得账号市场价值的全额赔付,让您的出租过程后顾无忧。`,
CompensationNote: "普通赔付方案如下:账号在租期内或祖期外出现封禁,追回、洗号等情况,最高可获赔全款相金+押金\n\n无忧保险赔付方案:按账号市场价值进行赔付(可参照螃蟹,盼之等主流交易平台)。注:选择此方案,需额外抽取订单佣金的8.0%作为服务费:押金须达到推荐押金方可购买。",
PricePlaceholder: "填写币数、保险、体力和负重后自动计算;发布总价=纯币基础价+额外消耗品",
RatioDescription: "1:xx 表示 1 元人民币(RMB)等价兑换 xx 万哈夫币",
},
@@ -150,6 +150,20 @@ func TestNormalizePublishOptionsValueDefaultsDepositTooltip(t *testing.T) {
}
}
func TestNormalizePublishOptionsValueDefaultsCompensationNote(t *testing.T) {
normalized, err := normalizePublishOptionsValue(`{"schema_version":2}`)
if err != nil {
t.Fatalf("规范化失败: %v", err)
}
var options PublishOptionsDTO
if err := json.Unmarshal([]byte(normalized), &options); err != nil {
t.Fatalf("解析规范化结果失败: %v", err)
}
if !strings.Contains(options.PriceConfig.CompensationNote, "普通赔付方案如下") {
t.Fatalf("赔付方案说明默认文案缺失: %q", options.PriceConfig.CompensationNote)
}
}
func TestNormalizePublishOptionsValuePreservesExplicitZeroPremiumReviewRatioMarkup(t *testing.T) {
options := DefaultPublishOptions()
options.RatioConfig.PremiumReviewRatioMarkup = 0