发布界面优化
This commit is contained in:
@@ -47,6 +47,10 @@ type PublishOptionsDTO struct {
|
||||
SkinGroups []PublishOptionGroup `json:"skin_groups"`
|
||||
QuantityItems []PublishQuantityItem `json:"quantity_items"`
|
||||
ScreenshotSlots []PublishScreenshotSlot `json:"screenshot_slots"`
|
||||
BanRecordOptions []string `json:"ban_record_options"`
|
||||
BanEvidenceOptions []string `json:"ban_evidence_options"`
|
||||
PriceConfig PublishPriceConfig `json:"price_config"`
|
||||
RatioConfig PublishRatioConfig `json:"ratio_config"`
|
||||
}
|
||||
|
||||
type PublishOptionGroup struct {
|
||||
@@ -68,3 +72,39 @@ type PublishScreenshotSlot struct {
|
||||
Required bool `json:"required"`
|
||||
Hint string `json:"hint"`
|
||||
}
|
||||
|
||||
type PublishPriceConfig struct {
|
||||
DepositPlaceholder string `json:"deposit_placeholder"`
|
||||
PricePlaceholder string `json:"price_placeholder"`
|
||||
RatioDescription string `json:"ratio_description"`
|
||||
}
|
||||
|
||||
type PublishRatioConfig struct {
|
||||
InsuranceBaseRatios []PublishInsuranceBaseRatio `json:"insurance_base_ratios"`
|
||||
ConfigItems []PublishRatioConfigItem `json:"config_items"`
|
||||
CoinCorrections []PublishCoinCorrection `json:"coin_corrections"`
|
||||
RentRules []PublishRentRule `json:"rent_rules"`
|
||||
}
|
||||
|
||||
type PublishInsuranceBaseRatio struct {
|
||||
Insurance string `json:"insurance"`
|
||||
Ratio float64 `json:"ratio"`
|
||||
}
|
||||
|
||||
type PublishRatioConfigItem struct {
|
||||
Key string `json:"key"`
|
||||
Label string `json:"label"`
|
||||
Kind string `json:"kind"`
|
||||
GroupKey string `json:"group_key,omitempty"`
|
||||
MissingPenalty float64 `json:"missing_penalty"`
|
||||
}
|
||||
|
||||
type PublishCoinCorrection struct {
|
||||
ThresholdM float64 `json:"threshold_m"`
|
||||
Correction float64 `json:"correction"`
|
||||
}
|
||||
|
||||
type PublishRentRule struct {
|
||||
ThresholdM float64 `json:"threshold_m"`
|
||||
Days int `json:"days"`
|
||||
}
|
||||
|
||||
@@ -76,8 +76,41 @@ func DefaultPublishOptions() PublishOptionsDTO {
|
||||
{Key: "coin", Label: "纯币截图", Required: true, Hint: "请上传纯币截图(必传)"},
|
||||
{Key: "gameId", Label: "游戏ID截图", Required: true, Hint: "请上传游戏ID截图(必传)"},
|
||||
{Key: "totalAsset", Label: "总资产截图", Required: true, Hint: "请上传总资产截图(必传)"},
|
||||
{Key: "tencentSecurity", Label: "腾讯安全中心截图", Required: true, Hint: "请上传腾讯安全中心截图(必传)"},
|
||||
{Key: "tencentSecurity", Label: "腾讯安全中心截图", Required: false, Hint: "有封禁记录时必传"},
|
||||
{Key: "skin", Label: "皮肤截图", Required: false, Hint: "请上传皮肤截图(选传)"},
|
||||
},
|
||||
BanRecordOptions: []string{"无封禁记录", "有封禁记录"},
|
||||
BanEvidenceOptions: []string{"有封禁记录"},
|
||||
PriceConfig: PublishPriceConfig{
|
||||
DepositPlaceholder: "温馨提示:本押金用于保障账号安全。若买家在租用期间,使用非纯币类道具/资源(如消耗品、材料等)或导致账号被封禁,相关损失将直接从押金中扣除进行赔付。押金过高会延长出租等待时间(请自行衡量)感谢理解。",
|
||||
PricePlaceholder: "填写币数、保险、体力和负重后自动计算",
|
||||
RatioDescription: "1:xx 表示 1 元人民币(RMB)等价兑换 xx 万哈夫币",
|
||||
},
|
||||
RatioConfig: PublishRatioConfig{
|
||||
InsuranceBaseRatios: []PublishInsuranceBaseRatio{
|
||||
{Insurance: "3*3", Ratio: 40},
|
||||
{Insurance: "2*3", Ratio: 42},
|
||||
{Insurance: "2*2", Ratio: 47},
|
||||
{Insurance: "2*1", Ratio: 48},
|
||||
},
|
||||
ConfigItems: []PublishRatioConfigItem{
|
||||
{Key: "operatorRed", Label: "干员红皮", Kind: "skin_group", GroupKey: "operatorRed", MissingPenalty: 1},
|
||||
{Key: "melee", Label: "刀皮", Kind: "skin_group", GroupKey: "melee", MissingPenalty: 1},
|
||||
{Key: "staminaMax", Label: "满体力", Kind: "max_stamina", MissingPenalty: 1},
|
||||
{Key: "loadMax", Label: "满负重", Kind: "max_load", MissingPenalty: 1},
|
||||
{Key: "weapon", Label: "砖皮", Kind: "skin_group", GroupKey: "weapon", MissingPenalty: 1},
|
||||
},
|
||||
CoinCorrections: []PublishCoinCorrection{
|
||||
{ThresholdM: 130, Correction: 1},
|
||||
{ThresholdM: 230, Correction: 2.5},
|
||||
{ThresholdM: 380, Correction: 4},
|
||||
{ThresholdM: 530, Correction: 5},
|
||||
},
|
||||
RentRules: []PublishRentRule{
|
||||
{ThresholdM: 300, Days: 7},
|
||||
{ThresholdM: 100, Days: 3},
|
||||
{ThresholdM: 0, Days: 1},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,14 +148,51 @@ func updateLegacyPublishOptions(tx *gorm.DB, item defaultConfig) error {
|
||||
if err := tx.Where("`key` = ?", item.Key).First(&row).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if !isLegacyPublishOptionsValue(row.Value) {
|
||||
if isLegacyPublishOptionsValue(row.Value) {
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
var options PublishOptionsDTO
|
||||
if err := json.Unmarshal([]byte(row.Value), &options); err != nil {
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
before := row.Value
|
||||
isOldPublishOptionsSchema := !strings.Contains(before, `"ban_record_options"`)
|
||||
normalizePublishOptions(&options)
|
||||
if isOldPublishOptionsSchema {
|
||||
applyConditionalBanEvidenceDefault(&options)
|
||||
}
|
||||
raw, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
row.Value = string(raw)
|
||||
row.Description = item.Description
|
||||
if row.Value == before {
|
||||
return nil
|
||||
}
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
|
||||
func applyConditionalBanEvidenceDefault(options *PublishOptionsDTO) {
|
||||
defaults := DefaultPublishOptions()
|
||||
defaultSlots := make(map[string]PublishScreenshotSlot, len(defaults.ScreenshotSlots))
|
||||
for _, item := range defaults.ScreenshotSlots {
|
||||
defaultSlots[item.Key] = item
|
||||
}
|
||||
for index, item := range options.ScreenshotSlots {
|
||||
if item.Key != "tencentSecurity" {
|
||||
continue
|
||||
}
|
||||
if next, ok := defaultSlots[item.Key]; ok {
|
||||
options.ScreenshotSlots[index] = next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isLegacyPublishOptionsValue(value string) bool {
|
||||
legacyMarkers := []string{
|
||||
`"kit5"`,
|
||||
|
||||
@@ -187,4 +187,31 @@ func normalizePublishOptions(options *PublishOptionsDTO) {
|
||||
if len(options.ScreenshotSlots) == 0 {
|
||||
options.ScreenshotSlots = defaults.ScreenshotSlots
|
||||
}
|
||||
if len(options.BanRecordOptions) == 0 {
|
||||
options.BanRecordOptions = defaults.BanRecordOptions
|
||||
}
|
||||
if len(options.BanEvidenceOptions) == 0 {
|
||||
options.BanEvidenceOptions = defaults.BanEvidenceOptions
|
||||
}
|
||||
if options.PriceConfig.DepositPlaceholder == "" {
|
||||
options.PriceConfig.DepositPlaceholder = defaults.PriceConfig.DepositPlaceholder
|
||||
}
|
||||
if options.PriceConfig.PricePlaceholder == "" {
|
||||
options.PriceConfig.PricePlaceholder = defaults.PriceConfig.PricePlaceholder
|
||||
}
|
||||
if options.PriceConfig.RatioDescription == "" {
|
||||
options.PriceConfig.RatioDescription = defaults.PriceConfig.RatioDescription
|
||||
}
|
||||
if len(options.RatioConfig.InsuranceBaseRatios) == 0 {
|
||||
options.RatioConfig.InsuranceBaseRatios = defaults.RatioConfig.InsuranceBaseRatios
|
||||
}
|
||||
if len(options.RatioConfig.ConfigItems) == 0 {
|
||||
options.RatioConfig.ConfigItems = defaults.RatioConfig.ConfigItems
|
||||
}
|
||||
if len(options.RatioConfig.CoinCorrections) == 0 {
|
||||
options.RatioConfig.CoinCorrections = defaults.RatioConfig.CoinCorrections
|
||||
}
|
||||
if len(options.RatioConfig.RentRules) == 0 {
|
||||
options.RatioConfig.RentRules = defaults.RatioConfig.RentRules
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user