refactor(listing): 卖家发布定价改用整数分与基点

This commit is contained in:
yml2213
2026-10-30 14:49:33 +08:00
parent 37e1980d2d
commit ce93f1636d
18 changed files with 1492 additions and 343 deletions
@@ -42,6 +42,9 @@ func rowsToDTO(rows []listingRow) []ListingDTO {
func normalizedListingPriceCent(req CreateRequest) int64 {
if req.AssetSummary != nil {
if breakdown, ok := req.AssetSummary["price_breakdown"].(map[string]any); ok {
if buyerPriceCent := readSummaryInt64(breakdown["buyer_total_price_cent"]); buyerPriceCent > 0 {
return buyerPriceCent
}
buyerPrice := readSummaryNumber(breakdown["buyer_total_price"])
if buyerPrice > 0 {
return yuanToCent(buyerPrice)
@@ -144,11 +147,11 @@ func applySellerListingPrice(item *ListingDTO) {
if !ok {
return
}
sellerPrice := readSummaryNumber(breakdown["seller_total_price"])
if sellerPrice > 0 {
item.PriceCent = int64(math.Round(sellerPrice * 100))
sellerPriceCent := summaryMoneyCent(breakdown, "seller_total_price_cent", "seller_total_price")
if sellerPriceCent > 0 {
item.PriceCent = sellerPriceCent
}
sellerRatio := readSummaryNumber(breakdown["seller_ratio"])
sellerRatio := summaryRatio(breakdown, "seller_ratio_bps", "seller_ratio")
if sellerRatio > 0 {
item.AssetSummary["publish_ratio"] = sellerRatio
}