修正外部上传加价逻辑
This commit is contained in:
@@ -33,11 +33,15 @@ func (s *Service) ImportExternalUpload(ctx context.Context, req ExternalUploadRe
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
salePriceConfig, err := s.externalSalePriceConfig(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
clientUploadTime := parseClientUploadTime(req.UploadTime)
|
||||
results := make([]ExternalUploadResult, 0, len(items))
|
||||
resp := &ExternalUploadResponse{Total: len(items)}
|
||||
for index, item := range items {
|
||||
createReq := externalAccountToCreateRequest(uploaderName, req.UploadTime, item)
|
||||
createReq := externalAccountToCreateRequest(uploaderName, req.UploadTime, item, salePriceConfig)
|
||||
if err := validateRequest(createReq, rules); err != nil {
|
||||
if len(items) == 1 {
|
||||
return nil, err
|
||||
@@ -235,9 +239,14 @@ func parseClientUploadTime(value int64) *time.Time {
|
||||
return &parsed
|
||||
}
|
||||
|
||||
func externalAccountToCreateRequest(uploaderName string, uploadTime int64, item ExternalAccountData) CreateRequest {
|
||||
func externalAccountToCreateRequest(
|
||||
uploaderName string,
|
||||
uploadTime int64,
|
||||
item ExternalAccountData,
|
||||
salePriceConfig salePriceConfig,
|
||||
) CreateRequest {
|
||||
hafCoinM := item.Currency.HafuCoin
|
||||
price := item.Currency.RecycleRent
|
||||
pureCoinPrice := item.Currency.RecycleRent
|
||||
ratio := item.Currency.RecycleRatio
|
||||
insurance := insuranceFromSafeSlots(item.SafeSlots)
|
||||
staminaLevel := levelText(item.DailyConsumption.Stamina)
|
||||
@@ -245,16 +254,25 @@ func externalAccountToCreateRequest(uploaderName string, uploadTime int64, item
|
||||
skins := cleanStrings(item.Inventory.Skins)
|
||||
remark := strings.TrimSpace(item.Remark)
|
||||
onlineTimeText := normalizeExternalOnlineTimeText(item.OwnerOnlineTime)
|
||||
resources := externalResources(item.Inventory)
|
||||
consumablePrice := consumableValue(map[string]any{"resources": resources})
|
||||
pricing := calculateExternalPlatformPricing(
|
||||
hafCoinM,
|
||||
ratio,
|
||||
pureCoinPrice,
|
||||
consumablePrice,
|
||||
salePriceConfig,
|
||||
)
|
||||
assetSummary := map[string]any{
|
||||
"face_owner": "",
|
||||
"secret_kd": item.SecretKD,
|
||||
"fire_level": item.Level,
|
||||
"daily_loss_m": item.DailyLossM,
|
||||
"publish_ratio": ratio,
|
||||
"publish_ratio": pricing.BuyerRatio,
|
||||
"season_insurance": insurance,
|
||||
"stamina_level": staminaLevel,
|
||||
"load_level": loadLevel,
|
||||
"resources": externalResources(item.Inventory),
|
||||
"resources": resources,
|
||||
"skin_groups": externalSkinGroups(skins),
|
||||
"online_time_text": onlineTimeText,
|
||||
"ban_record": normalizeBanRecord(item.BanRecord),
|
||||
@@ -268,14 +286,14 @@ func externalAccountToCreateRequest(uploaderName string, uploadTime int64, item
|
||||
"price_breakdown": map[string]any{
|
||||
"seller_reference_ratio": ratio,
|
||||
"seller_ratio": ratio,
|
||||
"seller_coin_base_price": price,
|
||||
"seller_total_price": price,
|
||||
"consumable_price": consumableValue(map[string]any{"resources": externalResources(item.Inventory)}),
|
||||
"buyer_coin_base_price": price,
|
||||
"buyer_total_price": price,
|
||||
"buyer_ratio": ratio,
|
||||
"platform_markup_amount": 0,
|
||||
"platform_rule_type": "external_upload",
|
||||
"seller_coin_base_price": roundMoney(pureCoinPrice),
|
||||
"seller_total_price": roundMoney(pureCoinPrice + consumablePrice),
|
||||
"consumable_price": consumablePrice,
|
||||
"buyer_coin_base_price": pricing.BuyerCoinBasePrice,
|
||||
"buyer_total_price": pricing.BuyerTotalPrice,
|
||||
"buyer_ratio": pricing.BuyerRatio,
|
||||
"platform_markup_amount": pricing.PlatformMarkupPrice,
|
||||
"platform_rule_type": pricing.RuleType,
|
||||
},
|
||||
}
|
||||
if start, end, ok := parseExternalOnlineTimeRange(onlineTimeText); ok {
|
||||
@@ -293,7 +311,7 @@ func externalAccountToCreateRequest(uploaderName string, uploadTime int64, item
|
||||
HafCoinAmount: int64(math.Round(hafCoinM * 1000000)),
|
||||
AssetSummary: assetSummary,
|
||||
ScreenshotURLS: []string{defaultUploadScreenshot},
|
||||
PriceCent: yuanToCent(price),
|
||||
PriceCent: yuanToCent(pricing.BuyerTotalPrice),
|
||||
DepositAmountCent: yuanToCent(item.Deposit),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user