feat(publish): 增加等级与特殊皮肤价格修正
This commit is contained in:
@@ -37,8 +37,8 @@ func TestCalculateExternalListingAdjustmentByDiscountAmount(t *testing.T) {
|
||||
assertExternalAdjustmentNumber(t, "发布比例", result.SaleRatio, 44.4)
|
||||
assertExternalAdjustmentNumber(t, "号主纯币价", result.SellerCoinPrice, 225.2)
|
||||
assertExternalAdjustmentNumber(t, "实际让利", result.ActualDiscountAmount, 24.8)
|
||||
assertExternalAdjustmentNumber(t, "额外物品", result.ConsumablePrice, 11.5)
|
||||
assertExternalAdjustmentNumber(t, "号主合计", result.SellerTotalPrice, 236.7)
|
||||
assertExternalAdjustmentNumber(t, "额外物品", result.ConsumablePrice, 12.5)
|
||||
assertExternalAdjustmentNumber(t, "号主合计", result.SellerTotalPrice, 237.7)
|
||||
if result.SaleRatio <= result.ReferenceRatio {
|
||||
t.Fatalf("降价后应进入特惠状态,参考比例 %.1f,调整比例 %.1f", result.ReferenceRatio, result.SaleRatio)
|
||||
}
|
||||
@@ -91,8 +91,8 @@ func TestAdjustExternalListingSynchronizesAssetsPricesAndAudit(t *testing.T) {
|
||||
if updated.SourceChannel != "淘宝" {
|
||||
t.Fatalf("来源渠道 = %q,期望 淘宝", updated.SourceChannel)
|
||||
}
|
||||
if updated.PriceCent != 33310 || updated.DepositAmountCent != 50000 {
|
||||
t.Fatalf("商品价格/押金 = %d/%d,期望 33310/50000", updated.PriceCent, updated.DepositAmountCent)
|
||||
if updated.PriceCent != 33410 || updated.DepositAmountCent != 50000 {
|
||||
t.Fatalf("商品价格/押金 = %d/%d,期望 33410/50000", updated.PriceCent, updated.DepositAmountCent)
|
||||
}
|
||||
|
||||
var storedAccount model.GameAccount
|
||||
@@ -117,10 +117,10 @@ func TestAdjustExternalListingSynchronizesAssetsPricesAndAudit(t *testing.T) {
|
||||
breakdown := ensurePriceBreakdown(summary)
|
||||
assertExternalAdjustmentNumber(t, "账号发布比例", readSummaryNumber(breakdown["seller_ratio"]), 42.9)
|
||||
assertExternalAdjustmentNumber(t, "号主纯币价", readSummaryNumber(breakdown["seller_coin_base_price"]), 279.7)
|
||||
assertExternalAdjustmentNumber(t, "额外物品价格", readSummaryNumber(breakdown["consumable_price"]), 16.5)
|
||||
assertExternalAdjustmentNumber(t, "号主合计", readSummaryNumber(breakdown["seller_total_price"]), 296.2)
|
||||
assertExternalAdjustmentNumber(t, "额外物品价格", readSummaryNumber(breakdown["consumable_price"]), 17.5)
|
||||
assertExternalAdjustmentNumber(t, "号主合计", readSummaryNumber(breakdown["seller_total_price"]), 297.2)
|
||||
assertExternalAdjustmentNumber(t, "租客比例", readSummaryNumber(breakdown["buyer_ratio"]), 37.9)
|
||||
assertExternalAdjustmentNumber(t, "租客售价", readSummaryNumber(breakdown["buyer_total_price"]), 333.1)
|
||||
assertExternalAdjustmentNumber(t, "租客售价", readSummaryNumber(breakdown["buyer_total_price"]), 334.1)
|
||||
if breakdown["external_admin_adjust_reason"] != "用户申请加入特惠" {
|
||||
t.Fatalf("调整原因未写入价格快照: %#v", breakdown["external_admin_adjust_reason"])
|
||||
}
|
||||
@@ -141,7 +141,7 @@ func TestAdjustExternalListingSynchronizesAssetsPricesAndAudit(t *testing.T) {
|
||||
assertExternalAdjustmentNumber(t, "审计调整前纯币", readSummaryNumber(before["haf_coin_amount"]), 100000000)
|
||||
assertExternalAdjustmentNumber(t, "审计调整后纯币", readSummaryNumber(after["haf_coin_amount"]), 120000000)
|
||||
assertExternalAdjustmentNumber(t, "审计调整后比例", readSummaryNumber(after["sale_ratio"]), 42.9)
|
||||
assertExternalAdjustmentNumber(t, "审计调整后售价", readSummaryNumber(after["listing_price_cent"]), 33310)
|
||||
assertExternalAdjustmentNumber(t, "审计调整后售价", readSummaryNumber(after["listing_price_cent"]), 33410)
|
||||
if detail["request_id"] != "request-1" {
|
||||
t.Fatalf("审计 request_id = %#v,期望 request-1", detail["request_id"])
|
||||
}
|
||||
|
||||
@@ -268,6 +268,7 @@ func (s *Service) publishRatioOptions(ctx context.Context) (systemconfig.Publish
|
||||
if len(parsed.SkinGroups) == 0 {
|
||||
parsed.SkinGroups = options.SkinGroups
|
||||
}
|
||||
systemconfig.NormalizePublishOptions(&parsed)
|
||||
return parsed, nil
|
||||
}
|
||||
|
||||
@@ -286,10 +287,14 @@ func calculateSellerReferenceRatio(coinM float64, summary map[string]any, option
|
||||
return 0
|
||||
}
|
||||
dailyLoss := readSummaryNumber(summary["daily_loss_m"])
|
||||
return baseRatio +
|
||||
ratio := baseRatio +
|
||||
calculateRatioConfigPenalty(options, summary, stamina, load) +
|
||||
coinCorrection(options.RatioConfig.CoinCorrections, coinM) +
|
||||
calculateDailyLossRatioAdjustment(dailyLoss)
|
||||
if ratio <= 0 {
|
||||
return 0
|
||||
}
|
||||
return roundRatio(ratio)
|
||||
}
|
||||
|
||||
func clampSaleRatio(referenceRatio, requestedRatio, minRatio float64) float64 {
|
||||
@@ -322,9 +327,82 @@ func calculateRatioConfigPenalty(options systemconfig.PublishOptionsDTO, summary
|
||||
if ratioConfigItemMatched(item, options, selectedSkins, stamina, load) {
|
||||
continue
|
||||
}
|
||||
if item.Kind == "max_stamina" &&
|
||||
hasMatchingLevelRatioRule(options.RatioConfig.LevelRatioRules, "stamina", stamina) {
|
||||
continue
|
||||
}
|
||||
if item.Kind == "max_load" &&
|
||||
hasMatchingLevelRatioRule(options.RatioConfig.LevelRatioRules, "load", load) {
|
||||
continue
|
||||
}
|
||||
penalty += item.MissingPenalty
|
||||
}
|
||||
return penalty
|
||||
penalty += calculateLevelRatioAdjustment(options.RatioConfig.LevelRatioRules, stamina, load)
|
||||
penalty += calculateSpecialSkinRatioAdjustment(options.SkinGroups, selectedSkins)
|
||||
return math.Round(penalty*10) / 10
|
||||
}
|
||||
|
||||
func hasMatchingLevelRatioRule(
|
||||
rules []systemconfig.PublishLevelRatioRule,
|
||||
field string,
|
||||
level string,
|
||||
) bool {
|
||||
for _, rule := range rules {
|
||||
if strings.TrimSpace(rule.Field) == field && strings.TrimSpace(rule.Level) == level {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func calculateLevelRatioAdjustment(
|
||||
rules []systemconfig.PublishLevelRatioRule,
|
||||
stamina string,
|
||||
load string,
|
||||
) float64 {
|
||||
adjustment := 0.0
|
||||
for _, rule := range rules {
|
||||
switch strings.TrimSpace(rule.Field) {
|
||||
case "stamina":
|
||||
if strings.TrimSpace(rule.Level) == stamina {
|
||||
adjustment += rule.RatioAdjustment
|
||||
}
|
||||
case "load":
|
||||
if strings.TrimSpace(rule.Level) == load {
|
||||
adjustment += rule.RatioAdjustment
|
||||
}
|
||||
}
|
||||
}
|
||||
return adjustment
|
||||
}
|
||||
|
||||
func calculateSpecialSkinRatioAdjustment(
|
||||
groups []systemconfig.PublishOptionGroup,
|
||||
selectedSkins []string,
|
||||
) float64 {
|
||||
if len(selectedSkins) == 0 {
|
||||
return 0
|
||||
}
|
||||
selected := make(map[string]struct{}, len(selectedSkins))
|
||||
for _, skin := range selectedSkins {
|
||||
skin = strings.TrimSpace(skin)
|
||||
if skin != "" {
|
||||
selected[skin] = struct{}{}
|
||||
}
|
||||
}
|
||||
adjustment := 0.0
|
||||
for _, group := range groups {
|
||||
if group.SpecialRatioAdjustment == 0 || len(group.SpecialPriceOptions) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, skin := range group.SpecialPriceOptions {
|
||||
if _, ok := selected[strings.TrimSpace(skin)]; ok {
|
||||
adjustment += group.SpecialRatioAdjustment
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return adjustment
|
||||
}
|
||||
|
||||
func ratioConfigItemMatched(
|
||||
|
||||
@@ -34,8 +34,40 @@ func TestCalculateSellerReferenceRatioUsesMainSiteConfig(t *testing.T) {
|
||||
"daily_loss_m": 10,
|
||||
}
|
||||
got := calculateSellerReferenceRatio(100, summary, options)
|
||||
if got != 43 {
|
||||
t.Fatalf("reference ratio = %v, want 43 (base 40 + missing skin penalties 3)", got)
|
||||
if got != 46 {
|
||||
t.Fatalf("reference ratio = %v, want 46 (base 45 + missing skins 3 - max levels 2)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateSellerReferenceRatioAppliesLevelTierOnce(t *testing.T) {
|
||||
options := systemconfig.DefaultPublishOptions()
|
||||
summary := map[string]any{
|
||||
"season_insurance": "3*3",
|
||||
"stamina_level": "6级",
|
||||
"load_level": "6级",
|
||||
"daily_loss_m": 10,
|
||||
}
|
||||
got := calculateSellerReferenceRatio(100, summary, options)
|
||||
if got != 47 {
|
||||
t.Fatalf("reference ratio = %v, want 47 (base 45 + missing skins 3 - level tiers 1)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCalculateSellerReferenceRatioAppliesSpecialSkinGroupOnce(t *testing.T) {
|
||||
options := systemconfig.DefaultPublishOptions()
|
||||
summary := map[string]any{
|
||||
"season_insurance": "3*3",
|
||||
"stamina_level": "7级",
|
||||
"load_level": "7级",
|
||||
"daily_loss_m": 10,
|
||||
"skin_groups": map[string]any{
|
||||
"melee": []any{"北极星", "龙牙", "赤霄"},
|
||||
},
|
||||
}
|
||||
got := calculateSellerReferenceRatio(100, summary, options)
|
||||
// 45 + 红皮缺失 1 + 砖皮缺失 1 - 体力/负重 2 - 特殊刀皮分组 1 = 44
|
||||
if got != 44 {
|
||||
t.Fatalf("reference ratio = %v, want 44", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,20 +75,20 @@ func TestApplyMainSiteReceivePricingOverwritesClientRatio(t *testing.T) {
|
||||
req := fullReceivePricingRequest(10)
|
||||
applyMainSiteReceivePricing(&req, systemconfig.DefaultPublishOptions(), defaultSalePriceConfig(), 0, 0, false)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 43 {
|
||||
t.Fatalf("seller_ratio = %v, want 43", breakdown["seller_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 46 {
|
||||
t.Fatalf("seller_ratio = %v, want 46", breakdown["seller_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["seller_reference_ratio"]) != 43 {
|
||||
t.Fatalf("seller_reference_ratio = %v, want 43", breakdown["seller_reference_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_reference_ratio"]) != 46 {
|
||||
t.Fatalf("seller_reference_ratio = %v, want 46", breakdown["seller_reference_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["seller_coin_base_price"]) != 232.6 {
|
||||
t.Fatalf("seller_coin_base_price = %v, want 232.6", breakdown["seller_coin_base_price"])
|
||||
if readSummaryNumber(breakdown["seller_coin_base_price"]) != 217.4 {
|
||||
t.Fatalf("seller_coin_base_price = %v, want 217.4", breakdown["seller_coin_base_price"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["buyer_ratio"]) != 38 {
|
||||
t.Fatalf("buyer_ratio = %v, want 38", breakdown["buyer_ratio"])
|
||||
if readSummaryNumber(breakdown["buyer_ratio"]) != 41 {
|
||||
t.Fatalf("buyer_ratio = %v, want 41", breakdown["buyer_ratio"])
|
||||
}
|
||||
if req.PriceCent != 26320 {
|
||||
t.Fatalf("PriceCent = %d, want 26320", req.PriceCent)
|
||||
if req.PriceCent != 24390 {
|
||||
t.Fatalf("PriceCent = %d, want 24390", req.PriceCent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +99,8 @@ func TestApplyMainSiteReceivePricingKeepsAcceleratedRatioWithinMainSiteRange(t *
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 50 {
|
||||
t.Fatalf("accelerated seller_ratio = %v, want 50", breakdown["seller_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["seller_reference_ratio"]) != 43 {
|
||||
t.Fatalf("seller_reference_ratio = %v, want 43", breakdown["seller_reference_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_reference_ratio"]) != 46 {
|
||||
t.Fatalf("seller_reference_ratio = %v, want 46", breakdown["seller_reference_ratio"])
|
||||
}
|
||||
if got := readSummaryNumber(breakdown["seller_coin_base_price"]); got != 200 {
|
||||
t.Fatalf("accelerated seller_coin_base_price = %v, want 200", got)
|
||||
@@ -85,7 +117,9 @@ func TestApplyMainSiteReceivePricingKeepsAcceleratedRatioWithinMainSiteRange(t *
|
||||
func TestApplyMainSiteReceivePricingIncludesPremiumReviewMarkup(t *testing.T) {
|
||||
req := fullReceivePricingRequest(50)
|
||||
req.IsPremium = true
|
||||
applyMainSiteReceivePricing(&req, systemconfig.DefaultPublishOptions(), defaultSalePriceConfig(), 0, 0, false)
|
||||
options := systemconfig.DefaultPublishOptions()
|
||||
options.RatioConfig.PremiumReviewRatioMarkup = 1
|
||||
applyMainSiteReceivePricing(&req, options, defaultSalePriceConfig(), 0, 0, false)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
if got := readSummaryNumber(breakdown["premium_review_ratio_markup"]); got != 1 {
|
||||
t.Fatalf("premium review markup = %v, want 1", got)
|
||||
@@ -105,13 +139,13 @@ func TestApplyMainSiteReceivePricingIncludesPremiumReviewMarkup(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestApplyMainSiteReceivePricingAllowsQualityOwnerExclusiveRatio(t *testing.T) {
|
||||
req := fullReceivePricingRequest(42)
|
||||
req := fullReceivePricingRequest(45)
|
||||
req.OwnerIsQualityOwner = true
|
||||
options := systemconfig.DefaultPublishOptions()
|
||||
applyMainSiteReceivePricing(&req, options, defaultSalePriceConfig(), 0, 0, false)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 42 {
|
||||
t.Fatalf("quality owner seller_ratio = %v, want 42", breakdown["seller_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 45 {
|
||||
t.Fatalf("quality owner seller_ratio = %v, want 45", breakdown["seller_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["quality_owner_ratio_discount"]) != 1 {
|
||||
t.Fatalf(
|
||||
@@ -120,11 +154,11 @@ func TestApplyMainSiteReceivePricingAllowsQualityOwnerExclusiveRatio(t *testing.
|
||||
)
|
||||
}
|
||||
|
||||
ordinary := fullReceivePricingRequest(42)
|
||||
ordinary := fullReceivePricingRequest(45)
|
||||
applyMainSiteReceivePricing(&ordinary, options, defaultSalePriceConfig(), 0, 0, false)
|
||||
ordinaryBreakdown := ensurePriceBreakdown(ordinary.AssetSummary)
|
||||
if readSummaryNumber(ordinaryBreakdown["seller_ratio"]) != 43 {
|
||||
t.Fatalf("ordinary seller_ratio = %v, want reference 43", ordinaryBreakdown["seller_ratio"])
|
||||
if readSummaryNumber(ordinaryBreakdown["seller_ratio"]) != 46 {
|
||||
t.Fatalf("ordinary seller_ratio = %v, want reference 46", ordinaryBreakdown["seller_ratio"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +169,8 @@ func TestQualityOwnerExclusiveRatioUsesConfiguredDiscount(t *testing.T) {
|
||||
options.RatioConfig.QualityOwnerRatioDiscount = 3
|
||||
applyMainSiteReceivePricing(&req, options, defaultSalePriceConfig(), 0, 0, false)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 40 {
|
||||
t.Fatalf("configured quality owner seller_ratio = %v, want 40", breakdown["seller_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 43 {
|
||||
t.Fatalf("configured quality owner seller_ratio = %v, want 43", breakdown["seller_ratio"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,11 +199,11 @@ func TestDistributionReceiveCostDeltaZeroKeepsMainSitePrice(t *testing.T) {
|
||||
req := fullReceivePricingRequest(50)
|
||||
applyMainSiteReceivePricing(&req, systemconfig.DefaultPublishOptions(), defaultSalePriceConfig(), 0, 0, true)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 43 {
|
||||
t.Fatalf("distribution seller_ratio = %v, want main-site reference 43 when cost delta is 0", breakdown["seller_ratio"])
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 46 {
|
||||
t.Fatalf("distribution seller_ratio = %v, want main-site reference 46 when cost delta is 0", breakdown["seller_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["buyer_total_price"]) != 263.2 {
|
||||
t.Fatalf("distribution buyer_total_price = %v, want 263.2 anchored to main site", breakdown["buyer_total_price"])
|
||||
if readSummaryNumber(breakdown["buyer_total_price"]) != 243.9 {
|
||||
t.Fatalf("distribution buyer_total_price = %v, want 243.9 anchored to main site", breakdown["buyer_total_price"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,24 +211,24 @@ func TestDistributionReceiveCostDeltaLowersReceivePriceKeepsSellPrice(t *testing
|
||||
req := fullReceivePricingRequest(50)
|
||||
applyMainSiteReceivePricing(&req, systemconfig.DefaultPublishOptions(), defaultSalePriceConfig(), 0, 3, true)
|
||||
breakdown := ensurePriceBreakdown(req.AssetSummary)
|
||||
// 压价 3 点:收号比例 = R+3 = 46,号主收 217.4(低于主站 232.6)。
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 46 {
|
||||
t.Fatalf("distribution seller_ratio = %v, want 46 (R+3) under cost-decoupled model", breakdown["seller_ratio"])
|
||||
// 压价 3 点:收号比例 = R+3 = 49,号主收 204.1(低于主站 217.4)。
|
||||
if readSummaryNumber(breakdown["seller_ratio"]) != 49 {
|
||||
t.Fatalf("distribution seller_ratio = %v, want 49 (R+3) under cost-decoupled model", breakdown["seller_ratio"])
|
||||
}
|
||||
if got := readSummaryNumber(breakdown["seller_coin_base_price"]); got != 217.4 {
|
||||
t.Fatalf("seller_coin_base_price = %v, want 217.4 (lower than main site 232.6)", got)
|
||||
if got := readSummaryNumber(breakdown["seller_coin_base_price"]); got != 204.1 {
|
||||
t.Fatalf("seller_coin_base_price = %v, want 204.1 (lower than main site 217.4)", got)
|
||||
}
|
||||
// 卖价锚定主站:买家比例仍为 38、买家价仍为 263.2,不随收号价下降。
|
||||
if readSummaryNumber(breakdown["buyer_ratio"]) != 38 {
|
||||
t.Fatalf("buyer_ratio = %v, want 38 (decoupled from receive ratio)", breakdown["buyer_ratio"])
|
||||
// 卖价锚定主站:买家比例仍为 41、买家价仍为 243.9,不随收号价下降。
|
||||
if readSummaryNumber(breakdown["buyer_ratio"]) != 41 {
|
||||
t.Fatalf("buyer_ratio = %v, want 41 (decoupled from receive ratio)", breakdown["buyer_ratio"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["buyer_total_price"]) != 263.2 {
|
||||
t.Fatalf("buyer_total_price = %v, want 263.2 unchanged by cost delta", breakdown["buyer_total_price"])
|
||||
if readSummaryNumber(breakdown["buyer_total_price"]) != 243.9 {
|
||||
t.Fatalf("buyer_total_price = %v, want 243.9 unchanged by cost delta", breakdown["buyer_total_price"])
|
||||
}
|
||||
// 注意:发布快照的 platform_markup_amount 仍为主站口径提价(30.6,锚定价→买价);
|
||||
// 压价差不在此体现,而是结算层 profit = 净付款 − 号主快照价(217.4)自动进入 35/40/25 分成池。
|
||||
if readSummaryNumber(breakdown["platform_markup_amount"]) != 30.6 {
|
||||
t.Fatalf("platform_markup_amount = %v, want 30.6 (main-site anchored markup)", breakdown["platform_markup_amount"])
|
||||
// 注意:发布快照的 platform_markup_amount 仍为主站口径提价(26.5,主站参考价→买价);
|
||||
// 压价差不在此体现,而是结算层 profit = 净付款 − 号主快照价(204.1)自动进入 35/40/25 分成池。
|
||||
if readSummaryNumber(breakdown["platform_markup_amount"]) != 26.5 {
|
||||
t.Fatalf("platform_markup_amount = %v, want 26.5 (main-site anchored markup)", breakdown["platform_markup_amount"])
|
||||
}
|
||||
if readSummaryNumber(breakdown["site_receive_cost_delta"]) != 3 {
|
||||
t.Fatalf("site_receive_cost_delta = %v, want 3", breakdown["site_receive_cost_delta"])
|
||||
|
||||
@@ -750,7 +750,7 @@ func TestExternalAccountToCreateRequestMapsUploadFields(t *testing.T) {
|
||||
if req.HafCoinAmount != 197100000 {
|
||||
t.Fatalf("expected haf coin amount 197100000, got %d", req.HafCoinAmount)
|
||||
}
|
||||
if req.PriceCent != 59590 || req.DepositAmountCent != 40000 {
|
||||
if req.PriceCent != 60040 || req.DepositAmountCent != 40000 {
|
||||
t.Fatalf("unexpected price/deposit cent %d/%d", req.PriceCent, req.DepositAmountCent)
|
||||
}
|
||||
if req.AssetSummary["season_insurance"] != "3*3" {
|
||||
@@ -790,10 +790,10 @@ func TestExternalAccountToCreateRequestMapsUploadFields(t *testing.T) {
|
||||
t.Fatalf("price_breakdown = %#v", req.AssetSummary["price_breakdown"])
|
||||
}
|
||||
if breakdown["seller_coin_base_price"] != 458.0 ||
|
||||
breakdown["consumable_price"] != 90.5 ||
|
||||
breakdown["seller_total_price"] != 548.5 ||
|
||||
breakdown["consumable_price"] != 95.0 ||
|
||||
breakdown["seller_total_price"] != 553.0 ||
|
||||
breakdown["buyer_coin_base_price"] != 505.4 ||
|
||||
breakdown["buyer_total_price"] != 595.9 ||
|
||||
breakdown["buyer_total_price"] != 600.4 ||
|
||||
breakdown["buyer_ratio"] != 39.0 ||
|
||||
breakdown["platform_markup_amount"] != 47.4 ||
|
||||
breakdown["platform_rule_type"] != "ratio_subtract" {
|
||||
@@ -850,19 +850,19 @@ func TestExternalAccountToCreateRequestSeparatesPureCoinAndExtraItems(t *testing
|
||||
t.Fatalf("price_breakdown = %#v", req.AssetSummary["price_breakdown"])
|
||||
}
|
||||
if breakdown["seller_coin_base_price"] != 659.0 ||
|
||||
breakdown["consumable_price"] != 11.0 ||
|
||||
breakdown["seller_total_price"] != 670.0 {
|
||||
breakdown["consumable_price"] != 12.0 ||
|
||||
breakdown["seller_total_price"] != 671.0 {
|
||||
t.Fatalf("回收租金未按纯币价与额外物品拆分:%#v", breakdown)
|
||||
}
|
||||
if breakdown["buyer_coin_base_price"] != 717.6 ||
|
||||
breakdown["buyer_total_price"] != 728.6 ||
|
||||
breakdown["buyer_total_price"] != 729.6 ||
|
||||
breakdown["buyer_ratio"] != 39.3 ||
|
||||
breakdown["platform_markup_amount"] != 58.6 ||
|
||||
breakdown["platform_rule_type"] != "ratio_subtract" {
|
||||
t.Fatalf("外部上传未按比例加价:%#v", breakdown)
|
||||
}
|
||||
if req.PriceCent != 72860 {
|
||||
t.Fatalf("PriceCent = %d, want 72860", req.PriceCent)
|
||||
if req.PriceCent != 72960 {
|
||||
t.Fatalf("PriceCent = %d, want 72960", req.PriceCent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1332,14 +1332,14 @@ func TestCreateDistributionListingUsesMainSiteReceiveRatio(t *testing.T) {
|
||||
}
|
||||
|
||||
pricing := ReceivePricingFromAssetSummary(mustMarshalSummary(t, dto.AssetSummary))
|
||||
if pricing.SellerRatio != 43 {
|
||||
t.Fatalf("distribution receive seller_ratio = %v, want 43 from main-site ratio_config", pricing.SellerRatio)
|
||||
if pricing.SellerRatio != 46 {
|
||||
t.Fatalf("distribution receive seller_ratio = %v, want 46 from main-site ratio_config", pricing.SellerRatio)
|
||||
}
|
||||
if pricing.SellerTotalPriceCent != 23260 {
|
||||
t.Fatalf("seller_total_price_cent = %d, want 23260", pricing.SellerTotalPriceCent)
|
||||
if pricing.SellerTotalPriceCent != 21740 {
|
||||
t.Fatalf("seller_total_price_cent = %d, want 21740", pricing.SellerTotalPriceCent)
|
||||
}
|
||||
if dto.PriceCent != 26320 {
|
||||
t.Fatalf("listing PriceCent = %d, want 26320 from main-site sale price", dto.PriceCent)
|
||||
if dto.PriceCent != 24390 {
|
||||
t.Fatalf("listing PriceCent = %d, want 24390 from main-site sale price", dto.PriceCent)
|
||||
}
|
||||
if dto.DistributionSiteCode != "dist_ratio_1" {
|
||||
t.Fatalf("DistributionSiteCode = %s, want dist_ratio_1", dto.DistributionSiteCode)
|
||||
@@ -1399,11 +1399,11 @@ func TestCreateDistributionListingAppliesSiteReceiveCostDelta(t *testing.T) {
|
||||
t.Fatalf("Create failed: %v", err)
|
||||
}
|
||||
pricing := ReceivePricingFromAssetSummary(mustMarshalSummary(t, dto.AssetSummary))
|
||||
if pricing.SellerRatio != 46 {
|
||||
t.Fatalf("seller_ratio = %v, want 46 after site cost delta 3 (R=43+3) under decoupled model", pricing.SellerRatio)
|
||||
if pricing.SellerRatio != 49 {
|
||||
t.Fatalf("seller_ratio = %v, want 49 after site cost delta 3 (R=46+3) under decoupled model", pricing.SellerRatio)
|
||||
}
|
||||
if dto.PriceCent != 26320 {
|
||||
t.Fatalf("listing PriceCent = %d, want 26320 (buyer price stays anchored to main-site R)", dto.PriceCent)
|
||||
if dto.PriceCent != 24390 {
|
||||
t.Fatalf("listing PriceCent = %d, want 24390 (buyer price stays anchored to main-site R)", dto.PriceCent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user