fix(listing): 外部上传按后台实时配置归类皮肤与折算消耗品,并补齐新增消耗品字段

- 皮肤归类:删除代码内硬编码的 externalSkinCatalog 快照,改为读取 listing.publish_options。
  修复运营在后台新增皮肤后,上传的商品被归入 other 的问题(详情页显示“其他皮肤”、
  按刀皮/金皮/红皮/武器皮分组筛选搜不到)
- 消耗品折算:externalResources 改为按 publish_options.quantity_items 生成条目与单价,
  修复 AWM 子弹按 0.6 元/发旧价折算等价格漂移(线上已调为 0.7 元/发)
- 上传契约:ExternalUploadInventory 新增 level6Ammo/barrettAmmo/gridCard9/redPacket45/
  coffeeBean/bulletPart 六个字段,字段名与消耗品 key 对齐;后续后台再新增消耗品,
  按同样 key 登记即可被上传链路识别
- 数量为 0 的消耗品不再写入资源清单,与网站自身发布流程(filter quantity > 0)保持一致
- 客服调整外部商品同样改用实时单价;Service 增加 externalPublishOptions 统一读配置并带默认值
- 验证:新增回归测试 TestExternalAccountToCreateRequestFollowsPublishOptions;
  并以线上 mobile-home-config 的真实配置 + 上传工具产出的 JSON 做跨仓库联调,
  确认“重塑→近战皮肤、骇爪-骇客少女→干员金皮”,9 项消耗品全部按线上单价生成
This commit is contained in:
yml2213
2026-10-11 17:44:27 +08:00
parent d21ddd9e96
commit 5840b7da40
7 changed files with 192 additions and 46 deletions
@@ -7,6 +7,7 @@ import (
"time"
"hfb_sys/backend/internal/model"
"hfb_sys/backend/internal/modules/systemconfig"
"gorm.io/gorm"
)
@@ -56,7 +57,9 @@ func (s *Service) AdjustExternalListing(
if err != nil {
return nil, err
}
return s.repo.AdjustExternalListing(ctx, adminID, listingID, req, config, meta)
// 消耗品单价同样取自后台实时配置,避免调整后的价格与网站现行单价不一致。
quantityItems := s.externalPublishOptions(ctx).QuantityItems
return s.repo.AdjustExternalListing(ctx, adminID, listingID, req, config, quantityItems, meta)
}
func (r *Repository) AdjustExternalListing(
@@ -65,6 +68,7 @@ func (r *Repository) AdjustExternalListing(
listingID uint64,
req AdminExternalListingAdjustRequest,
config salePriceConfig,
quantityItems []systemconfig.PublishQuantityItem,
meta AuditMeta,
) (*ListingDTO, error) {
if r == nil || r.db == nil {
@@ -105,7 +109,7 @@ func (r *Repository) AdjustExternalListing(
}
before := externalAdjustmentAuditSnapshot(account, listing, summary, breakdown)
adjustment, err := calculateExternalListingAdjustment(req, summary, referenceRatio, config)
adjustment, err := calculateExternalListingAdjustment(req, summary, referenceRatio, config, quantityItems)
if err != nil {
return err
}
@@ -179,6 +183,7 @@ func calculateExternalListingAdjustment(
summary map[string]any,
referenceRatio float64,
config salePriceConfig,
quantityItems []systemconfig.PublishQuantityItem,
) (externalAdjustmentResult, error) {
coinM := float64(req.HafCoinAmount) / 1000000
coinWan := float64(req.HafCoinAmount) / 10000
@@ -207,7 +212,7 @@ func calculateExternalListingAdjustment(
AWMBullets: req.AWMBullets,
Level6Helmets: req.Level6Helmets,
Level6Armor: req.Level6Armor,
})
}, quantityItems)
resources := mergeExternalCoreResources(summary, coreResources)
consumablePrice := consumableValue(map[string]any{"resources": resources})
sellerTotalPrice := roundMoney(sellerCoinPrice + consumablePrice)